AnsweredAssumed Answered

Can I make TIM1 or TIM8 generate 4 timer interrupts?

Question asked by arnold_w on Oct 6, 2016
Latest reply on Oct 7, 2016 by FTITI.Walid
I am working with the Discovery Development Board (STM32F407) and I would like to write a function that uses one physical timer and allows me to generate arbitrary interrupts at different instances, for example

addTimerInt (100, myCallback1); // Call callback1 100 ms from now
delayMs(5);                                  // Dummy delay to explain what my function should be capable of
addTimerInt (50, myCallback2);   // Call callback2 50 ms from now
delayMs(10);                                // Dummy delay to explain what my function should be capable of
addTimerInt (100, myCallback3); // Call callback3 100 ms from now
delayMs(100);                              // Dummy delay to explain what my function should be capable of
addTimerInt (1, myCallback4);     // Call callback4 1 ms from now


The advanced (TIM1 & TIM8) timers have 4 channels, can these be used in this case somehow? The function will have nothing to do with actual pins on the microcontroller and we don't have spare pins to hook up for looping back clocks to particular pins.

Or is it possible to have a timer run from 0 to 0xFFFF (and then wrap around to 0) and have the timer generate an interrupt at a specific CNT-value without the CNT-value being reset back to 0? Basically, if I schedule an interrupt at CNT = 0x100 then the next CNT-value after the interrupt should be 0x101, not 0. Can I do something clever by setting APRE = 1?

Outcomes