LPC1769 Configure Clock?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1769 Configure Clock?

1,399 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by belskyc on Thu Mar 21 17:11:28 MST 2013
Hello,
Really basic question.  On the LPC1769, I'm trying to setup the clock such that:
CCLK = OSC_CLK.  Here's the initializing code I tried:

LPC_SC->CLKSRCSEL &= ~(0x00000003);  // sysclk = osc_clk: Setup External Oscillator = 12Mhz.
LPC_SC->CLKSRCSEL |=  (0x00000001);
LPC_SC->PLL0CON   &= ~(0x00000003);  // pllclk = sysclk: Disable and bypass PLL.
LPC_SC->CCLKCFG   &= ~(0x000000FF);  // cclk = pllclk = sysclk:  Clock Divide = 1.

When I try to run on the LPCXpresso LPC1769 demo board, the debugger crashes.  However, if I comment out this and rely on register defaults for the clock (using the IRC - Internal RC Oscillator), it runs. 

Does anyone see what I'm missing or have any examples on simple configurations of the clock? 

Thanks much,
~
0 Kudos
1 Reply

650 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Mar 21 19:51:16 MST 2013
Your code is switching to main clock (= crystal) without problem

Unfortunately you've forgotten to start main clock
 LPC_SC->SCS       =  (1<<5);            //enable main oscillator bit 5
 while ((LPC_SC->SCS & (1<<6)) == 0);/* Wait for Oscillator to be ready    */
This is starting your crystal circuit at XTAL1/2 and waiting until it's ready

All this is doing CMSIS (if enabled) for you in SystemInit()  of system_LPC17xx.c
0 Kudos