2018-03-04 10:57 PM
Hello there,
I am using an STM32L4 family MCU. In an application, the RTC peripheral is utilized and clocked from an external crystal:
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.2018-03-07 04:21 AM
No doubt. The mains is a 5000 mAh battery + it was connected to the charger. Even if power went down the battery would last about 60h.
Also no reset events in the logs.
2018-03-07 04:30 AM
Thanks for the example Szymon, exactly what I needed.
So I have the scope view here:
The time for a full period is ~3.5 us, which gives 32786,8852459016393442623 Hz. I think that it is correct. I am not sure however why is the MCO output PWM not 50 %.
Can the crystal frequency be ruled out as a problem ir is the measurement not precise enough?
2018-03-07 05:21 AM
3.5us period means a frequency just shy of 300khz. Something is seriously wrong here.
Those crystals have a pullability of about 0.5hz per pf. So they cannot possibly account for a material portion of your error here.
2018-03-07 06:47 AM
sorry, its a mistype in the post. Its 5 us, not 3.5 us. That gives the proper frequency.
2018-03-08 02:56 AM
Your design is wrong. You should have 6pF for (C16.C17/C16+C17) + Cx, with Cx tracks + STM32 pins capacitance (few pF).
Crystals with CL=6pF are made for direct connection to microcontroller/RTC and hard to design.
Take a 12.5pF crystal (the most used value) and C16=C17=22pF. Have a look on the STM32 hardware manual regarding the crystal power.
Theo.
2018-03-08 04:57 AM
In the meanwhile, here is an interesting reading about the hardware pov
2018-03-08 05:01 AM
thanks for the like.
To be complete, capacitors should be 22pF/C0G class and at 32kHz, the crystal is thick and you can't destroy it even at full power. But you can tweak it to reduce power consumption.
Theo
2018-03-08 05:40 AM
Fine. As suggested by Danilotto Runi, make a quick calculations with the Application Note regarding ESR and max power for your resonator.
Theo
2018-03-08 06:05 AM
Ok, so now I have choosen these:
https://www.tme.eu/gb/details/abs25-32.768khz/smd-quartz-crystals/abracon/abs25-32768khz-t/
https://www.tme.eu/gb/details/cc0603frnpo9220/0603-mlcc-smd-capacitors/yageo/cc0603frnpo9bn220/
Thank you.
2018-03-08 06:16 AM
There are two parts to this issue?
1. Why is the crystal 600ppm off?
2. Why is the rtc 6000ppm off?
Once you lay that out, it becomes crystal clear where to focus your effort.