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-09 01:11 PM
the issue there is related to insufficient drive, to my undrestanding, on F1 chips -> i'm not aware of F2/F4 chips having similar issues.
not sure if that applies here as the oscillator is obviously working, unless the clock is switched to LSE -> if so, the error of 6000ppm wouldn't sufficient.
the whole thing is fairly easy to debug.
2018-03-09 01:48 PM
Just to sum things up:
Am I right or did I not get something?
2018-03-09 06:17 PM
Set the scope to measure 10 cycles, you can get a better measurement that way.
Yes, pull the crystall and caps off the board.
clean footprints with Metho, then flux and replace with new high quality matched parts. (xtal and caps)
you should be able to get to 100ppm easily.
then bake for a few hours and use conformal coating to stabilize the crystal frequency.
if you would like to send the cube file I can have a look. not sure there is anything to see there...
but just so you know, 32768.1 is bad enough, 32786.885 is horrible.
2018-03-10 01:45 AM
Thanks for answer,
I will start with replacing the parts and trying to get better scope, this one has limited functionality.
Just a personal note: I wish my more critical problems described on those forums escalated this far.
2018-03-10 03:59 PM
Like they have been saying, you may want a frequency counter, much more accurate for this measurement.
2018-03-11 01:31 AM
I tried to read all the answers in this topic and I cannot find an answer similar to my experiences - excuse me if overlooked it. Here are my suggestions:
The L4 LSE circuit is EXTREMELY sensitive to interferences. Any change of state on the tracks on the PCB going close to the oscillator (even if no current flows through them) results in LSE skipping several pulses and getting out of sync. What you observe is not a surprise, it's how it typically behaves.
To eliminate the problem, make sure that:
- the connections between MCU and crystal ale short,
- there are ABSOLUTELY NO SIGNAL TRACES in top layer under the crystal and in the next layer under the traces connecting the crystal to MCU,
- if there are such traces - use a crystal with a metal can and ground its case - it may help a little on your prototype board,
- there is a solid ground plane under the crystal and its traces to the MCU,
- the capacitors are between the MCU and the crystal or at the crystal pins, not outside of the crystal with long connecting traces,
- the MCU pins close to the LSE pins are not used for any waveform output (including MCO) - better don't use them at all.
Fiddling with LSEDRV setting may help.
Also note that if your LSE circuit is not perfect and you use it for synchronizing the main clock (a very useful option in L4 for eliminating the HSE crystal), you will encounter UART and USB data errors (like I did).
2018-03-11 03:47 AM
Thank you for answer,
To answer your questions, here is screenshot of how the crystal is routed:
Its the Y2 crystal.
I would not say that your guidelines were followed. I paid a lot more attention to the HSE placement to be fair, as I thought at this frequency (32 kHz) there are not hard constraints when it comes to placement. This is a 2 layer board so the is no solid GND plane underneath the crystal. Do you really think that this could make the difference?
2018-03-11 06:29 AM
If
Mazur.Grzegorz
is correct, you have noise injection from the ground fills, from the switchers.I would remove the ground fill from the crystal circuit area totally and off C16, C17, try to move underside tracks away if possible.
Run a 15thou trace from C17,C16(Gnd), to pin 10 Vss, before it hits C25, then connecting to the remaining ground fill/track.
This will mostly block any switcher noise you have propagating along Vss,.along your ground fills.
2018-03-11 08:05 AM
Your layout is not perfect but not bad. I would try to move away the tracks crossing LSE tracks and slightly move the capacitors. I would suggest to try another oscillator, 'straw' thin can 'watch' type and ground its case. The black plastic one you use is the worst one for L4 (I did the same, so I know) . Try 6p8 capacitors and LSEDRV options. The LSE tracks should ideally go through the LCE capacitors to the oscillator.
2018-03-11 01:27 PM
I will try another oscillator in the next revision, thanks. About the caps in the way of routes- I find it hard to measure either this really makes sense at this frequencies. Also, its not good reflow oven soldering wise.