Find RPM with sensor using analog comparator input

I want to build a motor shaft RPM detector. The sensor output voltage is only 20 mV peak-peak with a DC offset of Vcc/2 = Vref. The frequency is 0 (STOP) to 10kHz.

The way this circuit works is that the input capacitor blocks the DC offset.
The sensor signal rises and falls with respect to Vref. The is a zero crossing detector type of circuit.

I’m looking for code suggestions on how to setup the analog comparator input on my NANO328p. I also have a RAVEN (Atmega 1284), to test this idea out.

Thanks in advance for your responses.