Problem with the main oscillator

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

Problem with the main oscillator

1,777 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Mon Apr 20 00:36:26 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
10 Replies

1,715 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Tue Apr 21 04:06:33 MST 2015
Update:

I tried it with a 5MHz crystal, everything works pretty well with this frequency.

Could it be that my circuit path (about 2cm) is too long for 14,7456MHz?

Regards
0 Kudos
Reply

1,715 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Tue Apr 21 02:17:37 MST 2015
Hey R2D2,

i don't wanted to attach a datasheet because it looks really lazy from my side. Like solve my problem  ;-)
I developed the board.

The code is not more than this function and the main :-D

Regards



0 Kudos
Reply

1,715 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Apr 21 02:04:48 MST 2015
:quest:

It's not possible to help you if you don't tell us which crystal ([color=#c00]DATASHEET[/color]), which hardware and which software and project you are using  :((

At the moment I just know that you are using some kind of 1763 board with a crystal and a code snippet...

So I don't know if you have a faulty hardware or if your Picosope is too slow...



0 Kudos
Reply

1,715 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Tue Apr 21 01:43:08 MST 2015
Hey R2D2,

1) I changed the capacities Cx1 and Cx2 (7, 10,18, 22 and 33pF) also i changed the crystal (same frequency 14,7456 MHz).
I also changed the board (i got two with the same MCU)

2) I am not completly sure what you mean. But i first used a Sunny crystal unit and then i switched to a Raltron crystal.

3) I am using a LPC1763

4) The attached pictures are meassured on the CLKOUT Pin, but i also meassured on XTAL1 and XTAL2

5) I am using LPCXpresso v7.6.2 with the redlink server and as GDB Debugger: arm-none-eabi-gdb.

6) I tried it on my two different boards, with the same result.

Regards
0 Kudos
Reply

1,715 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Apr 21 01:24:38 MST 2015
I'm not sure what you are doing in detail  :quest:

Which crystal are we talking about (DS) ?

Which hardware are we talking about ?

Did you connect your Picoscope to XTAL1 / XTAL2 ?

Which toolchain are we talking about (could be useful to post your project) ?

Did you test other boards ?


0 Kudos
Reply

1,715 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Tue Apr 21 01:21:21 MST 2015
Hey,

so with the load capacitance of 18pF and Cstray 7pF i got 22pF.
I tried it, with the same result (meassured frequency at crystal and CLKOUT 5,254 MHz)
So because the crystal delivers 5.2MHz i changed it to another 14.7456MHz crystal. Still the same result.

Even after trying different capacitance (7, 10, 18 and 33pF), same result. 
I also tried the whole thing on an other MCU, same result.

I also tried with setting the OSC Range (SYSCTL_OSCRANGE_15_25) and without setting the OSC Range.

When i change:
Chip_Clock_SetCPUClockDiv(0);

to
Chip_Clock_SetCPUClockDiv(1);


i meassure a frequency of 7,34MHz. But the signal looks deformed. I attached two pictures of the meassured signals, may it will help you.

Thanks for your help
regards

0 Kudos
Reply

1,715 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Mon Apr 20 06:10:06 MST 2015
I would start with Cstray = 7pF.
0 Kudos
Reply

1,715 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Apr 20 04:50:14 MST 2015

Quote: Patrick_W
The crystall is connected to two 18pF Capacities.



Look in your crystal datasheet (CL) and calculate CX1/2  :O

http://www.lpcware.com/content/faq/how-calculate-value-crystal-load-capacitors

Then change your caps, probably to something around 30pF  :)
0 Kudos
Reply

1,715 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Patrick_W on Mon Apr 20 01:37:57 MST 2015
Hey Wolfgang:

1) With the 14.7456MHz crystal, the meassured frequency varies between 4.75 and 4.76MHz
2) The shunt cabacity souldn't be larger then 7pF

Thanks for your reply.

Regards
0 Kudos
Reply

1,715 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Mon Apr 20 01:02:18 MST 2015
How big is the frequency error? Please give numbers.

How big is the shunt capacity of your crystals in the data sheet?

We can not help you without data.

regards
Wolfgang
0 Kudos
Reply