AnsweredAssumed Answered

Timer output compare

Question asked by Montagner.Robert.001 on Mar 21, 2017
Latest reply on Mar 22, 2017 by waclawek.jan

Hi all. 

I'm working on a STM32L151, with EWARM toolchain. 

I'm using TIM4, with HAL libraries. TIM4 has 4 channels. I set

- CH1, input compare;

- CH2, CH3, CH4 output compare (no output);

I want to use input compare event as "trigger" for the other channels. 

In my implementation of: 


I set up period for CH2 (or CH3, CH4 ) and then want to start it  with: HAL_TIM_OC_Start_IT. I noticed that this is the wrong way: HAL_TIM_IC_CaptureCallback, is called before HAL_TIM_OC_DelayElapsedCallback and setting OC inside HAL_TIM_IC_CaptureCallback caused that HAL_TIM_OC_DelayElapsedCallback manages an interrupt already managed by HAL_TIM_IC_CaptureCallback. (bad design issue? why STM gives 4 channels and manages only one?)

I move HAL_TIM_OC_Start_IT after  HAL_TIM_IRQHandler(&htim4). In this way OC starts properly. My problem is that if I try to stop interrupt of only OC one channel inside HAL_TIM_OC_DelayElapsedCallback, the timer, after a first return from HAL_TIM_OC_DelayElapsedCallback stops working. 

- i try to stop it with the HAL: HAL_TIM_OC_Stop_IT(&htim4, TIM_CHANNEL_2); 

- i try to stop the CHANNEL with LL

however it does not work.


Where I'm wrong?