2025-04-21 6:15 AM
Hello,
I've discovered the following anomalous behavior when attempting to use the STM32F103 Nucleo board:
Pushbutton interrupt code will not execute if the RTC is active with NVIC EXTI13. I've noticed that the RTC tamper PIN is also assigned to PC13 but I've made sure that the output selection is disabled and RTC tamper is deselected inside CudeIDE/CubeMX window. If the RTC is activated with NVIC EXTI13, I measure zero volts across the appropriate pushbutton (pushbutton not depressed) pins (without the RTC activated the voltage across the same pins is 3.3V). My initial GUESS is PC13 is being reconfigured as an open drain output and being pulled low when the MX_RTC_Init is executed? I've tried to use the debugger to read the appropriate register and bit but I keep receiving a read error. If I comment out the MX_RTC_Init function and download the program I receive correct functionality from the pushbutton but only after a computer reboot.
I've also tried to execute the MX_GPIO_Init both before and after MX_RTC_Init but the problem still persists. Is there something inside the generated CubeMX/CubeIDE RTC code that forces PC13 into a different mode?
I don't have the appropriate tools to attempt my proposed hardware fix which would be to reroute the pushbutton to PB13 and change the configuration and code to match.
2025-04-21 6:19 AM - edited 2025-04-21 6:21 AM
Hello @vicsimdelay1
First let me thank you for posting.
I'm currently checking this , I will get back to you asap.
I would appreciate it if you could share your IOC.
THX
Ghofrane
2025-04-21 6:39 AM
2025-04-21 8:16 AM
Hello @vicsimdelay1
By checking the generated code using CubeMX , The function MX_RTC_Init does not contain any code that explicitly configures GPIO pins, including PC13. there is no indication that MX_RTC_Init directly affects PC13.
static void MX_RTC_Init(void)
{
/* USER CODE BEGIN RTC_Init 0 */
/* USER CODE END RTC_Init 0 */
RTC_TimeTypeDef sTime = {0};
RTC_DateTypeDef DateToUpdate = {0};
/* USER CODE BEGIN RTC_Init 1 */
/* USER CODE END RTC_Init 1 */
/** Initialize RTC Only
*/
hrtc.Instance = RTC;
hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
hrtc.Init.OutPut = RTC_OUTPUTSOURCE_ALARM;
if (HAL_RTC_Init(&hrtc) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN Check_RTC_BKUP */
/* USER CODE END Check_RTC_BKUP */
/** Initialize RTC and set the Time and Date
*/
sTime.Hours = 0x0;
sTime.Minutes = 0x0;
sTime.Seconds = 0x0;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
DateToUpdate.Month = RTC_MONTH_JANUARY;
DateToUpdate.Date = 0x1;
DateToUpdate.Year = 0x0;
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BCD) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN RTC_Init 2 */
/* USER CODE END RTC_Init 2 */
}
2025-04-21 8:30 AM
What about inside HAL_RTC_Init() on line 20?