This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Measuring Pulse Width using PPI and GPIOTE

Just as the title says, I'm trying to measure an input pulse width using PPI and GPIOTE.  I am currently measuring the pulse width using timer interrupts, but I would like to move to PPI to avoid issues when I start to use the Soft Device.

From looking at the forums, here is the start of my code:

I am assuming the code should do the following:

V_SENSOR is P0.30, which has a periodic pulse of unknown pulse width.  The pulse will come every second, and the width will be between 100-400ms. On the LotoHi transition the timer will clear and begin to count, and on the HitoLo transition the timer will store the value so I can read it into a variable.

I have a 1 second interrupt where I try to grab the value of the timer, value = NRF_TIMER3->CC[3]; but that never seems to give me anything useful.

I configure and start my timer like so.

In my main program I initialize the timer, initialize the GPIOE, and then start the timer.

Any advice would be appreciated.