cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476 had too much coffee

mattreed9
Associate III
Posted on May 06, 2016 at 22:49

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 is 

PWR_SR1

, but that's for events and FreeRTOS is using WFI.

Should I be posting in the FreeRTOS forum?

Any help appreciated!

-Matt

#sleeping #freertos
1 REPLY 1
mattreed9
Associate III
Posted on May 10, 2016 at 21:57

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