Problem with the main oscillator

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

Problem with the main oscillator

787 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Thu Apr 16 05:58:31 MST 2015
Hey guys,

it's me again. After debugging my board with the IRC i wanted to switch to the main osc.
So i wrote a function which i call at the beginning of the main function. In this function i wanted to set up the oscillator
and deactivate the PLL0 (i don't need it). The CPU should just be clocked by the main osci.

void MAIN_CLK_without_PLL(bool f_15_25MHz)
{
//first step PLL0 Setup Sequence
if(Chip_Clock_IsMainPLLConnected())
{
Chip_Clock_DisablePLL(SYSCTL_MAIN_PLL, SYSCTL_PLL_CONNECT);//disconnect PLL0
}
//second step in PLL0 Setup Sequence
if(Chip_Clock_IsMainPLLEnabled())
{
Chip_Clock_DisablePLL(SYSCTL_MAIN_PLL, SYSCTL_PLL_ENABLE);//deactivat PLL0
}
//third step in PLL0 Setup Sequence

if(f_15_25MHz)
{
LPC_SYSCTL->SCS |= SYSCTL_OSCRANGE_15_25;//Oscillator got a frequencie between 15 and 25 MHz
}else{
LPC_SYSCTL->SCS &= ~SYSCTL_OSCRANGE_15_25;
 }

LPC_SYSCTL->SCS |= SYSCTL_OSCEC;//activate main oscillator
while(!Chip_Clock_IsCrystalEnabled()) {}//wait till oscillator is started correc

Chip_Clock_SetCPUClockDiv(0);//set the cpu prescaller to 1 
Chip_Clock_SetMainPLLSource(SYSCTL_PLLCLKSRC_MAINOSC);

//for testing deliver the clock on CLKOUT

Chip_IOCON_PinMux(LPC_IOCON, PORT_1, PIN_27, IOCON_MODE_INACT, IOCON_FUNC1);
Chip_Clock_SetCLKOUTSource(SYSCTL_CLKOUTSRC_CPU, 1);
Chip_Clock_EnableCLKOUT();
}


After i tried this with several crystals (24MHz and 14.7456MHz) and measured on the CLKOUT Pin the frequency always had been wrong.
The crystall is connected to two 18pF Capacities.
Have i made a error in setting up the oscillator?

Any advice would be great.

Regards




Labels (1)
0 Kudos
Reply
2 Replies

756 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xianghuiwang on Mon Apr 27 18:58:38 MST 2015
Hi,
you need to switch the main clock to IRC before powering down the pll if the pll was used with the IRC.
Use CLKOut pin to confirm this is correct. Then switch to use main oscillator to feed the pll. You can reference the LPCOpen sample project for this portion of the implementation.

Regards!
0 Kudos
Reply

756 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Thu Apr 16 06:02:23 MST 2015
Oh i forgot to say that i am working on an LPC1763
0 Kudos
Reply