Electronic – How to software-decode this 260KHz serial stream

communicationdigital-logicprotocolserialsignal

I've probed this serial stream coming out of a scoreboard controller and it seems like a proprietary protocol. How would I go about trying to software-decode this?

Serial stream

The start bit is 7.8us long. All the data bits are about 3.85us, giving a bus speed of around 260KHz. A logic HIGH bit starts with a 3.1us HIGH period then a ~800ns LOW. A logic LOW bit is the same but the periods are switched. Each packet is made of 255 bits, so about one packet is sent every millisecond.

I've thought of triggering on the rising edge and then reading the pin level after a short delay, but I don't think an interrupt-driven scheme would work that well because of the overhead.

Any ideas?

Best Answer

You say that the overhead of interrupt handling would be too high, but I don't think that's necessarily true. A cheap microcontroller may not be able to do much useful processing of the data stream, but it should be powerful enough to serve as an ad-hoc converter.

Let's take an AVR chip as an example: the ATmega328P that serves as the core of the Arduino dev board. At the maximum clock rate of 20MHz, you get 77 clock cycles per bit. According to the datasheet (page 15) it takes about 7 clock cycles to enter an ISR and 4 cycles to exit.

Assuming you spend half of each data bit in a spin-loop waiting for the right time to sample the input, you're left with about 27 cycles per bit outside of the interrupt handler. Most AVR instructions are single-cycle, so that should be plenty of time to frame the bits into bytes and shove them onto an SPI link to your host processor.

(I've glossed over the problem of detecting start bits. One option is to reset one of the built-in timers at the beginning of every bit, and use the output compare to determine whether the interval between two rising edges exceeds a threshold.)