2024-10-06 11:15 PM - last edited on 2024-10-09 06:20 AM by Andrew Neil
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?
Solved! Go to Solution.
2024-10-07 08:09 AM - edited 2024-10-09 07:22 AM
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.
2024-10-07 12:53 AM - edited 2024-10-07 12:58 AM
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.
2024-10-07 01:08 AM
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.
2024-10-07 01:28 AM
@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?
2024-10-07 01:37 AM
Hello @Kenwang ,
Could you please tell which "Clock Example" you are referring to?
2024-10-07 07:43 AM
I use this combination
2024-10-07 08:01 AM
You didn't mention TouchGFX.
Moved to the TouchGFX. forum.
2024-10-07 08:09 AM - edited 2024-10-09 07:22 AM
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.
2024-10-07 07:28 PM
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?
2024-10-08 12:02 AM - edited 2024-10-08 03:07 AM
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.