Skip to main content
Visitor II
July 7, 2022
Solved

Strange behaviour when writing to RTC calibration register

  • July 7, 2022
  • 2 replies
  • 1339 views

Hi everyone,

I am trying to trim the internal RTC of an STM32MP157 to run slightly faster. According to the reference manual, you need to set bits CALP and CALM[8:0] in RTC_CALR to do so.

Here is what I did (using devmem2:(

# Enable write access to RTC_CALR
./devmem2 0x5C004024 h 0xCA
./devmem2 0x5C004024 h 0x53
# Write calibration factor (CALP=1, CALM=327) to RTC_CALR
./devmem2 0x5C004028 h 0x8147

Reading back the contents of register RTC_CALR returns 0x0147 instead of 0x8147, which corresponds to CALP=0.

Measuring the RTC deviation confirms that CALP does not get set to 1.

I am aware that using hwclock with adjtime can easily work around this issue. Yet not knowing what is going wrong here keeps bugging me...

    This topic has been closed for replies.
    Best answer by PatrickF

    Hi,

    this behavior is explained because our SW does not use default values and sets PREDIV_A = 0 and PREDIV_S = 32767 (to allow better accuracy on Linux time restore on low power modes exit as subsecond granularity is linked to PREDIV_S).

    See relevant RTC section to calibrate in that case:

    0693W00000QKd91QAD.pngRegards,

    In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

    2 replies

    PatrickFAnswer
    Technical Moderator
    July 7, 2022

    Hi,

    this behavior is explained because our SW does not use default values and sets PREDIV_A = 0 and PREDIV_S = 32767 (to allow better accuracy on Linux time restore on low power modes exit as subsecond granularity is linked to PREDIV_S).

    See relevant RTC section to calibrate in that case:

    0693W00000QKd91QAD.pngRegards,

    In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

    jvog.senAuthor
    Visitor II
    July 7, 2022

    Thanks, now it makes sense!