Content originally posted in LPCWare by kiryat8 on Thu Apr 19 03:23:12 MST 2012
I am using a LPC1768 board (12MHz crystal) with Code Red CMSISv2.
This is a low power project so I must turn off both PLLs most of the time.
My problem is that I do need the USB serial interface for parameter update after manual user input.
If I enable both defines PLL0_SETUP & PLL1_SETUP in the CMSIS lib file,
my USB serial code (from example) works fine but I consume too much current.
If I enabled only PLL1_SETUP with PLL1CFG_Val the default 0x23 value but the USB does not work.
I had thought to switch on PLL1 when I need USB and then switch it back off.
When both defines are zero and I then try to enable only PLL1, PLL1 does not lock after the first enable and loops forever. The LPC1768 is running from the Crystal at this stage.
I can not see any problem in my code.
//---------------------------------------------------------------------------
// Switch power to main crystal oscillator on
//---------------------------------------------------------------------------
LPC_SC->SCS = OSCEN;
while ((LPC_SC->SCS & OSCSTAT) == 0);
LPC_SC->PLL1CFG = PLL1CFG_Val; // 0x23
LPC_SC->PLL1FEED = PLLFEED1; // 0xAA
LPC_SC->PLL1FEED = PLLFEED2; // 0x55
//---------------------------------------------------------------------------
// PLL1 Enable
//---------------------------------------------------------------------------
LPC_SC->PLL1CON = CLKPWR_PLL1CON_ENABLE; // 0x01
LPC_SC->PLL1FEED = PLLFEED1; // 0xAA
LPC_SC->PLL1FEED = PLLFEED2; // 0x55
//---------------------------------------------------------------------------
// Wait for LOCK
//---------------------------------------------------------------------------
while (!(LPC_SC->PLL1STAT & CLKPWR_PLL1STAT_PLOCK)); // (1<<10)
//---------------------------------------------------------------------------
// PLL1 Enable & Connect
//---------------------------------------------------------------------------
LPC_SC->PLL1CON = CLKPWR_PLL1CON_ENABLE | CLKPWR_PLL1CON_CONNECT; // 0x01 | 0x02
LPC_SC->PLL1FEED = PLLFEED1; // 0xAA
LPC_SC->PLL1FEED = PLLFEED2; // 0x55
//---------------------------------------------------------------------------
// Wait for PLLC1_STAT & PLLE1_STAT
//---------------------------------------------------------------------------
while (!(LPC_SC->PLL1STAT & (CLKPWR_PLL1STAT_PLLE | CLKPWR_PLL1STAT_PLLC)));
Any help would be appreciated.