Trying to decode serial data (encoded using proprietary method) from a RF module.
Having switched back and forth between the fast-sampling (4x the fastest freq) and of late an interrupt based method, I've reached a dead-end and not sure what all I am doing wrong, because apparently people have been successful in decoding ISM-band RF data (Manchester, NRZ, VirtualWire and HT12E/PT2260-62 encoded), in software.
In my case, the RF modules's AGC (which I've no idea how to turn off, since there's no data-sheet, and the co. doesn't respond to emails... a cheap east-asian make) picks up noise and has the fastest level-transitions in durations ~40us, although valid (encoded data) transitions not lesser than 400us. My ISR has an elementary task of measuring the duration of last state to reject the spurious noise, and save only those transitions that could possibly be part of the encoded data. So far, I have not used a circular-queue (which is what I plan as the next step), but before doing that, I did a small experiment. In the ISR I check the state of a flag to see if it is true, and if true I do Serial.print("x"), else I set it true. In the loop(), I check if flag is true, then do Serial.print("-") and set it false. The flag is declared volatile. I find that I get very long continous streams of "x"s and very rare "-". My ISR is triggering on every transition of pin-2 (i.e. external interrupt#0).
Now my question is, would adding a queue really solve my problem, because apparently the ISR is running far too frequently and thereby starving my loop() of cycles. Counting the distance between the "x"s and "-", I was hoping to find the ideal queue length, but I can't figure out a pattern. Is there something inherently wrong in my approach ?
An outline of the source code is here.