cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 low RTC precision

Posted on March 05, 2018 at 07:57

Hello there,

I am using an STM32L4 family MCU. In an application, the RTC peripheral is utilized and clocked from an external crystal:

0690X00000609xVQAQ.png

0690X00000609vUQAQ.png

The problem I have noticed just now is that with time, the RTC timer looses sync. It is not easy to notice in short periods of time, but after leaving the application to log time for entire weekend, I noticed that the RTC timer is over 20 minutes later after my PC timer (they were both synced before the weekend).

What could be the cause of this problem? Its hard to believe for me that the RTC timer is simply this low precision, as I am using an external crystal. I would appreciate all help.

#precision #stm32l4 #rtc

Note: this post was migrated and contained many threaded conversations, some content may be missing.
71 REPLIES 71
Posted on March 11, 2018 at 21:37

...it's not about frequency, it's about the ultra-high impedances. The additional capacitance of the board (could be on the order of 1 to 2 pF) can make the difference. You may want to try to reduce the capacitors to 3,3 or 4,7 pF as a quick test. This change might save you the day.

Posted on March 11, 2018 at 22:28

Anything will make a difference, including the guy blowing his candle 2 continents away.

That's not the point. The point is will it make a material difference? The biggest difference comes from the side of small load capacitance. Luckily, the pin capacitance helps, as will as the high q from the crystal.

Again, focus on why this thing is 6000ppm off. With that much error, something that makes 20 to 30ppn makes practically zero difference.

Posted on March 11, 2018 at 22:37

You bet it does: it's not that less capacitance would bring the crystal on the frequency, rather would possibly make the crystal be part of the oscillator. At 6000 ppm off-frequency, the crystal acts as a simple capacitor and the STM oscillator is free running, as if there would be no crystal in the circuit. For me there is no question about it. The goal here is to make the crystal become part of the circuit. I have seen this several times in my long, long career.

Posted on March 11, 2018 at 23:15

Google the load curve of a typical 32k crystal.

It will help you with some perspectives. No theory needed.

Posted on March 12, 2018 at 19:05

So would you recommend this oscillator?

https://www.tme.eu/gb/details/32.768k-26smd-sr/smd-quartz-crystals/sr-passives/32768k-26smd-sr/

 

With the case soldered to GND?

Posted on March 14, 2018 at 09:31

The datasheet states that the can should not be soldered, but only glued:

0690X0000060A4rQAE.png

Mazur.Grzegorz

‌ could you please elaborate on what did you mean exacly to solder the case?

Danilotto Runi
Associate II
Posted on March 14, 2018 at 14:06

I was reading today an ST document about hardware design and I got into this:

0690X0000060A7pQAE.png

What about using a MEMS oscillator like this

http://www.abracon.com/Oscillators/ASTMKJ.pdf

 

to get rid of the crystal circuit tuning mess? Did anyone tried this approach?

Posted on March 14, 2018 at 16:09

I have used some mems oscillators - and found them to be nothing special vs. the regular crystal. they do consume considerably less energy than the regulator oscillators.

I think they are useful in two areas:

1. low power consumption - obviously;

2. tough environment where you are concerned about a crystal not getting to oscillation.

I don't think there is much to gain here by going to an external oscillator, including a mems oscillator.

Igor Cesko
ST Employee
Posted on March 16, 2018 at 10:39

Please check also the firmware behavior.

If the CPU is waking up periodically from low power mode in some intervals (for example from standby mode) then it can go through function which is configuring the LSE clock (startup code). Usually this function enables LSE clock - but please check if the function which is enabling LSE clock firstly not disables it (for example by masking bit in register) and then immediately enables it (setting bit in register). Problem is that the startup of XTALL is quite slow - which can lead to delaying the time in RTC (delay depends from wakeup interval setting).

Posted on March 16, 2018 at 13:07

Lukasz is already aware of this, see

https://community.st.com/0D50X00009XkhQJSAZ

and his answer to it.

JW