HAL bug: HAL_TIM_PWM_Stop() function stops timer even when another channel is configured for input capture?
Hi,
I'm on a L011 device with the following configuration for timer 2:
Channel 1 is in input capture mode, rising edge. The timer itself is in auto-reset mode, on each rising edge on channel 1 the timer count is copied to the CCrx register and the timer itself is reset. This is to measure the duration between edges.
Now, depending on the measured pulse width, I want to output a defined pulse width with channel 2 of timer 2 (the same timer). There's also the case where no pulse has to be generated at all.
I couldn't get this working with output compare mode since I found no way to reset the OCxREF flag, so I configured the channel to PWM output mode. My idea was to output the pulse by simply starting or stopping the PWM channel by corresponding HAL functions HAL_TIM_PWM_Start() / HAL_TIM_PWM_Stop(). Now, it seems that the stop function disables the timer (clearing CEN flag) if no other output(!) is active, the enabled input compare on channel 1 is ignored. I'd say this is a bug in HAL, the timer shouldn't be stopped if a channel is active in any mode, not only output enabled.
Aside from bug or no bug, does anyone have a suggestion how I can realize the above mentioned pulse without stopping the timer?
Regards