I'm working with a prototype sensor that changes impedance when environmental conditions change (sorry, can't provide too many details on the sensor itself).
Currently the sensor is read by generating a 10kHz sine wave, and measuring the phase difference using two fast comparators and a digital 12 bit counter with a 2MHz clock. The comparators generate a pulse on zero crossing, one starting and one stopping the counter. The sensor value is read as a 12 bit value from the counter.
I was hoping to simplify the circuit a lot with just an external sine generator, generating a 1.65V centered, 3.3V sine (single supply). And use the nRF52840 comparator to detect zero crossing (using differential mode with the negative input at 1.65V), starting a timer when the reference signal (AIN0) crosses zero, and stopping it when the sensor signal (AIN1) crosses zero. That should give me a good enough resolution. The original circuit uses a 2MHz clock, and I should be able to use the 16MHz timer.
If I understand things correctly, I need to use the comparator, PPI and timer peripherals, using PPI to route events. And that's where I get lost, the only PPI example I found is for timer to timer PPI. I'm assuming I need to set the AIN0 comparator to generate an UP event when the + input is "zero crossing" the - input set at 1.65V (my reference point for the 0 point of the 3.3V signal), and use PPI to start TimerX. Then use the UP event for AIN1 (with same reference point) to stop the timer, and store the value for further processing
Am I on the right path? Is there any guidance on how to properly initialize PPI, comparators and timer for a case like mine? I'm not expecting code, just pointers to get started and avoid going down dead ends