2025-01-18 11:25 AM - last edited on 2025-01-20 02:59 AM by Andrew Neil
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)
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.
Solved! Go to Solution.
2025-01-24 12:40 AM
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
2025-01-24 01:49 AM - edited 2025-01-24 01:52 AM
@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
2025-01-24 05:03 AM - edited 2025-01-24 05:10 AM
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();
}
}
2025-01-25 03:59 AM
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.