Receiving 800khz data stream?

Can anyone recommend a library or any references for receiving an 800khz or so data stream? It looks like I might have to learn the assembly code to do this if there isn't already a solution out there :)

EDIT: I initially typed Mhz instead of khz! I mean kilohertz :)

EDIT EDIT: I'm mainly looking for any existing projects I can reference that have dealt with receiving data streams in this range (400microseconds/cycle or thereabouts)

You won't be reading that stream with a 16 MHz CPU.

A 1GHz Logic Analyser.

An ardunio is far too under powered for this. 16Mhz or even 32Mhz is nowhere close. 1 clock cycle at 32MHz (like a simple "fetch from RAM" command) means you could have missed ~20 data points. Assembly code wont even help here.

If you want to sample need a device designed for it. A 16Mhz arduino is not that.

Woops! Typo. I intended to write kilohertz :-[

Well now this is a little more feasible.

800 Khz period.

So you have ~10 clock cycles to do what you need to do between one bit arriving and the next.

Conservative, but possible?

Definitely sounding like a challenge and would be some very conservative assembly programming I bet.

Not more tempted by a higher frequency MCU?

I want to receive and manipulate WS2812 packets. I'll need to store anywhere from 1000 to 2,250 bytes, so I might be able to sneak it all in.

The ESP8266 is 80MHz...and can be overclocked to 160Mhz (apparently)...

160Mhz / 800Khz = 200 cycles a period = 100 per state change...


I'm pretty set on an Arduino Nano at the moment. I can make it work within the dynamic memory range.

My main question is whether there's any existing project out there that can already handle data at these time resolutions? The Nano has a theoretical 62.5ns cycle time, and the bits in this data stream are about 400ns long with about 25% +/- tolerance. 2,000,000 baud in the serial monitor is also just close enough to be able to see enough of what it's doing to get a good start.

Any help finding a similar project, or even better search term suggestions would be awesome :)

WS2812 packet

What do you mean by this - my google did NOT show this as any kind of protocol!


WS2812 is an LED protocol - often called Neopixels.



A 16 MHz Arduino can handle recieving data at high speeds, see Section 20 of the datasheet for "Examples of UBRRn Settings for Commonly Used Oscillator Frequencies" where it shows settings for 250K, 500K, 1M bps rates.

At 1M, that uses just about all the processing power. I have a project where I used SPI with 8 MHz clock to send out 45 bytes to shift registers - had to turn off interrupts and use NOPs to time out the 17 clocks for each transfer in order to send out data that fast to meet a 20KHz update rate, with just a few uS at the end of every burst to update the array pointer for the next row of 45 bytes. That achieved nearly a 1Mbps rate, just over 1uS per byte sent out. You can send it the burst of data from a PC, have the Arduino store it in array, then send it to the WS2812Bs. It will take ~ 1000uS to receive 1000 bytes, then longer to send the data out again at 800KHz. (20% longer? more?)

I don't think you can send it out as it comes in tho, there's not enough processing time in between the receiving and meeting the strict timing created using assembly code for the WS2812Bs, which need a burst of cycles to send out the 1000+ bytes in order for the parts to see a steady stream and not go into refreshing their output if they see a longer break between bytes. Each WS2812B needs 3 bytes of data.

Uno - 2048 bytes of SRAM 1284P based boards - 16K SRAM 2560 based boards - 8K SRAM.

I guess an Arduino DUE clocked at 84 MHz with 96 KBytes of SRAM could do the job, but to be sure, post a flow chart of your algorithm with timestamps and the process you need to perform with your packets.