This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Driving WS281x RGB LEDs from an nRF51822

Hi Guys,

I'm new to using the nRF51822 environment but I've used AVRs for years, so please be gentle...

I'm wanting to drive a strip of WS2812 RGB LEDs from an nRF51822 processor. Ultimately I want to control it over BLE but initially I need to drive the LED strip first.

Here's the WS2812 datasheet:

The WS2812 RGB LEDs have a single data line that daisy-chains between devices and it has bit timings of about 1.2us where a 0 bit is High for .35us and Low for 0.8us and a 1 bit is High for 0.7us and Low for 0.8us.

One implementation on the AVR's disables interrupts and uses hand coded assembler to generate the right bit timing. Another implementation configures the SPI port to generate the correct bit timings by sending different byte values such that the different 1's and 0's generate the desired waveform.

There's a cleaver implementation on the Teensy 3.0 board here: www.pjrc.com/.../teensy3.html that uses the OctoWS2811 library that uses DMA and some timers to clock out the bit streams for 8 LED strips in parallel from buffer in SRAM at almost no CPU overhead.

I like the idea of using DMA however, looking at the nRF51822 it doesn't seem to have this capability.

Any suggestions?

Regards

Alex Shepherd

Parents
  • It should be doable with Timer Compare regs + GPIOTE, look at the PWM sample code here on devzone for something to model it after so you don't need to do any polling. I would take the approach of using PPI to drive GPIOTE off one Timer Compare reg and use another Compare with the same CC value to setup the next bit for transmission.

    Also, there is some neat but mostly inapplicable code (as far as nRF51822 is concerned) for driving WS2811s at github.com/.../

Reply
  • It should be doable with Timer Compare regs + GPIOTE, look at the PWM sample code here on devzone for something to model it after so you don't need to do any polling. I would take the approach of using PPI to drive GPIOTE off one Timer Compare reg and use another Compare with the same CC value to setup the next bit for transmission.

    Also, there is some neat but mostly inapplicable code (as far as nRF51822 is concerned) for driving WS2811s at github.com/.../

Children
Related