2022-05-24 10:22 AM
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.
Solved! Go to Solution.
2022-05-25 12:23 PM
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).
2022-05-25 03:09 AM
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);
}
}
2022-05-25 10:34 AM
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?
2022-05-25 12:23 PM
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).
2022-05-25 12:52 PM
Which STM32?
Read description of TIMx_CR1.URS bit.
But I personally would do exactly what Bob said above.
JW
2022-05-25 02:24 PM
This is exactly what I needed, thanks
2022-05-25 02:32 PM
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.