2021-02-24 03:45 PM
I know timers are not designed for that purpose but Input Capture channels have unique Input Filter property which I think could be used to debounce a button. It just needs to be configured a way so interrupt is triggered on external signal rising (or falling) edge.
I cannot figure out how to configure it in CubeMX. It would also be good to know which channel triggered the interrupt - in case more than one channel is used.
Please advise.
Solved! Go to Solution.
2021-03-31 12:11 PM
It is actually quite trivial, basic setup (below) will do + timer interrupt enabled.
The only catch is that channels on the same timer have to be enabled separately:
HAL_TIM_IC_Start_IT(&htim4, TIM_CHANNEL_3);
HAL_TIM_IC_Start_IT(&htim4, TIM_CHANNEL_4);
This does NOT work:
HAL_TIM_IC_Start_IT(&htim4, TIM_CHANNEL_3 | TIM_CHANNEL_4);
Next, within HAL_TIM_IC_CaptureCallback() interrupt handler button pressed can be identified using htim->Channel
That's all.
TIMERS_CLOCK_FREQ is 'user constant' I defined
2021-03-31 12:11 PM
It is actually quite trivial, basic setup (below) will do + timer interrupt enabled.
The only catch is that channels on the same timer have to be enabled separately:
HAL_TIM_IC_Start_IT(&htim4, TIM_CHANNEL_3);
HAL_TIM_IC_Start_IT(&htim4, TIM_CHANNEL_4);
This does NOT work:
HAL_TIM_IC_Start_IT(&htim4, TIM_CHANNEL_3 | TIM_CHANNEL_4);
Next, within HAL_TIM_IC_CaptureCallback() interrupt handler button pressed can be identified using htim->Channel
That's all.
TIMERS_CLOCK_FREQ is 'user constant' I defined
2024-08-02 03:47 AM
hi
could you please brief what Input filter will do with input capture data? how input capture data will affect using this filter and without using this filter?