In an embedded programming project for FreeRTOS/ARM, I attempted to read 24 bits of data on a noise GPIO signal. While idle, the signal has a lot of random noises; during the actual data, the noise is suppressed and only the signal data will be read. The data signal consists of a preamble of 300us HIGH (1) followed by 31x300us LOW (0) and then each bit 1 is a 900us HIGH and 300us LOW and bit 0 is 300us LOW followed by 900us HIGH.
I did measurements using a simple tight GPIO read loop that shows an average 388 reads in 300us.
So I attempted to count my reads, with an epsilon of +/- 15 reads, of HIGH and LOW and determine if I read the preamble or the bits following that using a state machine. But I can't detect any preamble or data. I suspect that additional codes in the real reading codes, even though not too complex, would result in different read frequency compared to the simple measuring loop. What would be the correct way to read such data?
I figured out. The method is sound. The problem are