Yeah... I can see one spending months chasing around really weird and very hard to track down problems with peripheral behaviour.
I guess one would start by making the WFI conditional on some stuff
not being active e.g. you will probably already have a mutex on r/w to an SPI FLASH, and you will want to
not do WFI if that mutex is locked. In fact you will probably have a mutex on an SPI channel as a whole.
Maybe use DMA for serial and SPI? That avoids the crap 1-char buffering provided by ST. But that means
not shutting down peripherals.
And lots and lots of other stuff like that.
Curiously I have found almost no examples of this online.
Looks like only the Sleep mode could be used
Next, the DS suggests Run mode to Sleep mode drops Icc from 102mA to 77mA, only! With all peripherals disabled it drops from 54mA to 27mA. This is at 168MHz, 32F417.
Then there are all kinds of other tables showing Icc under lots of conditions, but if one sticks to a mode where the Systick will wake you up, and the HSO (say 25MHz) remained running, I don't see much point in doing this unless your power situation is already critical, in return for the considerable increase in development time and testing required.
Maybe other CPUs are much better - the "L" chips?
The worst may be compatibility testing e.g. USB. Currently I am implementing the primitive USB client mode which is reportedly used by FLASH sticks i.e. Host activity triggers an ISR which does everything including a 15ms FLASH write, and
hangs up the target for the 15ms.
With a 1ms RTOS tick it all still runs but 15x slower; what a surprise This is primitive but is 100% compatible across Host USB implementations. Other approaches, sending back a BUSY packet immediately upon starting the FLASH write and hoping the Host will retry, etc, have been tried but are complex, practically nobody knows how to do them (apart from the one guy on ST forum who never actually tells you
how), the ST-provided code hooks for BUSY/NAK do not actually work, and the final code cannot possibly be tested across the Host spectrum.
ETH, I don't even want to think about. You probably want to just shut it down totally (for a
good Icc gain) until somebody starts the HTTP server
But then you won't know they started it, will you?
And you still need to have a PSU big enough to run that mode...
What am I missing?