RTC with FreeRTOS and TouchGFX
Hello everybody!
Have asked this as a comment in another thread (https://community.st.com/s/question/0D50X0000BvkqIZSQY/inexplicably-slow-rtc?t=1622663635692), but decided to make a separate question in this group.
So far I was able to run STM32H743 (rev V) with FreeRTOS, LWIP and TouchGFX. Now I was trying to get TouchGFX show RTC clock and I stuck. RTC is working precisely (both with FreeRTOS [in a separate task] and without FreeRTOS [in a main while loop] ) until TouchGFX is started. Tried different task priorities - without success.
MCU is configured for LSE (BDCR->LSEON=1, BDCR->LSERDY=1, BDCR->RTCSRC=0x01 (LSE), BDCR->RTCEN=1 [BDCR=0x8103])
LSE itself is exactly 32.768kHz (oscilloscope measured)
But in my case setting LSE Drive to RCC_LSEDRIVE_MEDIUMHIGH (as well as any other value) does not help.
Reading RTC time from separate task at 1000ms intervals (osDelay(1000) ) log shows double values about every 5 seconds:
03.06.21 00:07:20
03.06.21 00:07:21
03.06.21 00:07:22
03.06.21 00:07:23
03.06.21 00:07:23 *
03.06.21 00:07:24
03.06.21 00:07:25
03.06.21 00:07:26
03.06.21 00:07:27
03.06.21 00:07:28
03.06.21 00:07:28 *
03.06.21 00:07:29
03.06.21 00:07:30
03.06.21 00:07:31
03.06.21 00:07:31 *
03.06.21 00:07:32
03.06.21 00:07:33
03.06.21 00:07:34
Same code with commented out TouchGFX task gives precise RTC clock at every second.
I can't understand how CPU, even being busy within interrupts, can slow down RTC (in a separate domain with it's own clock)?
Any ideas why this happens and how fix it?
Thank you!
P.S. I have checked dividers while RTC is running slow: PREDIV_A=127 and PREDIV_S=32767. These are default values for 32,768kHz quartz and theoretically should give 1s CK_PRE frequency.
