Is it possible to run a tickless timer at a slower frequency than the system tick?

martisen wrote on Monday, November 28, 2016:

I only have a 16-bit timer available to run in low-power mode, and I would like to have a tick rate of 1 ms when running normally.

However, my application will from time to time have long idle periods where it will onlywake up a couple of times per day.

Is it possible to run the tickless timer at a slower rate than the system tick, and not go into deep-sleep unless the xExpectedIdleTime is more than one count on the tickless timer, which for instance could be running at 1Hz?

Are there any recommended ways for sleeping for extended periods of time?

rtel wrote on Monday, November 28, 2016:

Yes - if you are providing your own tickless idle implementation then
you can either:

  1. Have one clock that provides both the normal tick interrupts, and is
    re-programmed before sleep to generate the long sleep time, and after
    sleep to set the clock back to the tick frequency.


  1. Use two clocks, say clock A and clock B. Then set clock A to
    generate the tick interrupt, before sleep stop clock A and set clock B
    to wake you up after the long sleep, on wake restart clock A so it
    generates the regular ticks again.

heinbali01 wrote on Monday, November 28, 2016:

How long does it take before your 16-bit timer gets an overflow? What is its lowest frequency?

If you also want a tick-rate of 1000 Hz, I guess the longest sleep will only last 65.535 seconds :slight_smile:

Are other (32-bit) timers shut-down during this low power mode? Would it be really expensive to power them up?

Most of the current can often be saved by inspecting the I/O ports

martisen wrote on Tuesday, November 29, 2016:

Thanks for the replies. Using the deepest sleepmode, I only have this 16-bit timer available as well as an RTC running at 1 hz.

So then I guess I will just do a custom implementation of the tickless idle with the tickless clock running at a very slow speed.