cancel
Showing results for 
Search instead for 
Did you mean: 

How to get state of the pulse (High or Low) when using Input Capture mode.

SDas.1
Associate II

In my application I need to design a multi purpose digital input which can operate in 3 modes

  1. ON/OFF detection
  2. Frequency measurement and
  3. Pulse Counting

I can do the last 2 using HW Timers in Input Capture mode and configuring it for both edges. In the alternate interrupts I calculate frequency and I have a separate counter to count pulses on every interrupt and then divide the final result by 2 since the interrupt is for both edges.

But for the first application I am unable to find a solution. The application needs to be able to change the Input modes on the fly so I was thinking that anything in Input Capture mode will be helpful.

Thanks

2 REPLIES 2
TDK
Guru

Read the GPIO_IDR register to determine the state of the pin, even when in AF mode. HAL_GPIO_ReadPin does this.

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

Thanks for the solution. I will try it then.