15 Replies Latest reply on Jun 13, 2017 6:48 AM by Meet Patel

    LSE Crystal fail to start

    Quentin Blanc

      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 here.

      The 12pF capacitor can be found here.

      The 6pF capacitor can be found here.

      For Init fonction is:

      void init_RTC (void)
         RTC_InitTypeDef RTC_InitStructure;
         RTC_TimeTypeDef RTC_TimeStructure;

         // Enable the PWR clock

         // Allow access to RTC

         // Reset RTC Domain

         // Enable the LSE OSC

         // Wait until LSE is ready
         while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
            //The program is hold in this loop
         // Select the RTC Clock Source

         // Enable the RTC Clock


         //Disable write protection

         RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_12;
         RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
         RTC_InitStructure.RTC_SynchPrediv = 0xFF;

         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




      Thank you for helping and have a nice day

      Blanc Quentin

        • Re: LSE Crystal fail to start
          Jan Waclawek

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



          • Re: LSE Crystal fail to start

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

            You should have a look at AN2867.


            Try to play with the drive level of the oscillator.


            /**Configure LSE Drive Capability */





            1 of 1 people found this helpful
            • Re: LSE Crystal fail to start
              Gidi M

              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.

              • Re: LSE Crystal fail to start
                Meet Patel

                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?

                • Re: LSE Crystal fail to start

                  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.



                  • Re: LSE Crystal fail to start
                    Clive One

                    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


                    • Re: LSE Crystal fail to start

                      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.



                      • Re: LSE Crystal fail to start
                        Meet Patel



                        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 Oscillator design guide for STM microcontrollers 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 MC-306 crystal with 6pF load capacitance 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
                        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.

                        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


                        BOTTOM SIDE LAYOUT


                        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.

                        3 of 3 people found this helpful
                        • Re: LSE Crystal fail to start
                          Ben Moulin

                          Hi Meet Patel,

                          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)...

                            • Re: LSE Crystal fail to start
                              Meet Patel

                              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.