AnsweredAssumed Answered

STM32L4 RTCCLK running slower than HSE frequency

Question asked by david.rea on Nov 30, 2017
Latest reply on Dec 1, 2017 by david.rea

Hi All-


I'm using SW4STM32 with STM32CubeMx for configuration of an STM32L431RB MCU. I noticed that WakeUp events timed by the RTC appeared slow, and it appears that the RTC is being clocked from LSI rather than LSE as-configured.


In CubeMx, I have configured the RTCCLK source as LSE, and verified that the generated code sets this correctly. In the debugger's register view, I've confirmed that LSEON=1 and LSERDY=1, and that RTCSEL=01. (These values seem to persist, even after a chip erase and power cycle. This seems odd.)


I have confirmed that both LSI and LSE oscillators are running, and that LSE is at the correct frequency, by configuring PA2 as LSCO and measuring the output frequencies with LSCOSEL=0 (31.6KHz) and LSCOSEL=1 (32.76KHz).


However, when I configure PC13 as RTC_OUT_CALIB and set this to 512Hz, the output waveform is only at 504Hz (measuring between rising edges, as the reference manual advises), indicating that RTCCLK is somewhere around 32.2KHz. Curiously, this is the average of the measured LSI and LSE clock speeds, though I'm not sure how that could happen.


Any ideas why the RTCCLK is behaving so strangely? My next step is to create a cleanroom project in CubeMx that configures only the RCC and RTC to verify none of my other settings are causing any issues. If the problem recurs with that IOC file, I will post it here.





(Edit 20171130-0656EDT: Changed incorrect mention of "HSE" to "LSE")