2022-02-07 04:59 AM
2022-02-09 05:05 AM
Of course it's possible. Cortex-M interrupt controller makes it possible to generate hardware interrupts in software, so the whole firmware may be implemented without the famous main loop, as a collection of event handlers with some "small" events generating "big" events, all of them being scheduled by NVIC with few different priority levels. I did several projects with few thousand lines of C source in this way. The binary code size reaches 120 KiB for the biggest one. No RTOS, no main loop and not a single delay(), just interrupt handlers.
You may even have a "blocking" lowest-priority interrupt handler if it's too hard to make it non-blocking for some nasty peripheral.
QuantumLeaps website may be a good starting point for more info on a similar approach (although without hardware scheduling)
https://www.state-machine.com/
2022-02-09 08:13 AM
And this is the way to go for energy saving.
Between interrupts handling the MCU can go to sleep (WFI instruction).