cancel
Showing results for 
Search instead for 
Did you mean: 

RTC of stm32l031k6 counting more

sahma.18
Associate II

I want to use RTC of stm32l031k6. But once I tested it I noticed that it counts 8 seconds more in a minute. I need a precise rtc. Do you have any advise what should I do.

Thanks,

4 REPLIES 4
S.Ma
Principal

With 13% error, it's definitely more of a prescaler setting problem (SW) than clocks oscillator precision.

sahma.18
Associate II

Should I use external oscilator(LSE) or I can correct it with calibration?

S.Ma
Principal

Just reading the datasheet:

Two ultra-low-power clock sources that can be used to drive the real-time clock: – 32.768 kHz low-speed external crystal (LSE) – 37 kHz low-speed internal RC (LSI), also used to drive the independent watchdog. The LSI clock can be measured using the high-speed internal RC oscillator for greater precision. • RTC clock sources The LSI, LSE or HSE sources can be chosen to clock the RTC, whatever the system clock. • Startup 

==> I do beleive an LSE of 32768 Hz is required to get precise clocks for RTC.

Even if you correct it with calibration, the specs talk about temperature drift worst case:

Symbol Parameter Min Typ Max Unit fLSI(1) 1. Guaranteed by test in production. LSI frequency 26 38 56 kHz DLSI(2) 2. This is a deviation for an individual part, once the initial frequency has been measured. LSI oscillator frequency drift 0°C ≤ TA ≤ 85°C –10 - 4 %

==> Drift is quite significant....

For starters, make sure you have the right prescaler, the LSI clocks faster than the LSE, typically 15-16%

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..