cancel
Showing results for 
Search instead for 
Did you mean: 

Massive Analog/Digital clock time delay in TouchGFX clock examples

Louie88
Associate III

Board STM32H7474I-DISCO, TouchGFX V4.24.2.

If you keep the analog/digital clock examples running (in the evaluatation board) for (say) 10 minutes then the clock on the LCD screen will be more than 15-25 seconds behind your watch. This is a massive delay: 15-25 seconds delay during 600 seconds is not nothing.

Probably reasons (my ideas)

  1. The SystemTick (VSYNC = 60Hz, 16.6667ms) is not accurate and it is not generated by an MCU Timer. Hard to believe it.
  2. All the examples update the hour/minute/second display (on the LCD) from the TouchGFX's handleTickEvent() interrupt service routine. The update runs once in every second. I can imagine that updating the LCD takes more than 16.6667ms so when the next system tick interrupt occurs the interrupt service is still in service. This way we can miss a couple of system ticks.

It would be nice to know which statement is right and how to resolve this issue.

I tried to open TouchGFX Academy Tutorial3 example in STMCubeMX and create a new, dedicated timer with 20ms interrupt for the LCD update, but STMCubeMX did not allow to edit any Timer: properties of any enabled timers were empty. I also do not know how I can consume a Timer Interrupt in TouchGFX.Thanks for your help.
Louis

PS: I also would like to mention that TouchGFX Academy/Tutorial 3 increments the minute counter in every second... not in every minute. This is not a big issue but it should be fixed in the tutorial.

 

 

13 REPLIES 13
Louie88
Associate III

Hi MM..1,

Almost all measurements (flow rate, totalizers, temperature, pressure, density,...) happens in interrupts in real world in the flow measurement industry, regardless the interrupt latency, which is almost always the same. Good interrupt priority policy helps a lot.

But I dropped the TIMER 1 interrupt-based clock example. Instead of TIMER 1 interrupt and counting the interrupt counts manually, I moved to STM32H7xxx's Real Time Clock (RTC) Subsystem. It can be initialized to run from 32 768Hz crystal which is assembled on the discovery board, and you do not have manually calculate the elapsed time even you get a leap-year (except 400 years) safe calendar. It works nice. No delay (or just minimal) but you can calibrate the clock of the RTC if the accuracy would be very important. And the main feature: I do not need any interrupt to read RTC. 

However one question raised about RTC: How can I stop and restart time measurement in RTC to write time and calendar registers?

Best regards,

Louis

 


@Louie88 wrote:

However one question raised about RTC: How can I stop and restart time measurement in RTC to write time and calendar registers?


That's a separate question - please start a new thread for that, and post a link here so that people can find it.

 

If your original TouchGFX question has been answered, please mark the solution - see:

https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256

Just sync it periodically with the RTC.

I call this in my screen view handleTickEvent():

    //clock
    //When every N tick execute C++ code
    //Execute C++ code
    tm const* timeinfoPtr = nullptr;
    static tm timeinfoOld = tm();// {0};
    
    #ifdef SIMULATOR
    	time_t rawtime;	
    
    	time(&rawtime);
    	timeinfoPtr = localtime(&rawtime);
    #else
    	//tm timeinfo={};
    	//timeinfoPtr = &timeinfo;
    
    	timeinfoPtr = getTimeStruct();
    #endif
    
    
    if (timeinfoPtr != nullptr)
    {
    	bool timeChanged = 	timeinfoPtr->tm_sec!= timeinfoOld.tm_sec||
    				timeinfoPtr->tm_min != timeinfoOld.tm_min ||
    				timeinfoPtr->tm_hour != timeinfoOld.tm_hour;
    
    
    	bool dateChanged = 	timeinfoPtr->tm_mday != timeinfoOld.tm_mday ||
    				timeinfoPtr->tm_mon != timeinfoOld.tm_mon ||
    				timeinfoPtr->tm_year != timeinfoOld.tm_year;
    
    	timeinfoOld = *timeinfoPtr;
    
    
    	
    	static bool timeInitialized = false;
    	
    	if (!timeInitialized)
    	{
    		timeInitialized = true;
    		// disable animation the first time to prevent arms from rotating a lot
    		analogClock1.initializeTime24Hour(timeinfoPtr->tm_hour, 
    							timeinfoPtr->tm_min, 
    							timeinfoPtr->tm_sec);
    	}
    	else
    	{
    		// analogClock need to be updated more than 1 time per second to allow animation
    		analogClock1.setTime24Hour(timeinfoPtr->tm_hour, 
    						timeinfoPtr->tm_min, 
    						timeinfoPtr->tm_sec);
    	}
    	
    	if (timeChanged)
    	{
    		digitalClock1.setTime24Hour(	timeinfoPtr->tm_hour, 
    							timeinfoPtr->tm_min, 
    							timeinfoPtr->tm_sec);
    	}
    	
    
    	if(dateChanged)
    	{
    		Unicode::snprintf(dateBuffer, DATE_SIZE, 
    						"%04d-%02d-%02d", 
    						timeinfoPtr->tm_year + TM_YEAR_BASE, 
    						timeinfoPtr->tm_mon - TM_MONTH_OFFSET, 
    						timeinfoPtr->tm_mday);
    			
    		date.resizeToCurrentText();
    		date.invalidate();
    	}
    }

 

 

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
Louie88
Associate III

Thanks, currently I am already doing what you suggested. (Except I check seconds only. If seconds is changed then I update the screen because any other part of RTC might be changed)

I just was wonder how to stop and restart the RTC? It is hard to belevie that such a complex and nice RTC chip does not have start/stop feature...

Best regards,

Louis

PS: My job was to demonstrate how "easy" to use the TouchGFX and can it be "mixed" with HAL based STM32CubeIDE app. I attached two screenshots of the working demo: the clock-calendar and the col-calendar setup screens.