Skip to main content
Lukasz Przenioslo
Associate III
March 5, 2018
Question

STM32L4 low RTC precision

  • March 5, 2018
  • 71 replies
  • 22261 views
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.
This topic has been closed for replies.

71 replies

Danilotto Runi
Associate
March 14, 2018
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?

henry.dick
Associate II
March 14, 2018
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
March 16, 2018
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).

waclawek.jan
Super User
March 16, 2018
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

henry.dick
Associate II
March 16, 2018
Posted on March 16, 2018 at 17:07

let's not focus on those major contributors to timing errors.

instead, let's focus on those minor contributors, especially those difficult ones first. we will sure get to solve the 6000ppm problem, 1ppm at a time.

Albert
Visitor II
March 19, 2018
Posted on March 19, 2018 at 11:33

@ S/T specialists: what is the initial accuracy for the STM32 main clock ? If it is good enough, you can make a frequency meter with another STM32 by counting fclock during 32kHz period. The accuracy is made by S/T and the resolution is 1/fclock. If initial accuracy is poor, TCO's are not expensive.

If your hardware is correct, the 32kHz output will be strong enough to drive the counter input. If not, you can add a quick and dirty capacitance coupled emitter follower. Google for frequency meter input amplifier.

I think there's an application note on the S/T website with a trick to make a reciprocal counter with STM32 timer using it's hardware.

Make your own tools !

Theo

henry.dick
Associate II
March 19, 2018
Posted on March 19, 2018 at 12:16

The internal RC clock is often 1 percent - higher for mcus capable of crytal-less USB. 

But using a crystal here is more than enough. Those are often specs to 20ppm and in reality within 10pppm. One can easily write a piece of code to use the main crystal to measure the 32k crystal, all on the same chip.

Albert
Visitor II
March 19, 2018
Posted on March 19, 2018 at 13:27

See AN4013, chapter 2.4 for reciprocal frequency counter + Nucleo + Display shield = Nice frequency counter.

Theo.