Page 1 of 1

driving APA102 LED array in lucid

Posted: April 27th, 2018, 7:50 pm
by hydronics

I'm really close to driving these LEDs over SPI. I'm sending the bytes to the AVR serial console and the SPI module simultaneously.

Every time I send the bytes, the 3 LEDs act quite randomly and or at least mostly random... so close!.

Code: Select all

    spi_out.data_in = ledArrayManager.tx_data;
    spi_out.start = ledArrayManager.new_tx;  
    avr.new_tx_data = ledArrayManager.new_tx;
    avr.tx_data = ledArrayManager.tx_data;

It reads in starting at the last byte in the array....

data2 = {.............8hff, 8b0, 8b0, 8h1e, 8he3, 8b0, 8b0, 8b0, 8he3, 8b0, 8b0, 8h1e, 8he3, 8b0, 8b0, 8b0, 8b0};

The APA102 data protocol is described here: ... -superled/
I've tried a bunch of mixing the bytes around with no avail... The 32 0s start frame is most important. I think it's a problem with interfacing with the SPI module.

- as 32 bits of 0s for the start of the sequence

- followed by a 32 bits per LED frame of 3 bits (111) and 5 bits (brightness), and 1 byte per R,G,B...

- followed by 32 bits of 1 or 0 depending on what you read

Re: driving APA102 LED array in lucid

Posted: May 9th, 2018, 1:32 pm
by hydronics
.... update

the code more or less works... I found infrequent updates produce glitchy results but if I continuously send out the LED array it is stable. I'll update this later as I understand more but feel free to make suggestions! ... ter/apa102