Skip to main content
Visitor II
August 31, 2021
Question

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

  • August 31, 2021
  • 6 replies
  • 4047 views

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?

    This topic has been closed for replies.

    6 replies

    Super User
    August 31, 2021

    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.

    Visitor II
    August 31, 2021

    I am using LSI Clock.

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

    Super User
    August 31, 2021

    > 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

    Visitor II
    August 31, 2021

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

    Super User
    August 31, 2021

    > 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?

    Visitor II
    August 31, 2021

    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?

    Super User
    August 31, 2021

    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.

    Super User
    August 31, 2021

    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

    Visitor II
    August 31, 2021

    OK Thank you