Skip to main content
Eden.757
Associate
May 27, 2021
Solved

How to enable output compare timer interrupt in STM32CubeMX?

  • May 27, 2021
  • 1 reply
  • 5809 views

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

This topic has been closed for replies.
Best answer by Petr DAVID

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!

1 reply

Petr DAVID
Petr DAVIDBest answer
ST Employee
May 29, 2021

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!