cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32L476: Available base Timers using HAL_TIM

Posted on January 11, 2018 at 12:30

I'm using stm32L476 mcu and I'm trying to configure and enable a set of timers in my stm32 project using cube, hence HAL libraries. 

Reading datasheet I found TIM2, TIM3, TIM4, TIM5, TIM15, TIM16, TIM6 and TIM7 could be used as simply timebases. 

First I have enabled TIM7 and TIM3. I enabled the timers irq using TIM3_IRQn (seen at stm32l476xx.h file) and its TIM3_IRQHandler (seen at and startup.s one) handler for callbacks. It was ok.

So, when I try to enable Tim6 irq, TIM6_IRQn or TIM6_IRQHandler they seem not to exist or, maybe, I'm not able to see how to enable this timer's interrupt. The same is happened with TIM15 and TIM16 and some of the available timers.

Could anybody explain me if there is less number of available timers using HAL libraries than not using ones. If is this the case which of them are actually available if used as base timers?

I have read two stm32l4 datasheets and how to use HAL drivers user guide. But here is no explanation about this fact. 

Any new information will be appreciated. 

Thanks in advance.

4 REPLIES 4
Chris1
Senior III
Posted on January 11, 2018 at 20:22

Some of the timers have interrupt handlers that are shared with other peripherals.  You need to use TIM6_DAC_IRQn with corresponding TIM6_DAC_IRQHandler; for TIM15: TIM1_BRK_TIM15_IRQn, TIM1_BRK_TIM15_IRQHandler etc.

Posted on January 12, 2018 at 11:30

Hi Chris, thanks for attending me, I see what you mean. But I have an single question about your answer in order to clarify your comment:

Hence,  is it possible to get TIM6 timer and the other ones as generic timebases using these irq handlers?

I guess, despite handler's name, HAL lib could handle elapsed time callbacks, normally. But I'm not sure. So, if you can confirm this, I will be grateful. 

Regards.

Posted on January 12, 2018 at 15:08

All TIM instances are capable of providing an update interrupt so any of them is suitable for a time base. I would recommend using TIM6 or TIM7 as they have no other capabilities (like external channels). I also recommend using the Reference Manual to get informed of the features of the peripherals.

Posted on January 12, 2018 at 15:42

Yes, if TIM6 is configured with interrupts enabled, TIM6 update events (e.g., counter overflow/underflow) will result in execution of TIM6_DAC_IRQHandler().