using pwm input to measure frequency

I have an NRF9160 system running and I see mention of "The nRF9160 PWM peripheral can capture the period and pulse width of an external PWM signal" but  was a little confused as to how to implement it. I have used and I am using PWM as an output so that I understand. I have used a generic GPIO as input and used interrupts to start and stop a timer to measure time between edges. This uses two items a generic GPIO and a timer. as I understand the capture capability it just used a single PWM to do the measurement.

can you point me to any examples how to implement this if I am correct in assuming all I need is a single PWM pin.

Parents Reply Children
  • I have used a generic GPIO and timer on other examples in the past. I am not using it now for this application. I wanted to use the capture capability of the PWM. I see there is a ...\v3.02\zephyr\tests\drivers\pwm\pwm_loopback example. this looks like it uses a PWM output connected to a PWM input that does use capture capabilities. I tired to understand and build this but was unsuccessful. there is not an overlay for nRF9160 so I could not get it to compile. Is this what I need to understand to do PWM measure frequency and period. The example is not very clear is there some description of the PWM loopback example?

  • There are lots of efforts to implement a sample to count the incoming clock frequency through a GPIO. One of them is here with the implementation details. Please check if one of those can be used as template.

Related