pwm and time based interrupt
Hi all,
I am working on STM32F746G - DISCO. I have started working with STM32 just recently, sorry if this is a silly question.
I need to use 1 timer to get PWM output from one of its channels, and generate time based interrupts from another channel. I have configured channel 1 for the PWM. The timer clock is 100MHz. ARR is set to (50000 - 1) and PSC is set to (2 - 1). Therefore I have achieved 1KHz PWM output of which duty cycle (CCR1) varies as needed. This part is perfectly fine.
I have tried to configure channel 2 to generate time-based interrupts, which should vary in the range, let's say 1ms or less (for now). The output of the prescaler in this case is 50MHz, which means an interrupt should be generated every 50K clock ticks for 1ms delay. The timer is in the upcounting mode, the CNT counts up to ARR and then restarts from 0. So the max value CCR2 can get is ARR
(50000 - 1)
, and the maximum possible duration between two timer interrupts is 1ms. Am I right?If I set CCR2 to something less than ARR, I expect the interrupt period is expected to be less. Interestingly, regardless of CCR2, the interrupt frequency is 500Hz, half of PWM frequency . When I change the PWM frequency, interrupt frequency changes accordingly, always half of it.
-What could be wrong with this?
-Is a delay of more than 1ms possible with this configuration if the need be?
-What is the usual approach?Should I use another timer for the time based interrupts?
I will be glad if you can please give me some hints.
Regards,
Den
#pwm #time-base-interrupt #different-timer-channels #stm32f746-discovery