cancel
Showing results for 
Search instead for 
Did you mean: 

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

Vmere.1
Senior
1 ACCEPTED SOLUTION

Accepted Solutions

> __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

View solution in original post

1 REPLY 1

> __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