Skip to main content
Vmere.1
Associate III
November 9, 2021
Solved

Difference between __HAL_TIM_ENABLE_IT(INTERRUPT, HANDLE); and HAL_NVIC_EnableIRQ(interrupt)? I am genuinely confused about the usage of this function.

  • November 9, 2021
  • 1 reply
  • 2332 views

..

This topic has been closed for replies.
Best answer by waclawek.jan

> __HAL_TIM_ENABLE_IT(INTERRUPT, HANDLE);

Parameters appear to be the other way round https://github.com/STMicroelectronics/STM32CubeL4/blob/5e1553e07706491bd11f4edd304e093b6e4b83a4/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim.h#L1240 :

#define__HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER |= (__INTERRUPT__))

i.e. this enables one particular source of interrupt in TIM, see TIMx_DIER register description in any TIM chapter of RM to your STM32.

There are several sources per timer, and while sometimes they have individual interrupts, in most timers they are simply ORed to one common interrupt; see the Interrupt chapter in RM to your STM32.

> HAL_NVIC_EnableIRQ(interrupt)

This is just a "decorated" Cube/HAL version of the CMSIS-standard NVIC_EnableIRQ(IRQn), i.e. function which enables one particular interrupt in NVIC. Read the NVIC chapter in Programming Manual to the core of your STM32.

JW

1 reply

waclawek.jan
waclawek.janBest answer
Super User
November 9, 2021

> __HAL_TIM_ENABLE_IT(INTERRUPT, HANDLE);

Parameters appear to be the other way round https://github.com/STMicroelectronics/STM32CubeL4/blob/5e1553e07706491bd11f4edd304e093b6e4b83a4/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim.h#L1240 :

#define__HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER |= (__INTERRUPT__))

i.e. this enables one particular source of interrupt in TIM, see TIMx_DIER register description in any TIM chapter of RM to your STM32.

There are several sources per timer, and while sometimes they have individual interrupts, in most timers they are simply ORed to one common interrupt; see the Interrupt chapter in RM to your STM32.

> HAL_NVIC_EnableIRQ(interrupt)

This is just a "decorated" Cube/HAL version of the CMSIS-standard NVIC_EnableIRQ(IRQn), i.e. function which enables one particular interrupt in NVIC. Read the NVIC chapter in Programming Manual to the core of your STM32.

JW