Skip to main content
Associate III
October 7, 2024
Solved

TouchGFX Analog Clock example runs slow on STM32H747I DISCO

  • October 7, 2024
  • 6 replies
  • 3124 views

I executed "Clock Example" on stm32H747I DISCO. I found that after two minutes of execution, the analog clock was about 15 seconds slower. After 53 minutes of execution, it was about 5 minutes slower, and it will become slower and slower. I did not add any The program code is in the M7 core. The way I compare is to enable RTC and uart in the M4 core, use the HAL_RTC_GetTime() function to read out the rtc time every second, and print it out through the uart. My question is, If the analog clock really slows down, is there any way I can correct it without users noticing?

Best answer by mƎALLEm

Ok I see,

Simply because the example doesn't use RTC for the clock counting but it's based on the event tick time base of the TouchGFX. Each tick fires each 1/60 second.

 

void MainView::handleTickEvent()
{
 tickCounter++;

 if (tickCounter % 60 == 0)
 {
 if (++digitalSeconds >= 60)
 {
 digitalSeconds = 0;
 if (++digitalMinutes >= 60)
 {
 digitalMinutes = 0;
 if (++digitalHours >= 24)
 {
 digitalHours = 0;
 }
 }
 }

 if (++analogSeconds >= 60)
 {
 analogSeconds = 0;
 if (++analogMinutes >= 60)
 {
 analogMinutes = 0;
 if (++analogHours >= 24)
 {
 analogHours = 0;
 }
 }
 }

 // Update the clocks
 digitalClock.setTime24Hour(digitalHours, digitalMinutes, digitalSeconds);
 analogClock.setTime24Hour(analogHours, analogMinutes, analogSeconds);
 }
}

 

The purpose of the example template provided in TouchGFX designer is to focus on the animation in the GUI and how to implement it in TouchGFX and not to provide a Clock function.  So if you are looking to implement a real clock you need to use RTC and link its counting to the GUI. 

Hope that answers your question.

6 replies

Technical Moderator
October 7, 2024

Hello @Kenwang ,

Did you test with smooth calibration ?

Check the calibration Settings (RTC_CALR register setting).

Are you using an external crystal or with an external clock?

Please check the section "Verifying the RTC calibration" in RM0399.

"When your question is answered, please close this topic by clicking ""Accept as Solution"".ThanksImen"
KenwangAuthor
Associate III
October 7, 2024

I have compared the time on the computer, it is really slow, and if you stare at the screen, its second hand will sometimes stop for a long time.

Andrew Neil
Super User
October 7, 2024

@Kenwang wrote:

 it will become slower and slower.


Is it actually slowing down, or is it just running at a constant slow rate?

Have you checked the accuracy of the timebase source for this analogue clock?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
mƎALLEm
Technical Moderator
October 7, 2024

Hello @Kenwang ,

Could you please tell which "Clock Example"  you are referring to?

 

"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."
KenwangAuthor
Associate III
October 7, 2024

Kenwang_1-1728312194609.png

 

I use this combination

Andrew Neil
Super User
October 7, 2024

You didn't mention TouchGFX.

Moved to the TouchGFX. forum.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
KenwangAuthor
Associate III
October 8, 2024

I understand that it is because handleTickEvent is not very accurate, because this project uses freertos. Would it help if the priority of the videoTask task is set higher?

mƎALLEm
Technical Moderator
October 8, 2024

Maybe.. but even if the case, it could not be an accurate time clock source as RTC due to interrupts latency of execution, the execution itself of the task etc... So please use RTC instead.

"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."
Andrew Neil
Super User
January 20, 2025

Another one caught out by this:

https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/massive-analog-digital-clock-time-delay-in-touchgfx-clock/m-p/763579

@mƎALLEm @Imen.D @Mohammad MORADI ESFAHANIASL - would be good to ensure the documentation makes this clear!

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.