2024-10-19 06:40 AM
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.
Solved! Go to Solution.
2024-10-20 02:51 AM
> 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
2024-10-19 07:00 AM
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.
2024-10-19 07:47 AM
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
TIM17 cube nvic config:
Generated init code, its exactly the same as the TIM16 code:
Here is a subset of my interrupt handler code. There's a large if-else block in here that checks TIM2, TIM16, and TIM17.
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.
In the startup assembly file you can see the TIM16 and 17 blocks:
Here's the TIM17 registers right after the config is done, and then here it is after the program has run for a bit:
Also, here's a grab of every register that contained the word "tim17"
2024-10-20 02:51 AM
> 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
2024-10-20 05:56 AM
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.
2024-10-20 07:25 AM
Thanks all,
I had a typo when I copied and pasted HAL_TIM_Base_Start_IT and I wasn't checking the return value.