cancel
Showing results for 
Search instead for 
Did you mean: 

RTC wake up

Aa.41
Associate II

Implementation on: STM32L476RC

  • I can configure a periodic sleep cycle by waking up through the RTC through calling HAL_RTCEx_SetWakeUpTimer_IT.
  • I'm now trying to handle an EXT interrupt while in this periodic sleep cycle.

The goal is to handle the EXT interrupt (set a flag or store something to buffer) and go back into the same sleep cycle the RTC wake up timer was handling. Example, on a 2 minute cycle, if I trigger the EXT interrupt at the 1:50 mark, it should handle the interrupt and go straight back to sleep for the remaining 10 seconds.

Currently in my EXT interrupt I set the SLEEPONEXIT bit to go straight back to sleep after the interrupt is handled.

My problem is as follows:

  1. How can I get out of the sleepmode when SLEEPONEXIT is configured in the EXT interrupt through the RTC cycle.
  2. When the EXT interrupt is triggered the MCU does not wake up through the RTC timer NOR another EXT interrupt (which makes sense for the latter, since the SLEEPONEXIT bit is set every time it's handled).

My idea was to store a tick value before entering sleep and comparing it to the interrupt tick value. Then I could set a sleep value in HAL_RTCEx_SetWakeUpTimer_IT. But I realised that (1) tick is suspended... (2) interrupt tick is not the same. (But I'd have to turn SLEEPONEXIT off to achieve this).

Where should I be clearing the SLEEPONEXIT bit, because I definitely can't do that in the ISR.

0 REPLIES 0