cancel
Showing results for 
Search instead for 
Did you mean: 

Using HAL_RTC in TouchGFX

DPyke.1
Associate

Hello All,

forgive me if this as an obvious mistake but I'm completely new to TouchGFX. I'm using STM32 MPU, with Cube, FreeRTOS and TouchGFX

I have created a page in TouchGFX using the digital clock object, I have created a TickEvent to update the clock.

The Tick even is being called and if I put literal numbers into setTime24Hour, they are displayed correctly and can even be updated.

The RTC is used throughout the rest of the code and is working fine, the code complies without any warnings.

When I use the code (below) I only get 00:00:00 on the display

Any ideas?

All the best

Dren

*****************************

extern RTC_HandleTypeDef hrtc;

void PageView::handleTickEvent()

{

RTC_TimeTypeDef sTime;

if ( HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK )

Fatal_Error();

digitalClock1.setTime24Hour(sTime.Hours, sTime.Minutes, sTime.Seconds);

}

1 REPLY 1
Romain DIELEMAN
ST Employee

Hi,

Have you also made sure that sTime.Hours/Minutes/Seconds actually do return the expected values 😅 ? And in the right uint8_t format as well. That could be the issue if adding literal numbers works fine as you wrote.

Might be useless but you could also try to first cast the values in uint8_t variables and use them in the setTime24Hour() function instead of directly putting STime.Hours/... as inputs.

So something like this

uint8_t hour, minute, second;
 
void PageView::handleTickEvent()
{
...
hour = (uint8_t) sTime.Hours;
...
}

Out of curiosity could you specify which MPU you are using ? How are you making it work with TouchGFX ?

/Romain