Skip to main content
Associate II
June 18, 2025
Solved

Configure STM32H753ZIT6 Internal RTC

  • June 18, 2025
  • 2 replies
  • 541 views

Hi, I'm trying to configure the internal RTC on the STM32H753ZIT6 development board, but the RTC isn't functioning correctly—the time doesn't increment. The code was previously working with Ethernet, and I attempted to configure the internal RTC to work simultaneously. However, after making these changes, neither the RTC nor the Ethernet functions are working. I’ve attached the code and output file for reference.

Best answer by TDK

> RTC_FORMAT_BCD

Use RTC_FORMAT_BIN if you want binary format instead of BCD format.

Binary-coded decimal - Wikipedia

2 replies

TDK
Super User
June 18, 2025

Here's your main loop code which prints the date and time:

 /* Infinite loop */
 for(;;)
 {
	 osDelay(100);
	 /* !! PBUF_RAM is critical for correct operation !! */
	 udp_buffer = pbuf_alloc(PBUF_TRANSPORT, strlen(message), PBUF_RAM);
	 if (udp_buffer != NULL) {
		memcpy(udp_buffer->payload, message, strlen(message));
		udp_send(my_udp, udp_buffer);
		printf("%d:%d:%d %d:%d:%d\r\n",gDate.Year,gDate.Month,gDate.Date,gTime.Hours,gTime.Minutes,gTime.Seconds);
		pbuf_free(udp_buffer);
	 }
 }

 

The code only reads date/time once, prior to entering the loop. You need to read it each time before you print it if you want it to be updated.

"If you feel a post has answered your question, please click ""Accept as Solution""."
EmaticAuthor
Associate II
June 19, 2025

Hi @TDK, I’ve modified my code based on your suggestion. The time is now incrementing, but I’ve noticed that the minutes increase when the seconds reach 89. Ideally, the minutes should increment when the seconds reach 59. I’ve attached the modified code and the output file for your reference.

 

Modified Code:

---------------------

 

/* Infinite loop */

for(;;)

{

HAL_RTC_GetTime(&hrtc, &gTime, RTC_FORMAT_BCD);

HAL_RTC_GetDate(&hrtc, &gDate, RTC_FORMAT_BCD);

osDelay(100);

/* !! PBUF_RAM is critical for correct operation !! */

udp_buffer = pbuf_alloc(PBUF_TRANSPORT, strlen(message), PBUF_RAM);

if (udp_buffer != NULL) {

memcpy(udp_buffer->payload, message, strlen(message));

udp_send(my_udp, udp_buffer);

printf("%d:%d:%d %d:%d:%d\r\n",gDate.Year,gDate.Month,gDate.Date,gTime.Hours,gTime.Minutes,gTime.Seconds);

pbuf_free(udp_buffer);

}

}

 

RTC Output2.PNG

TDK
TDKBest answer
Super User
June 19, 2025

> RTC_FORMAT_BCD

Use RTC_FORMAT_BIN if you want binary format instead of BCD format.

Binary-coded decimal - Wikipedia

"If you feel a post has answered your question, please click ""Accept as Solution""."
waclawek.jan
Super User
June 19, 2025

You read time/date as BCD, i.e. 9 seconds is 0x09, 10 seconds is 0x10 = 17 - note the 9-to-17 transition in your printout; similarly 58 seconds is 0x58=88 (osDelay() plus the printing code results in slightly more than 1sec of delay between RTC readouts).

You want to use the binary readout facilities of Cube/HAL.

JW