cancel
Showing results for 
Search instead for 
Did you mean: 

Strange behaviour when writing to RTC calibration register

jvog.sen
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
PatrickF
ST Employee

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'

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
PatrickF
ST Employee

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'

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
jvog.sen
Associate II

Thanks, now it makes sense!