2018-12-06 02:02 AM
Problem:
RTC Wakeup interrupt is not working on STM32L4 after calling the HAL_RTCEx_SetWakeUpTimer_IT.
Cause:
A preprocessor macro check rules out a call to the __HAL_RTC_WAKEUP_EXTI_ENABLE_IT for uC other than STM32L412xx / STM32L422xx in the file stm32l4xx_hal_rtc_ex.c
Fix:
Add a call to __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT just before __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT line 912:
#if defined(STM32L412xx) || defined(STM32L422xx)
/* In case of WUT autoclr, the IRQ handler should not be called */
if (WakeUpAutoClr != 0u)
{
/* RTC WakeUpTimer EXTI Configuration: Event configuration */
__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT();
}
else
{
/* RTC WakeUpTimer EXTI Configuration: Interrupt configuration */
__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT();
}
#else /* defined(STM32L412xx) || defined(STM32L422xx) */
__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT();
#endif /* defined(STM32L412xx) || defined(STM32L422xx) */
becomes:
#if defined(STM32L412xx) || defined(STM32L422xx)
/* In case of WUT autoclr, the IRQ handler should not be called */
if (WakeUpAutoClr != 0u)
{
/* RTC WakeUpTimer EXTI Configuration: Event configuration */
__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT();
}
else
{
/* RTC WakeUpTimer EXTI Configuration: Interrupt configuration */
__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT();
}
#else /* defined(STM32L412xx) || defined(STM32L422xx) */
__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT();
__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT();
#endif /* defined(STM32L412xx) || defined(STM32L422xx) */