Tag Archives: 8 MHz AVR

8 MHz AVR MCU controls WS2811 LED driver at 800kHz

Yes, it is definitely possible to drive WS2811 LED strip controllers at 800 kHz with an 8 MHz Atmel AVR – sans an external 16 Mhz oscillator.

As the Hack A Day crew notes, this was recently proven by a Maker named Danny who wrote Assembly code to handle pairs of binary bit values.

“With a code block for each of the four possible combinations in hand he had to find a way to craft the conditional jumps to preserve accurate timing. After hitting the wall trying to solve this puzzle by hand he wrote a C++ program to solve it for home,” the Hack A Day team explained.

“The proof is in this video which shows one chip driving multiple Larson scanners on a single strip.”

According to Danny, the exercise taught him that extremely time-critical code can be solved with a number of techniques.

“[The first is] unrolling loops. It is not a new technique, but in this case it not only saves on the number of test-and-jump-to-the-starts (the normal reason to unroll a loop), but also decreases the number of other tests and allows me to sweep a few precious left-over clock cycles into contiguous blocks,” Danny wrote on his Wiki page.

“[Also], when code is ‘phase critical’ abandon the idea of a list-of-instructions and organize the code inphase aligned side-by-side blocks, where a jump is most often a jump ‘to the right’ or ‘left.’ [Finally], use software to optimize code layout in memory. [While] I am not aware of any assembler that will automatically do this when jump labels are out of reach, I [do] know I have wished for it more than once.”

Additional information about Danny’s hack can be found here on the project’s official Wiki page.