32 KHz RTC lSE

- Dear cgrenier,

Could you please share us your hardware schematics of the LSE and external quartz datasheet + Capacitors used. Please Note that 12.5pF quartz are not compatible with STM32 LSE as stated in datasheet :

For CL1 and CL2 it is recommended to use high-quality ceramic capacitors in the 5 pF to 15 pF range selected to match the requirements of the crystal or resonator. CL1 and CL2, are usually the same size. The crystal manufacturer typically specifies a load capacitance which is the series combination of CL1 and CL2.

Load capacitance CL has the following formula: CL = CL1 x CL2 / (CL1 + CL2) + Cstray where Cstray is the pin capacitance and board or trace PCB-related capacitance. Typically, it is between 2 pF and 7 pF.

Caution: To avoid exceeding the maximum value of CL1 and CL2 (15 pF) it is strongly recommended to use a resonator/Quartz with a load capacitance CL ≤ 7 pF. Never use a resonator with a load capacitance of 12.5 pF.

Example: if you choose a resonator with a load capacitance of CL = 6 pF, and Cstray = 2 pF, then CL1 = CL2 = 8 pF.

Hope this may explain you why your LSE is not starting sometimes.

Cheers,

STOne-32. - Hi,

This is not good/recommended, it may work but not safe. you should replace your quartz with a Cload =< 7pF and CL1, CL2 are in range of twice Cload if we assume that Cstray and parasitic caps are Zero.

Changing CL1, CL2 values will then create a drift on the Fundamental frequency of your (32.768Khz) depending on its characteristics details in quartz manufacturer and then may affect the reliability of operation if not calibrated and taken into account. Cheers,

STOne-32. - We have also had problems using the LSE. Sometimes it works, sometimes not.

I am using a 65.536kHz crystal with a load capacitance of 12.5pF. The crystal is close to the micro, but we still have around 10pF parasitic capacitance on the PCB, so even using a crystal with a load capacitance of 7pF could still be problematic.

I cannot find any 65.536kHz crystals with less than 12.pF that are readily available (we can't use a 32.768kHz unfortunately due to RTC dividing issues). I have never experienced a problem like this with any other micro. Has anyone else had a problem with the LSE?

James - Hi James,

Here are some Quartz data-sheets that you can refer to :

http://www.kds.info/data/pdf/035E.pdf

and also this one attached below.

ST1. - Hi jdmallett;

There is an important parameter that is often neglicted or unknown, it's the gain margin of the internal inverter. This parameter determines if the oscillator will be start or not. A gain margin of 5 can be considered as a minimum to ensure an efficient start-up of the oscillations.

gain margin = gm / gm_min

gm is the transconductance of the internal inverter. Refer to the table 22 and 23 in the datasheet:

For the HSE: gm = 25mA/V and for the LSE: gm = 5µA/V

the gm_min formula is given by: gm_min = 4*ESR*(2*PI*F)²(C0 + CL)²

Where: ESR is the series resistor (specified by the crystal manufacturer)

C0 is the shunt capacitance (specified by the crystal manufacturer)

CL is the load capacitance (specified by the crystal manufacturer)

F is the frequency of the crystal

let's take an example for HSE part:

let's take the part number of HOSONIC ELECTRONIC a 8MHz quartz: HC-49S-8MHz which has the following caracterstics:

CL = 10pF, C0 = 7pF, ESR = 80ohm

gm_min = 4*80*(2*3.14*8000000)²*(7E-12+10E-12)² = 2.33E-4 A/V

if we calculate the gain margin of this oscillator:

gain margin = 25E-3/2.33E-4 = 107 >> 5 ==> the oscillator has a sufficient gain to make the oscillation to start-up.

Now, let's take the example of the LSE part:

if we take MC306C12O part number from JFVNY manufacturer: its caracterstics are:

CL = 12.5pF, C0 = 2pF, ESR = 50kohm

gm_min = = 4*50E3*(2*3.14*32768)²*(12.5E-12+2E-12)² = 1.78E-6 A/V

Let's now calculate the gain margin of this oscillator:

since gm = 5E-6 A/V (refer to the table 23 in the datasheet)

gain margin = 5E-6/1.78E-6 = 2.8 < 5 ==> the oscilator won't startup since the gain is insufficient to make the oscilations to start up.

I hope that I answered the question :)

B.R.

M3allem - Dear James,

As said previously, the most Important parameter to let the Oscillator starting up is Gm.

As detailed by M3allem, You can at this first step select your Quartz that will satisfy the Oscillation condition ( Based on CL, Co & ESR)

Finally, you have just to tune the CL1 and CL2, Parasatic capacitance, taking into account to match the Parallel Capacitance seen by the OSC_IN and OSC_OUT which should be equal to Cload of the quartz.

You can not measure the parasitic capacitance with a simple instrument or standard oscilloscope probe. It has to be qualified with quartz manufacturers based on your PCB, Most of quartz/Resonator manufacturers provide this service for their customers.

Cheers,

STOne-32.

PS: By the way, I believe that you have already addressed your case to our local US office, isn't it ? - Hi all,

A new application note is available on the web: "Oscillator design guide for ST microcontrollers " (AN2867).

For the first part, it introduces some Pierce oscillator basics (some theory).

In second part, it provides some guidelines for a good oscillator design. It gives some good crystal part numbers for STM32's external clocks: HSE and LSE.

B.R.

M3allem

[ This message was edited by: M3allem on 03-02-2009 10:41 ]

I understood the problem. The 32 KHz is not started by the MCU. After a power up, I enabled Pc.13 to output 32KHz/64 = 512 Hz. Sometimes, I see the signal. But when it loops for ever in RTC_WaitForLastTask(), the 32 KHz is not started.

Do you have an idea why the 32 KHz is not started?