IT based timer period


I would like to have timer interrupts every 10 minutes for temperature readings. Also, I would like to have opportunity to change this period in the code. How could such long period be implemented? Are there any examples? I am using STM32L011 MCU and STM32CubeIDE environment.

Generated Timer initialization function:

The maximum period I can enter is 65 536 ms (2^16) which is 65.536 seconds. If I enter for example 70 000 then timer interrupts every 5 seconds.
How could I set period to 10 minutes (600 000 ms)? MCU works at maximum 32 MHz.

Thank you.

It’s a 16-bit timer, which means the largest value you can have is 65535.

To get a timer for longer than the max, you need to use smaller timer increments, and have a master function to count the interrupts. You provide the timeout value to the master function.

I.e. I’d set up a timer for a convenient value, e.g. 10 seconds. The master function starts at zero, counts the number of interrupts until the target time is reached, fires off the task (take temperature) then resets its count. So for 10 minutes, the target interrupt count would be 60 (10 x 6 interrupts per minute). Easy to change too.

Can’t provide an example I’m afraid … not sure what the syntax would be for the interrupt callback.