Configure STM32H753ZIT6 Internal RTC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-18 12:16 AM
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.
Solved! Go to Solution.
- Labels:
-
STM32CubeIDE
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-19 5:36 AM
> RTC_FORMAT_BCD
Use RTC_FORMAT_BIN if you want binary format instead of BCD format.
Binary-coded decimal - Wikipedia
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-18 5:30 AM - edited ‎2025-06-18 5:30 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-18 9:05 PM
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-18 10:49 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-19 5:36 AM
> RTC_FORMAT_BCD
Use RTC_FORMAT_BIN if you want binary format instead of BCD format.
Binary-coded decimal - Wikipedia
