cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 RTC Accuracy

dtarrago
Associate II
Posted on March 27, 2017 at 10:31

Good morning,

I'm developing an application based on STM32L475 device.

I use the RTC (LSE based) as a periodic wakeup source, as application is periodically going to Stop2 mode: I have followed the '...STM32Cube_FW_L4_V1.7.0\Projects\STM32L476RG-Nucleo\Examples\PWR\PWR_STOP2_RTC' example and I have setup the RTC to wakeup every 31.25ms =>

....

  if (HAL_RTCEx_SetWakeUpTimer_IT(&H_RTC, 0x0200, RTC_WAKEUPCLOCK_RTCCLK_DIV2) != HAL_OK) //WakeUp Time every 31.25ms. RTC resolution set to 61.035us

{

Error_Handler();

}

...

Furthermore, I use the recommended 'NX3215SA 6pF' LSE oscillator.

The application is waking up every 31.25ms and it is working fine. In the code, there is also a variable that is initialized at 1920 and decremented every 31.25ms (every time RTC interruption is given), so it reaches 0 every minute: at this point, the application switches on a LED, and variable is initialized again => What I have observed is that the instant in which this happens is moving: about 5 seconds in 1 hour. So, is it necessary to calibrate the RTC? Is there any other reason that can cause this RTC to have this misallignment?

Best regards.

#rtc #stop2 #stm32l4
1 REPLY 1
dtarrago
Associate II
Posted on March 27, 2017 at 14:50

Already solved --> in order to have 31.25ms wakeup-time, time parameter must be 0x01FF instead of 0x0200.