2019-01-21 09:17 AM
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,
2019-01-21 09:57 AM
With 13% error, it's definitely more of a prescaler setting problem (SW) than clocks oscillator precision.
2019-01-21 10:38 AM
Should I use external oscilator(LSE) or I can correct it with calibration?
2019-01-21 12:31 PM
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....
2019-01-21 12:55 PM
For starters, make sure you have the right prescaler, the LSI clocks faster than the LSE, typically 15-16%