2016-05-06 01:49 PM
I have been trying to implement the Tickless Idle feature in FreeRTOS (which comes pre-implemented for STM32 processors).
In my main code I have turned off all IP except the pushbutton (EXTI0), which I want to use to wake the device. I call HAL_DBGMCU_DisableDBGSleepMode so the debugger will not interrupt sleeping. Then I suspend all tasks, this forces FreeRTOS's tickless idle to kick in.I have modified PreSleepProcessing (which is called immediately before the WFI call) with code to record how long I am sleeping, and PostSleepProcessing to do nothing but hit any programmed breakpoint.I hit the debug breakpoint in PreSleepProcessing (meaning it is prepared to go to sleep), and hit RUN, but the current does not drop. If I put a breakpoint in PostSleepProcessing it seems to hit immediately, but from the PreSleepProcessing breakpoint I know it is only sleeping for 209 ms.I have breakpoints in all interrupts (including the RTOS ones) so I know none of those are causing it to wake. While awake (between PostSleepProcessing and PreSleepProcessing) the SysTick does run.How do I know it's actually sleeping? I've been looking for a register that will indicate why it woke, the only one I can find isPWR_SR1
, but that's for events and FreeRTOS is using WFI.
Should I be posting in the FreeRTOS forum?Any help appreciated!-Matt #sleeping #freertos2016-05-10 12:57 PM
Answering my own question:
Turns out it was sleeping, but the minimum sleep time for an 80mhz clock is 209 ms.If you change the system clock to 4mhz you can get a sleep time of around 2 minutes.I'm now working on switching FreeRTOS from using systick to using LPTIM2.-Matt