cancel
Showing results for 
Search instead for 
Did you mean: 

Timer Interrupt on overflow only

Mosco
Associate II

I am capturing an RC PPM signal using an advanced timer with DMA. But now, I want to implement a failsafe in case of a lost connection using only hardware. The closest I got so far is using a separate timer (with pins connected externally) in reset mode, so the counter restarts when an edge is detected. I am using the timer update interrupt to know when the counter period has been reached. This works, except that the act of resetting the counter also triggers this interrupt. I want an interrupt only when there has been no activity on a pin for an amount of time.

1 ACCEPTED SOLUTION

Accepted Solutions
Bob S
Principal

Configure one of the timer's channels for "output compare" (don't need a physical pin tied to this channel, in CubeMX this is "output comapre no output"). Set the channel's compare register to whatever you want your timeout count to be (for example, 65535 for a 16-bit timer just before roll-over).

View solution in original post

6 REPLIES 6
Javier1
Principal

what if instead of using that second timmer interruption you do something like this:

HAL_TIM_Base_Start(&htim16);
 
  while (1)
  {
 
do your stuff here
 
    // If enough time has passed , trigger TIMEOUT and get new timestamp
    if (__HAL_TIM_GET_COUNTER(&htim16) - timer_val >= 10000)
    {
     TIMEOUT!!
      timer_val = __HAL_TIM_GET_COUNTER(&htim16);
    }
 
}

Mosco
Associate II

That does in fact work, I don't like it but it's the most obvious. Is there not a way to set up a timer-based interrupt as an input timeout?

Bob S
Principal

Configure one of the timer's channels for "output compare" (don't need a physical pin tied to this channel, in CubeMX this is "output comapre no output"). Set the channel's compare register to whatever you want your timeout count to be (for example, 65535 for a 16-bit timer just before roll-over).

Which STM32?

Read description of TIMx_CR1.URS bit.

But I personally would do exactly what Bob said above.

JW

This is exactly what I needed, thanks

STM32F303K8, I couldn't get __HAL_TIM_URS_ENABLE to work in the little time I spent on it. I got the output compare to work so I'll quite while I'm ahead. Also, I need to access the DMA not just when an overflow occurs, I think I would have to use two timers connected externally if I went the Update Request Source (URS) route.