cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX Analog Clock example runs slow on STM32H747I DISCO

Kenwang
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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.

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.

View solution in original post

11 REPLIES 11
Imen.D
ST Employee

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".
Thanks
Imen
Kenwang
Associate III

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
Evangelist III

@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?

SofLit
ST Employee

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.

Kenwang_1-1728312194609.png

 

I use this combination

You didn't mention TouchGFX.

Moved to the TouchGFX. forum.

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.

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.
Kenwang
Associate III

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?

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.