Implementation of a real low power timer for sleep/stop mode (idle thread)

Hello everyone, the STM32L053 has a low power timer which could be configured to be clocked by an internal 37kHz oscillator. For real low power applications it would be a good idea to use this timer during sleep/stop mode (for the idle tread). As far as I know the context switching is performed by the xtimer which needs a 1MHz clock in its configuration. Would it be possible to use such a slow clock for this purpose?

Best regards, Bernhard

Hi Bernhard, ​It should be possible with some modifications to use a slow clock as the xtimer source. There are a few developers working on improving the low power operation in RIOT. As you discovered, the periph/timer API currently needs to be updated to support non-MHz timer frequencies. I have a PR open which will be merged some time soon, hopefully. Some PRs of interest:

https://github.com/RIOT-OS/RIOT/pull/4040 - support for non-1MHz operation of periph/timer

https://github.com/RIOT-OS/RIOT/pull/3990 - xtimer 32768 Hz support, needs some love, there are problems with it right now. https://github.com/RIOT-OS/RIOT/pull/4065 - kinetis: periph/timer use LPTMR for TIMER_0, PIT for TIMER_1, TIMER_2

https://github.com/RIOT-OS/RIOT/pull/2605 - kinetis: Add LPM implementation - mostly an experiment remaining as a memo, needs to be reworked.

Once #4040 gets merged I hope to be able to resume working on xtimer 32768 Hz support. There are some other stuff that I need for work which are more urgent though.

Best regards, Joakim