I am working on an STM32L432. I am trying to implement low-power features. Specifically, I am using the Tickless-Idle mode to put the MCU to sleep when it enters the Idle task. I am using a periodic interrupt to wake it up periodically, and do a minimal processing (about 100 us worth of MCU cycles).
I would like to have the following behaviour:
- The MCU wakes up at periodic intervals (once every 125 ms).
- It does its 100us processing.
- It falls back to sleep immediately upon entering the Idle task (if there is no other task ready of course)
The behaviour that I see instead when configEXPECTED_IDLE_TIME_BEFORE_SLEEP is set to the default (and minimum) value of 2, is that after waking up, the MCU stays awake for a minimum of 1 tick period (1ms in my case: too long).
I tried to set configEXPECTED_IDLE_TIME_BEFORE_SLEEP to 1, and then I have the behaviour that I need. But setting configEXPECTED_IDLE_TIME_BEFORE_SLEEP to 1 creates a compile error that says: “#error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2”.
I can easily disable that error message, but before I do that, I would like to understand better what the risks are.
Note that in that project, a tight accounting of ticks is not requried. The tick counter can freeze once in a while, or skip a beat, without any noticeable effect.