Apologies if this isn't the right place to post this, but I haven't selected an MCU yet and the selection will depend on how I'm going to solve this issue.
I have a 200kHz carrier that has a low frequency (25 bits/second) data channel that is indicated by the phase of the carrier advancing or retarding by 22.5°. The data channel uses Manchester coding so the frequency always averages out to 200kHz over one second (with dummy bits inserted as required). Basically it stretches or shortens one cycle of the carrier to indicate high or low bits, and you recover the clock in the usual way with Manchester coding.
The carrier is a square wave derived from a sine wave, but can have some noise at times. I need to be able to detect the phase changes on the cycle they happen, because some of the bits start at precise times that I need to synchronize to.
I can demodulate the data by XOR mixing the carrier with a 200kHz square wave that I steer to be 180 degrees out of phase with the carrier, so they mostly cancel each other out except for the low frequency data stream that I separate with a low pass filter. Of course the problem with this is that the output of the filter is delayed and the delay is basically random, depending on the tolerances of the analogue components and the temperature.
The steering is done by low pass filtering the XOR output, when the two signals are in phase they cancel out and produce close to VCC. I have another square wave that is 90 degrees out of phase with the first one, and with low pass filtering gives me the sign of the error so I know if I need to advance or retard. I sample these voltages with an ADC.
So the issue is how do I detect the phase changes on the cycle that they happen, or at least at some fixed time after they happen that isn't subject to variances due to analogue circuits. I need to measure down to 1uS, ideally lower.
Are there any MCUs that have timers that can do "window capture"? By that I mean detect a transition within a certain timeframe, and ignore ones outside it. Then I could have two windows for the advance/retard transitions, but I don't know of any MCUs that can do that. STM32 have a gate function that allows one timer to control when another time runs, so potentially I could have a chain of timers maybe.
The obvious solution is to just have the timer capture every cycle and an interrupt check the captured value, but the problem with that is it will trigger 200,000 interrupts a second. I could do it but would need to dedicate an MCU to it. An AVR Dx at 20MHz would only have 100 cycles to handle the interrupt or loop, but I suppose that's within the realms of possibility.
Any other clever ideas?