AnsweredAssumed Answered

output compare with 32 bit timer

Question asked by Lukasz Przenioslo on Mar 14, 2016
Latest reply on Mar 14, 2016 by Lukasz Przenioslo
Hello there,
I have a question regarding output compare mode with 32 bit timers in STM32F4 mcu.
I have only one 32 bit timer that is free to use. I need to generate interrupts for 2 events. Those events should occur periodically with a set frequency. The frequency for event 1 is not corresponding to frequency of event 2 and vice versa.
I need to dynamically change the frequency of the events from 1 Hz to 5 kHz. Normally I would use two 32 bit timers for that, but I only have one left. I cant use a 16 bit timer, because while the frequency lowers, I would have to change the prescaller. I want to keep the prescaller constant and only change period. This way I can use a simple equastion that will give me period for an applied frequency:

ARR = (sysClk / ((PSC(i) + 1) * desiredFreq)) - 1;

So my question is, can I maybe use 2 channels of a 32 bit timer and use OC interrupts with no outputs? Or does this work like with pwm, that I can only set "width" but overall frequency wont change?

For example, can I set TIM5 frequency to 1 Hz and manipulate CCR1 and CCR2 to get interrupts with frequencies 1 kHz and 3 kHz independently?

I would appreciate all help!