The servo I use in my application uses a PWM signal duty cycle to represent servo amperage level.
So, to measure servo amperage, I use a GPIOTE channel to capture the time between rising and falling edges of the servo's PWM amperage signal. I then have an interrupt handler that reads the GPIO pin to determine whether or not the time was for a peak or valley and I calculate duty cycle appropriately.
The problem is at low duty cycles, when triggered by a peak, the signal occasionally changes prior to reading the pin in the interrupt handler routine. This result is an inaccurate spike in servo amperage. As I use the valley routine to calculate duty cycle when I should have used a peak routine.
I recognize that it is a timing issue and would like to overcome this with a robust solution.
Can I rely on the latch function instead of reading the pin to determine if I'm measuring the width of the peak or the width of a valley?
Or alternatively, Can a I make a pin read and GPIOTE event via PPI?
I've attached the code of my interrupt handler in case you need more detail.