STM32H562 RTC problems
Hello everyone. How are you?
I created a test program based on https://community.st.com/t5/stm32-mcus/how-to-calibrate-the-stm32-s-real-time-clock-rtc/ta-p/744958 I calibrated and compared the signal (512Hz @ PB2) with an oscilloscope, resulting in an error of less than 20 ppm. The RTC worked for 24 hours, and the seconds were the same as my base source (Windows). To me, this indicates that the hardware, crystal, and capacitors are OK.
After that, when I entered my application code, the RTC always showed a delay (error > 5000 ppm). My code never use HAL_RTC_SetTime or HAL_RTC_SetDate. Reading from the RTC->CALR register is the same as the calibration value.
Regardless of whether the calibration is at -488 or +488 (maximum value), the RTC always lags. I have the feeling that the processor gets busy doing something, and ends up losing some RTC pulse.
Unfortunately, I can't post the complete code here, but I can provide some other information:
- 1 ISR timer every 1 ms
- X-Cube FreeRTOS - 6 tasks
- 8 UART ISRs for RX and TX via DMA + 1 I2C channel
- iCache enabled / No USB device
Considering that the RTC runs independently, by hardware, and that ISR, DMA, RTOS crash, etc. shouldn't affect it, does anyone have any idea what else I should analyze?
Thanks in advance,
leandro
