cancel
Showing results for 
Search instead for 
Did you mean: 

Timer interrupt issue with CubeMX generated code, NucleoF722ZE board

Brian D
Associate III
Posted on October 13, 2017 at 21:38

NucleoF722ZE board, Stm32CubeMX ver 4.22.1, Eclipse

Version: Neon.3 Release (4.6.3)

I wanted to setup TIM6 as timer interrupt for 400usec sampling loop. In CubeMX : TIM6 clocked at 1Mhz and ARR = 400,

TIM6 Configuration/NVIC settings/Enabled (TIM6 global interrupt), then in NVIC Configuration/enabled TIM6 global interrupt with Preemp Priority=10 and Sub Priority=0. Then Generate code.

 The generated code seemed to be OK, and it also had 

 set NVIC interrupt priority and enable as below.

HAL_NVIC_SetPriority(

TIM6_DAC_IRQn

, 10, 0);

HAL_NVIC_EnableIRQ(

TIM6_DAC_IRQn

);

I added code to toggle the LED inside the ISR void TIM6_DAC_IRQHandler (void) and it never triggered.

Result:

TIM6  was counting OK (read TIM6.CNT and outputted on PWM pin for monitoring), but there was  no timer overflow interrupt generated.

 

However after adding TIM6.DIER = 1; // DMA/interrupt enable, then it worked.

What I need to add TIM6.DIER=1; instead of by CubeMX? or what I did wrong in my steps?

Thanks,

Brian

#stme32-cube #timer-interrupts #cubemx-4.22
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on October 14, 2017 at 00:41

Hello!

Did you start the timebase by calling HAL_TIM_Base_Start_IT  or HAL_TIM_Base_Start_DMA(in case you use DMA)?

Also 400 microsecond is very short time to observe toggling by eye.

Regards

vf

View solution in original post

3 REPLIES 3
Posted on October 14, 2017 at 00:41

Hello!

Did you start the timebase by calling HAL_TIM_Base_Start_IT  or HAL_TIM_Base_Start_DMA(in case you use DMA)?

Also 400 microsecond is very short time to observe toggling by eye.

Regards

vf

Brian D
Associate III
Posted on October 14, 2017 at 01:45

Hi VF,

Thanks for the answer. No, I didn't use those functions; to start the timer I just set the bit CE=1 in the CR1 register. I was aware that one needed to call HAL_TIM_Base_Start(TIM6) for the timer to run from reading other posts, but I didn't know those functions mentioned by you exist. How do I know they are exist and how to use them? 

So I searched for 

HAL_TIM_Base_Start_IT, and this answers my question. It calls a macro to set the interrupt bit in TIM6.DIER register. 

Thanks,

Brian

Posted on October 14, 2017 at 12:00

Hi Brian.

Unfortunately there is not detailed documentation to read from.

There is a description only at HAL user manual inside HAL firmware  at \STM32Cube\Repository\STM32Cube_FW_F7_V1.7.0\Drivers\STM32F7xx_HAL_Driver.

Take a look also inside stm32f7xx_hal_tim.c module. In the begining there is a summary of all tim functions and their use

You can study also every function inside modules to havean idea how it works.

Regards

vf