Loading ...
Sorry, an error occurred while loading the content.

5203PLL of LPC2378

Expand Messages
  • T VH
    Mar 25, 2014
    • 0 Attachment
      Dear,

      I am trying to get the PLL working on the LPC2378 on an olimex developement board
      it does not work, and I can't figure out what the solution is.
      I' have figured out that the PLL does not lock, but I also lose the JTAG connection.

      the code:

      int main (void) {
      int  j; // loop counter (stack variable)

      FIO1DIR |= 1<<19; // p0.12 as output -> Stat led
      FIO1SET |= 1<<19;

      VICSWPriorityMask = 0;
      VICIntEnClr=0xffffffff;

      FIO4CLR |= 1<<31;
      // 1. Init OSC
        //SCS_bit.OSCRANGE = 0;
        //SCS_bit.OSCEN = 1;
      SCS &= ~(1<<4); // OSCRANGE = 0
      SCS |= (1<<5); // OSCEN = 1
        // 2.  Wait for OSC ready
        //while(!SCS_bit.OSCSTAT);
      while (!(SCS|(1<<6)));
        // 3. Disconnect PLL
        //PLLCON_bit.PLLC = 0;
      PLLCON &= ~(1<<1);
      FIO4SET |=1<<31;
        PLLFEED = 0xAA;
        PLLFEED = 0x55;
      FIO4CLR |= 1<<31;
        // 4. Disable PLL
        //PLLCON_bit.PLLE = 0;
        PLLCON &= ~(1<<0);
      FIO4SET |= 1<<31;
        PLLFEED = 0xAA;
        PLLFEED = 0x55;
      FIO4CLR |= 1<<31;
        // 5. Select souce clock for PLL
        //CLKSRCSEL_bit.CLKSRC = 1; // Selects the main oscillator as the PLL clock source.
        CLKSRCSEL=0x01;
        // 6. Set PLL settings 144 MHz
        PLLCFG = (6) | (6 << 16);
      FIO4SET |= 1<<31;
        PLLFEED = 0xAA;
        PLLFEED = 0x55;
      FIO4CLR |= 1<<31;
        // 7. Enable PLL
        //PLLCON_bit.PLLE = 1;
        PLLCON |= 1<<0;
      FIO4SET |= 1<<31;
        PLLFEED = 0xAA;
        PLLFEED = 0x55;
      FIO4CLR |= 1<<31;
        // 8. Wait for the PLL to achieve lock
        //while(!PLLSTAT_bit.PLOCK);
        while (!(PLLSTAT &(1<<26)));
      FIO4SET |= 1<<31;
        
        // 9. Set clk divider settings
        CCLKCFG   = 0;  
      FIO4CLR |= 1<<31;
        USBCLKCFG = 0;
      FIO4SET |= 1<<31;
        PCLKSEL0 = PCLKSEL1 = 0; 
        // 10. Connect the PLL
        //PLLCON_bit.PLLC = 1;
        PLLCON |= 1<<1;
      FIO4SET |= 1<<31;
        PLLFEED = 0xAA;
        PLLFEED = 0x55;
      FIO4CLR |= 1<<31;
      //SCS |= 0x01;
      // Initialize the system
      //Initialize();
      FIO4CLR |= 1<<31;

       MAMCR = 0; // disable MAM
      FIO4SET |= 1<<31;
        MAMTIM = 4;    // FCLK > 40 MHz
      FIO4CLR |= 1<<31;
        MAMCR = 1;   // MAM functions fully enabled
      FIO4SET |= 1<<31;
      VICSWPriorityMask = 0xFFFF;
      while(1);
      }

      kind regards