cancel
Showing results for 
Search instead for 
Did you mean: 

No interrupts with TIM1 or TIM17

Jcoll.1
Associate III

I have a HAL/Cube based project where I am currently using TIM2 for counting edges, and TIM16 for timing.

I am now trying to add more timers but have found that when I enable TIM1 orTIM17, and enable ALL the associated interrupts, that I never get any interrupts for these timers.  But interrupts continue just fine for TIM2 and TIM16.

1 ACCEPTED SOLUTION

Accepted Solutions

 

> I'll have to read the documentation some more to get the relevant RCC and NVIC registers.

That too, but also read the TIM chapter.

TIM17_DIER=0 means, that there is no interrupt enabled for TIM17.

TIM17_CR1=0x80 means that TIM17_CR1.CEN=0 i.e. TIM17 does not run.

JW

View solution in original post

5 REPLIES 5

Not sure how we'd debug this remotely with this much information.

Dump the related RCC and TIMx registers. Those of the NVIC

Show Code for the Vector Table and Handlers.

Show Code for initialization.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Given that its entirely HAL/Cube generated code I mostly assumed I had a fundamental misunderstanding about the timers (i.e. something like "you simply can't do that").

Here's what I could grab easily.  I'll have to read the documentation some more to get the relevant RCC and NVIC registers.

 

TIM17 cube config

Jcoll1_0-1729348186996.png

 

 

TIM17 cube nvic config:

Jcoll1_1-1729348218089.png

 

Generated init code, its exactly the same as the TIM16 code:

Jcoll1_2-1729348313630.png

 

 

Here is a subset of my interrupt handler code.  There's a large if-else block in here that checks TIM2, TIM16, and TIM17.

Jcoll1_3-1729348376141.png

 

 

Cube auto generates these functions, which I believe are the actual interrupt vectors.  HAL_TIM_IRQHandler will call HAL_TIME_PeriodElapsedCallback.  TIM1_TRG_COM_TIM17_IRQHandler is never called.

Jcoll1_4-1729348423624.png

 

In the startup assembly file you can see the TIM16 and 17 blocks:

Jcoll1_5-1729348466494.png

Jcoll1_6-1729348474182.png

 

 

Here's the TIM17 registers right after the config is done, and then here it is after the program has run for a bit:

Jcoll1_8-1729348645987.png

 

Jcoll1_7-1729348583871.png

 

 

Also, here's a grab of every register that contained the word "tim17"

Jcoll1_9-1729349258055.png

 

 

> I'll have to read the documentation some more to get the relevant RCC and NVIC registers.

That too, but also read the TIM chapter.

TIM17_DIER=0 means, that there is no interrupt enabled for TIM17.

TIM17_CR1=0x80 means that TIM17_CR1.CEN=0 i.e. TIM17 does not run.

JW

Thanks for checking on that. 

 

THAT'S interesting. Like I said, this is all auto generated code. For timers 2 and 16 it's working as expected. 

 

I'll check on why this register isn't set and post back.

Thanks all,

I had a typo when I copied and pasted HAL_TIM_Base_Start_IT and I wasn't checking the return value.