Skip to main content
Quentin Blanc
Associate
February 23, 2017
Question

LSE Crystal fail to start

  • February 23, 2017
  • 10 replies
  • 6096 views
Posted on February 23, 2017 at 11:32

Hello everyone,

I work on a clock project and have a problem with the LSE crystal. I first

made my program on a STM32F0Discovery and it worked properly. Then I made a PCB with a STM32F030R8T6 and tried to program it but the LSE didn't start

oscillating. I looked on the forum to see if anyone had the same issues than me and I found some people that said that it's the capacitors that cause the problem. They say that you need a crystal whit two 6pF capacitors and not a crystal with two 12pF like I had. So I tried that and it didn�t work either. Can someone help me further?

The crystal I'm using can be found

http://eu.mouser.com/ProductDetail/Epson-Timing/MC-306-327680K-A0ROHS/?qs=sGAEpiMZZMsBj6bBr9Q9acukpafrIaZ1R56uLk59WWc%3d

.

The 12pF capacitor can be found

https://www.distrelec.ch/en/capacitor-12-pf-0805-rnd-components-rnd-1500805n120j500/p/30065870?q=258799&page=1&origPos=1&origPageSize=50&simi=98.0

.

The 6pF capacitor can be found

http://eu.mouser.com/ProductDetail/AVX/08055A6R0CAT2A/?qs=sGAEpiMZZMs0AnBnWHyRQEncggutzp42xImDo6lXcbY%3d

.

For Init fonction is:

void init_RTC (void)

{

   RTC_InitTypeDef RTC_InitStructure;

   RTC_TimeTypeDef RTC_TimeStructure;

   // Enable the PWR clock

   RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);

   // Allow access to RTC

   PWR_BackupAccessCmd(ENABLE);

   // Reset RTC Domain

   RCC_BackupResetCmd(ENABLE);

   RCC_BackupResetCmd(DISABLE);

   // Enable the LSE OSC

   RCC_LSEConfig(RCC_LSE_ON);

   // Wait until LSE is ready

   while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)

   {

      //The program is hold in this loop

   }

   // Select the RTC Clock Source

   RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);

   // Enable the RTC Clock

   RCC_RTCCLKCmd(ENABLE);

   RTC_DeInit();

   //Disable write protection

   RTC_WriteProtectionCmd(DISABLE);

   RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_12;

   RTC_InitStructure.RTC_AsynchPrediv = 0x7F;

   RTC_InitStructure.RTC_SynchPrediv = 0xFF;

   RTC_Init(&RTC_InitStructure);

   RTC_TimeStructure.RTC_H12 = RTC_H12_AM;

   RTC_TimeStructure.RTC_Hours = 0;

   RTC_TimeStructure.RTC_Minutes = 0;

   RTC_TimeStructure.RTC_Seconds = 0x00;

   if(RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure)== ERROR)

      while (1)

{

};

   // Wait for RTC APB registers synchronisation

   RTC_WaitForSynchro();

}

Thank you for helping and have a nice day

Blanc Quentin

#stm32 #stm32f030 #rtc_waitforsynchro #lserdy #lse-rtc #lse #crystal #rtc #stm32f0
This topic has been closed for replies.

10 replies

Jan Waclawek
Visitor II
February 23, 2017
Posted on February 23, 2017 at 13:04

Post you PCB layout at aronud the crystal (or a photo).

JW

Quentin Blanc
Associate
February 23, 2017
Posted on February 23, 2017 at 13:41

Here is the PCB layout as asked. If you need more just ask.

Blanc Quentin

0690X00000606MDQAY.png0690X00000606PVQAY.png
Max
ST Employee
February 23, 2017
Posted on February 23, 2017 at 14:53

I don't like the 2 vias on OSC32_IN track and OSC32_OUT track seems too long to me.

You should start laying out your oscillator first to make sure the tracks are as short as possible.

But this is not bad enough to justify why your oscillator is not starting.

