Skip to main content
Mich1
Associate III
May 14, 2019 3:43 PM UTC
Solved

RTC IRQ STM32L476

With the STM32 in stop mode 2, is it possible to use the RTC as a additional low power timer?

I mean to trig IRQ periodically.

I tried the PWR_STANDBY_RTC STM32Cube_FW_L4_V1.14.0 example for STM32L476 and the code never stop at the breakpoint in function RTC_WKUP_IRQHandler().

What's more, to avoid debugger I tried to set the LED2 ON inside this function, but the LED never lights up.

This topic has been closed for replies.
Peter Mather
Peter MatherBest answer
Associate III
May 14, 2019 4:07 PM UTC

There was a bug in CubeMX for the L4 which I found - don't know if it has been fixed. I needed to use

         EXTI->IMR1|=(1<<20);

to get the RTC interrupt to work.

EXTI20 is the pseudo external interrupt used by the RTC

         HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, timetosleep, RTC_WAKEUPCLOCK_RTCCLK_DIV16);

        EXTI->IMR1|=(1<<20);

        HAL_NVIC_EnableIRQ((IRQn_Type)(RTC_WKUP_IRQn));

3 replies

Peter Mather
Peter MatherBest answer
Associate III
May 14, 2019 4:07 PM UTC

There was a bug in CubeMX for the L4 which I found - don't know if it has been fixed. I needed to use

         EXTI->IMR1|=(1<<20);

to get the RTC interrupt to work.

EXTI20 is the pseudo external interrupt used by the RTC

         HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, timetosleep, RTC_WAKEUPCLOCK_RTCCLK_DIV16);

        EXTI->IMR1|=(1<<20);

        HAL_NVIC_EnableIRQ((IRQn_Type)(RTC_WKUP_IRQn));

Mich1
Mich1Author
Associate III
May 14, 2019 4:32 PM UTC

(I used the latest STM32CubeMx)

Does ST have a LL_example?

Mich1
Mich1Author
Associate III
May 16, 2019 4:09 PM UTC

You are right Peter. Still not corrected inside CubeMX

Same problem: if Wake Up Clock is change inside CubeMX there is no change in any generated file .....:o