cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable output compare timer interrupt in STM32CubeMX?

Eden.757
Associate

Hello,

I want to activate three output compare interrupts in my timer peripheral. I want to use Output Compare for this purpose because then I can change the time. However, in STM32CubeMx there is a button to activate a global TIM2 interrupt, but there is no output compare interrupt. Even when I activate the output compare. Am I missing something?

0693W00000APxORQA1.png 0693W00000APxP0QAL.png

1 ACCEPTED SOLUTION

Accepted Solutions
Petr DAVID
ST Employee

Hello Eden.757,

the setting output/compare interrupt for the respective channels is not available in the STM32CubeMX. The respective CCxIE bits (Capture/Compare interrupt enable) are set inside the code when you are using related HAL functions.  In your case you will be interested in these respective functions:

HAL_StatusTypeDef HAL_TIM_OC_Start_IT (TIM_HandleTypeDef * htim, uint32_t Channel);
HAL_StatusTypeDef HAL_TIM_OC_Stop_IT (TIM_HandleTypeDef * htim, uint32_t Channel);

More information you can in the HAL and low-layer drivers user manual related to MCU family you are using. For the STM32F4 mcus family the manual could be found here. The TIM HAL functions across the families are rather similar. Please click on Select as Best if my reply fully answered your question. This will help other users with the same problem to find the solution faster!

View solution in original post

1 REPLY 1
Petr DAVID
ST Employee

Hello Eden.757,

the setting output/compare interrupt for the respective channels is not available in the STM32CubeMX. The respective CCxIE bits (Capture/Compare interrupt enable) are set inside the code when you are using related HAL functions.  In your case you will be interested in these respective functions:

HAL_StatusTypeDef HAL_TIM_OC_Start_IT (TIM_HandleTypeDef * htim, uint32_t Channel);
HAL_StatusTypeDef HAL_TIM_OC_Stop_IT (TIM_HandleTypeDef * htim, uint32_t Channel);

More information you can in the HAL and low-layer drivers user manual related to MCU family you are using. For the STM32F4 mcus family the manual could be found here. The TIM HAL functions across the families are rather similar. Please click on Select as Best if my reply fully answered your question. This will help other users with the same problem to find the solution faster!