The EPSON MC-306 + 6pF capacitors is in the recommended listof

/external-link.jspa?url=http%3A%2F%2Fwww.st.com%2Fcontent%2Fccc%2Fresource%2Ftechnical%2Fdocument%2Fapplication_note%2Fc6%2Feb%2F5e%2F11%2Fe3%2F69%2F43%2Feb%2FCD002216pdf%2Ffiles%2FCD002216pdf%2Fjcr%3Acontent%2Ftranslations%2Fen.CD002216pdf

so it should be compatible

.

Are you sure you did solder the crystal is the right direction?

Max
ST Employee
February 23, 2017
Posted on February 23, 2017 at 14:09

STM32 LSE oscillators are made to work with very low consumption, and are therefore very sensitive...

You should have a look at

http://www.st.com/content/ccc/resource/technical/document/application_note/c6/eb/5e/11/e3/69/43/eb/CD00221665.pdf/files/CD00221665.pdf/jcr:content/translations/en.CD00221665.pdf

.

Try to play with the drive level of the oscillator.

/**Configure LSE Drive Capability */

__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH);

regards.

Max

Quentin Blanc
Associate
February 23, 2017
Posted on February 23, 2017 at 14:28

Hi

teissier.maxime

,

I tried all four level of drive capability but none of then worked. I called the function 'RCC_LSEDriveConfig(RCC_LSEDrive_***)' just before I enable the LSE with the function 'RCC_LSEConfig(RCC_LSE_ON)'.

Thanks for helping.

Blanc Quentin

Gidi
ST Employee
March 2, 2017
Posted on March 02, 2017 at 08:29

Maybe its just a simple thing, did you check the pinout? maybe it was placed in reverse? 

Try also 3pF capacitors, see if it starts.

Meet Patel
Visitor II
March 7, 2017
Posted on March 07, 2017 at 22:20

I am having exactly the same problem. I added the 32.768 kHz crystal along with 22pF capacitors on the discovery kit and it worked perfectly. But then I tried it on the PCB and it wouldn't work. It's just stuck waiting for LSE_RDY flag.

The crystal I am using is connected directly to the STM32F051 controller without any Via. I tried the solutions suggested earlier, like changing the LSE drive to High. Nothing worked for me.

I am using 22pF capacitors with the 32.768kHz oscillator both in DIP package. Could that be an issue? Is 22pF too high?

waclawek.jan
Super User
March 8, 2017
Posted on March 08, 2017 at 01:25

Some crystals in some designs simply take too long to start up. I don't know how long the 'library' code you posted waits for it, but you can simply put a breakpoint into the loop which waits for LSE to come up, and wait there 'manually' for a few seconds, observing the ready flag in the debugger.

As a last resort, you could also try to use the crystal from the 'known good' Disco board, or use a known-good crystal e.g. from a discarded clock.

Aren't the SMD crystals sometimes too sensitive on overheating during soldering? I have experience only with crystals in leaded packages.

JW

Tesla DeLorean
Guru
March 8, 2017
Posted on March 08, 2017 at 04:56

That looks to be a 12pF crystal, I'm pretty sure the BOM calls out the 6-7pF one, not the more common 9pF or 12pF ones, which historically have not functioned well with STM32 parts. ie not started at all, take a long time, or are simply off frequency.

This is the one you want

http://eu.mouser.com/ProductDetail/Epson-Timing/MC-306-327680K-E3ROHS/?qs=sGAEpiMZZMtrsVZKbinfr44N8ScY7KZU

 
Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
waclawek.jan
Super User
March 8, 2017
Posted on March 08, 2017 at 09:38

Now I don't know if this was a sheer luck but all crystals I tried with 12pF load worked at me. I was even able to observe them oscillating with the most common 1:10 scope probe (i.e. an extra 15pF or so); on the OUT pin only of course, the slightest extra load on IN pin killed the oscillations reliably, but they restored themselves after removing that load. I tried all this on a F4, which is said in AN2867 to have the smallest (fixed) gain of all STM32s. I used only leaded crystals, but of very varying source and quality (including salvaged from scrap clock as I mentioned above), and all worked.

