Skip to main content
darla14
Associate III
April 7, 2016
Question

Setting Timer Channels Priority

  • April 7, 2016
  • 3 replies
  • 867 views
Posted on April 07, 2016 at 12:13

Is it possible to assign the priority to Timer channels.I am suing timer1 channels 1,2,3,4 where time period of channel 1,3 and 2 and 4 are multiple of each other so thier respective interrupts comes at the same time but I want one to be non-premepted by other by using priority.

Is it possible?

Thanks in advance !

#timer-channels #priority #!stm32f4 #-
This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
April 7, 2016
Posted on April 07, 2016 at 13:54

No, one vector one set of levels.

You might be able to play games with the NVIC directy or manage threads with an rtos.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Walid FTITI_O
Visitor II
April 7, 2016
Posted on April 07, 2016 at 14:01

Hi p.raul,

You should managed that by the NVIC premption priotity. The Intrerruption with the high priority ( premption priority is set to the lowest number)  will be non-prempted.

For example:

here TIM1 interruption will be non-prempted bu TIM8 interruption.

   HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 0, 0);

   HAL_NVIC_SetPriority(TIM8_UP_TIM13_IRQn, 1, 0);

-Hannibal-

Tesla DeLorean
Guru
April 7, 2016
Posted on April 07, 2016 at 17:49

I think you misinterpreted the question.

Single timer, multiple channels, single IRQ vector/handler. I'm pretty sure the NVIC can't preempt a currently running handler at the same level. To do so would allow unconstrained reentry, and the stack could explode.

In an RTOS, one could presumably use the IRQ to signal worker tasks/threads, causing a task switch upon exiting the IRQ handler, and freeing the NVIC to fire again.

There was another thread on materially the same topic/issue earlier, where I basically stated that to do what was wanted with multiple interrupts you'd want to constrain the handler(s) so ALL could execute within the same minimum time defined by the fastest frequency being called. ie if you had 1, 10 and 100ms tasks, combined they would need to execute in less than 1ms for this mechanism to work. If the 100ms task takes 85ms, it is not going to work, and another method needs to be used.

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