cancel
Showing results for 
Search instead for 
Did you mean: 

How to Calibrate RTC clocked with internal RC oscillator (LSI).?

shivashekar
Associate II

Hi, I am using STM32L452 Controller and I would like to use LSI for RTC which is not an accurate clock source.

I referenced the following manual and adjusted the pre-scaler as

2.8 RTC prescaler adjustment with LSI measurements - page 23

https://www.st.com/resource/en/application_note/dm00226326-using-the-hardware-realtime-clock-rtc-and-the-tamper-management-unit-tamp-with-stm32-microcontrollers-stmicroelectronics.pdf

But still, I see the lag in one device and lead in one device.

Is there a process to calibrate it?

9 REPLIES 9
TDK
Guru

No clock is perfect. What sort of accuracy are you expecting and what are you seeing instead?

Calibration is only going to be as good as the source you're using to calibrate. What are you using? HSE should be good, HSI not so much.

If you feel a post has answered your question, please click "Accept as Solution".
shivashekar
Associate II

I am using LSI Clock.

I am seeing around a 5-minute lead in one device and around 4 minute lag in one device.

> I am seeing around a 5-minute lead in one device and around 4 minute lag in one device.

In what time?

LSI is an inherently low precision and also low stability RC oscillator. The datasheet gives a 3% error at fixed voltage and temperature, that's 5 minutes error in roughly 3 hours.

JW

TDK
Guru

> I am using LSI Clock.

I understand you are using the LSI clock for the RTC. But how are you calibrating it? An oscilloscope? Another onboard timer?

If you feel a post has answered your question, please click "Accept as Solution".

 I am seeing around a 5-minute lead in one device and around 4 minute lag in one device. per day

shivashekar
Associate II

I am not calibrating it as of now. I am just adjusting the Prescaler value as explained in the above document in section 2.8

2.8 RTC prescaler adjustment with LSI measurements - page 23

I need ways to calibrate it?

As I've said, according to datasheet, you can expect worst case 5 minute deviation in roughly 3 hours.

The LSI oscillator is inherently unstable, you cannot expect more precision from it, whatever your adjustment/calibration process is.

JW

OK Thank you

Thought this meant you were calibrating it:

> I referenced the following manual and adjusted the pre-scaler

To calibrate, put out the RTC_CALIB signal on a line somewhere and use an oscilloscope to measure the frequency. Adjust the prescaler such that the frequency is corrected. This needs to be done on every chip.

You can also use an onboard timer if you're using an accurate clock source such as HSE.

What JW says is true, but you can calibrate out much of the inaccuracy if your temperature is stable.

If you feel a post has answered your question, please click "Accept as Solution".