This all said does not mean one should go for the 12pF crystals once the design calls for the 6pF ones - those from experiments above I measured run tens of ppm off their nominal frequency plus tolerance, btw.  I am just encouraging experimentation.

I stress that I am waiting up to 10 seconds in my code for the crystal to come up (as the RTC is under battery, this happens only at battery change, so it's a bearable procedure), and have seen some crystals to take literally seconds to come up oscillating properly.

JW

Meet Patel
Visitor II
May 11, 2017
Posted on May 11, 2017 at 12:39

[SOLVED]

Hello 

Blanc Quentin,

As I mentioned in my earlier comment, I also had the same issue as you described. Everything worked correctly on discovery kit, but not on PCB. I tried changing the capacitor values, changling the drive level but nothing worked for me. Finally, I went through this

http://www.st.com/content/ccc/resource/technical/document/application_note/c6/eb/5e/11/e3/69/43/eb/CD00221665.pdf/files/CD00221665.pdf/jcr:content/translations/en.CD00221665.pdf

 and it had all the answers I needed.

So, here is a list of all the changes that I made in my design to solve the problem.

  1. Insted of a cylindrical DIP package of 32.768 kHz crystal, I used

    https://www.digikey.com/product-detail/en/EPSON/MC-306-32.768K-E3-ROHS/SER2417CT-ND/1532560

     along with two 10pF capacitors in 1206 SMD package as load capacitors CL1 and CL2
  2. Made sure that Crystal is mounted very very close (less than 3mm) to the microcontroller as shown below

    0690X00000606iYQAQ.png
  3. Ocillator circuit has to be surrounded by a Guard Ring on the top layer of PCB, and by an isolated Ground Plane on the bottom layer of PCB as shown in below figure. The Guard Ring should be connected to underlying Ground Plane by multiple VIAs from top layer to the bottom layer.

    0690X00000606waQAA.png

  4. The Guard Ring and Ground Plane are to be connected only to the microcontroller ground and not to the rest of the circuit ground.

  5. Keep rest of the high frequency GPIO tracks away (more than 10mm) from the Oscillator circuit

  6. Keep the OSC32_IN and OSC32_OUT track of the same length and balanced

  7. Do not insert any test points on the tracks of oscillator circuit

Have a Look at my final PCB layout of Oscillator Circuit

TOP SIDE LAYOUT

0690X00000606yfQAA.png

BOTTOM SIDE LAYOUT

0690X00000606ykQAA.png

After applying above mentioned changes to a newly designed PCB, the LSE crystal started oscillating without any difficulties at all.

So my suggestion to you is to redesign the PCB keeping above points in mind.

I hope this helps you.

Ben Moulin
Associate
June 12, 2017
Posted on June 12, 2017 at 14:00

Hi

Patel.Meet.002

,

Do you know how long does it take to have the LSE ready on your new design ?

On my side I have to wait 2 sec on :RCC_GetFlagStatus(RCC_FLAG_LSERDY)...

Meet Patel
Visitor II
June 13, 2017
Posted on June 13, 2017 at 06:48

Hi Ben Moulin,

After the new design, it takes less than 1 second. Slightly more time is taken when selecting LSE as a clock source for the first time, but after that, hardly 1 second for LSE to be ready in the subsequent runs.

Earlier it used to take as long as 1 minute for the LSE ready flag, and even after that, the clock timing was not accurate.

As far as I remember, the controller waits for 4000 perfect pulses from the crystal before making LSE = 1.

So, if the crystal frequency is 32.768 kHz, then it will require atleast 0.122 seconds provided that the oscillator was already working.

It also depends on factors like load capacitance, drive level etc.

However, I think the 2 second time taken by the LSE to be ready in your case is alright if you are not facing any issues during the operation.