2019-10-08 04:02 PM
Implementation on: STM32L476RC
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:
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.