Skip to main content
SAkhi.951
Associate III
March 18, 2021
Question

RTC wakeup with CubeMX generated code does not work.

  • March 18, 2021
  • 2 replies
  • 836 views

I have setup RTC wakeup functionality and generated code with CubeMX.

The code does not work straight away, because imr1's mr20 in EXTI IMR1 register was not unmasked. I suppose this is a bug and should be handle by STM. It took some time to figure that out and that is not what you expect from automatic code generator.

Note! This is just a bug report and notice for everyone who faced same issue.

/* RTC init function */
void MX_RTC_Init(void)
{
 
 /** Initialize RTC Only
 */
 hrtc.Instance = RTC;
 hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
 hrtc.Init.AsynchPrediv = 127;
 hrtc.Init.SynchPrediv = 255;
 hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
 hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
 hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
 hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
 if (HAL_RTC_Init(&hrtc) != HAL_OK)
 {
 Error_Handler();
 }
 
 if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 7, RTC_WAKEUPCLOCK_RTCCLK_DIV16) != HAL_OK)
 {
 Error_Handler();
 }
 
 /* Adding this line makes Wake up ISR works */
 __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT(); 
}

This topic has been closed for replies.

2 replies

Khouloud ZEMMELI
ST Employee
March 22, 2021

Hello @SAkhi.951​ 

Thanks for your feedback,

Which part number are you using please?

Khouloud

SAkhi.951
SAkhi.951Author
Associate III
March 23, 2021

Hello @Khouloud ZEMMELI​ ,

MCU - STM32L41RCIx. CubeMX FW package FW_L4 V1.13.0