Combine TIM1 output compare mode and up/down count mode to generate PWM
Hi:
I want TIM1 of STM32H503 to output PWM output.
What I need is:
* the counter works in up/down counting mode
* Set channel 1 to active level on match (TIMx_CNT match TIMx_CCR1) when the the counter is counting up
* Set channel 1 to ainctive on match (TIMx_CNT match TIMx_CCR1) when the the counter is counting down
But neither PWM mode nor Output Compare mode satisfy my requirement.
* PWM mode (OC3M[3:0] = 0110b or 0111b): channel 1 is active/inactive as long as TIMx_CNT<TIMx_CCR1 else inactive. It means the comparator is always working. Instead my need is set/clear the channel1 only when TIMx_CNT match TIMx_CCR1.
* Output Compare mode (OC3M[3:0] = 0001b or 0010b): Set channel 1 to active/inactive level on match. This mode seem more suitable for my case. But unfortunately it doesn't cover all my requirement: I want the Output Mode Controller take different action on counting up and counting down, as stated in the beginning of this post.
(Note that OC3M[3:0] = 0011b is Toggle mode. It's possible that the output is toggled twice when counting up, which is unacceptable for me.)
Could you please tell me how to implement the desired pattern in STM32H503 Advanced Timer1?
* the counter works in up/down counting mode
* Set channel 1 to active level on match (TIMx_CNT match TIMx_CCR1) when the the counter is counting up
* Set channel 1 to ainctive on match (TIMx_CNT match TIMx_CCR1) when the the counter is counting down
