stm32/timer: Fix use of timer channel callback() method on L4 MCUs.
Since L4 HAL version 1.17.0, HAL_TIM_IC_Start_IT() checks whether specified channel of timer is busy or not, which is the case if this function is called more than once without first calling HAL_TIM_IC_Stop_IT(). The fix in this commit is to call the stop function before calling start. The PWM and OC modes have the same issue with the same fix. Fixes issue #8732.
This commit is contained in:
parent
da50827657
commit
989b8c728b
@ -1576,6 +1576,7 @@ STATIC mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback)
|
||||
switch (self->mode) {
|
||||
case CHANNEL_MODE_PWM_NORMAL:
|
||||
case CHANNEL_MODE_PWM_INVERTED:
|
||||
HAL_TIM_PWM_Stop_IT(&self->timer->tim, TIMER_CHANNEL(self));
|
||||
HAL_TIM_PWM_Start_IT(&self->timer->tim, TIMER_CHANNEL(self));
|
||||
break;
|
||||
case CHANNEL_MODE_OC_TIMING:
|
||||
@ -1584,9 +1585,11 @@ STATIC mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback)
|
||||
case CHANNEL_MODE_OC_TOGGLE:
|
||||
case CHANNEL_MODE_OC_FORCED_ACTIVE:
|
||||
case CHANNEL_MODE_OC_FORCED_INACTIVE:
|
||||
HAL_TIM_OC_Stop_IT(&self->timer->tim, TIMER_CHANNEL(self));
|
||||
HAL_TIM_OC_Start_IT(&self->timer->tim, TIMER_CHANNEL(self));
|
||||
break;
|
||||
case CHANNEL_MODE_IC:
|
||||
HAL_TIM_IC_Stop_IT(&self->timer->tim, TIMER_CHANNEL(self));
|
||||
HAL_TIM_IC_Start_IT(&self->timer->tim, TIMER_CHANNEL(self));
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user