Single shot timer for peripheral timeout check
Hello,
I'm here on H75x. I'm looking for portable way to do a timeout check via timer.
Here, I want a timeout IRQ if UART receive DMA hangs up.
First I setup a OnePulse timer in Cube. It generates the following code:
if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIM_OnePulse_Init(&htim6, TIM_OPMODE_SINGLE) != HAL_OK)
{
Error_Handler();
}The second init function does almost the same as the first but activates the OneShot mode which stops the counter immediately if IRQ is fired.

I was looking for a suitable HAL function to setup the timeout value but failed. Instead I use
__HAL_TIM_SetCounter(htim, 1); // set start value
__HAL_TIM_SetAutoreload(htim, ulDelay); // set end value
__HAL_TIM_ENABLE(htim);The last macro is required because after the RX DMA is done in time, the timer has to be stopped to prevent from false timeout IRQs.
Is this the way to go? Is there a HAL-compatible solution which I didn't get?
Thanks
