2026-01-09 9:03 AM - last edited on 2026-01-09 9:29 AM by mƎALLEm
Hi everyone!
I'm using an Arduino Portenta H7 (STM32H747) board mounted on a custom carrier board.
I'm using STM32CubeIDE as a development environment, with HAL libraries for peripheral initialization.
I'm only using the Portenta's M7 core.
Portenta interfaces via GPIO to a parallel bus that drives both a display and other peripherals. I'm also using the RTC module for the system clock only, initialized at startup via HAL.
Everything works fine until I try to set the RTC datetime using this function:
void tm_wr(struct tm *_tm) {
RTC_DateTypeDef sDate;
RTC_TimeTypeDef sTime;
if (_tm->tm_wday == 0) {
sDate.WeekDay = 7;
} else {
sDate.WeekDay = _tm->tm_wday;
}
sDate.Month = (uint8_t)_tm->tm_mon + 1;
sDate.Date = (uint8_t)_tm->tm_mday;
sDate.Year = (uint16_t)(_tm->tm_year-100);
HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN);
sTime.Hours = (uint8_t)_tm->tm_hour;
sTime.Minutes = (uint8_t)_tm->tm_min;
sTime.Seconds = (uint8_t)_tm->tm_sec;
HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN);
}
After this setting, any string on the display appears with abnormal characters. This happens even when I reboot the MCU or remove power from the system while leaving the VBAT power supply on. If I also remove the VBAT, everything starts working again.
The RTC peripheral clock is an external bypass clock at 32768Hz on pin PC14 (OSC IN), while PC15 (OSC OUT) is used on the bus.
What could be causing this behavior?
Thanks everyone, any suggestion is really appreciated!
2026-01-09 9:31 AM
Hello @davidedigesualdo and welcome to the ST community,
What do you mean by display here: "After this setting, any string on the display appears with abnormal characters. " ?
IDE Live expression? LCD display?
2026-01-09 9:54 AM
Hello @mƎALLEm ,
thank you for your reply!
The display has a Hitachi HD44780 controller. After the startup, the strings the MCU sends to the display are correctly displayed. After date&time setting if the MCU sends a string with 5 ASCII characters (latin alphabet), the display displays 5 characters but they are not the correct ones ("HELLO" becomes something like "δπДДψ").
2026-01-09 12:27 PM
Which pins are connected to the LCD?
JW
2026-01-09 3:51 PM
The RTC can work independently of any communication protocol. Changing the time and date shouldn't affect anything.
sTime has other fields which you do not initialize and are left at random values. That should be fixed, but I don't think that will cause issues.
You haven't given us much else to work with. Perhaps a pin is misconfigured, perhaps LSE isn't set up as bypass, perhaps some other cross talk is happening which gives a spurious edge.