STM32H747 RTC weird behaviour: the display appears with abnormal characters
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!
