cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to reset the internal prescaler counter in input capture mode?

SCamp.1041
Associate III
My timer setup in input capture mode. The ICPrescaler value is set to TIM_ICPSC_DIV2, meaning a capture event will occur on the falling edge of every second pulse.
 
I need to handle an edge case where I need to "reset" the whole input capture system. If I need to handle a reset in-between the first and second triggers, then the internal prescaler counter will be at 1 when I reset/reconfigure, and then the very next input edge will trigger a capture instead of waiting for the full prescaler count of 2
 
 
In order to handle this edge case I need a way to "reset" the internal prescaler counter, however I don't think there is a HAL function to do this.
4 REPLIES 4
TDK
Super User

There's always the nuclear option:

__HAL_RCC_TIMx_FORCE_RESET();
__HAL_RCC_TIMx_RELEASE_RESET();

You can try disabling/reenabling the timer but I don't think it'll reset what you want.

If you feel a post has answered your question, please click "Accept as Solution".

It doesn't look like these functions exist in my version of the HAL. This is for the F446RE MCU. 

TDK
Super User

They have existed in the F4 HAL for at least 6 years, likely longer.

stm32f4xx-hal-driver/Inc/stm32f4xx_hal_rcc.h at b6f0ed3829f3829eb358a2e7417d80bba1a42db7 · STMicroelectronics/stm32f4xx-hal-driver

If you feel a post has answered your question, please click "Accept as Solution".
SCamp.1041
Associate III

Ah yes, there they are.

However I can't say calling these has solved my issue. Could you help me understand the intention?

I am guessing I need to trigger the input capture interrupt via software. Triggering an interrupt will consequently clear/reset the capture counter back to 0. Is this the idea?