LPD8806 + SPI + Due

I'm trying to take the Renard protocol output of Vixen Lights 3.0 into my Arduino Due and spit it out over SPI to the LPD8806 RGB strip (sold at adafruit). The renard protocol is very simple, it will output 2 control bytes (which are ignored for now in the code) and then 3 bytes for each RGB pixel on the strip. So for 20 pixels that is 60 bytes + 2 bytes for a total of 62 bytes. All I do is take the 60 bytes of color information and send it out via spi with 3 latch bytes. The code below works fine for 20 pixels. Not a problem. Once I try anything above that (24 pixels) the spi output stops cold and I see nothing on the strip. This is where I've wasted hours and need a little advice.

I'm using 2 pins on the Arduino Due:
MOSI - 109
SCK - 110

//****************************************************************
//  Name    : LPD8806 RGB Awesomeness                           //
//  Author  : Matthew Strange                                   //
//  Version : 1.0                                               //
//  Notes   : Arduino Due Sketch                                //
//          : Renard Protocol                                   //
//          : LPD8806 RGB Strip                                 //
//          : Vixen 3.0.3                                       //
//****************************************************************

#include "SPI.h"

byte incomingByte[481]; //Channels + 1 - zero indexed

//number of pixels/LEDs in strip you will use
int pix = 24;

int pixCount = pix * 3;
int one = 0;
int fun = pixCount + 1;
//int ss=109;

// Clock Pin
//int clockPin = 110;
// Data Pin
//int dataPin = 109;

void setup()
{
//pinMode(ss, OUTPUT); // we use this for 109 pin  
SPI.begin(109);
SPI.setBitOrder(109, MSBFIRST);
SPI.setDataMode(109, SPI_MODE0);
SPI.setClockDivider(109, 21);
  
Serial.begin(115200); 
}

void loop(){
  //Run once to clear the strip
  if (one == 0){
     SPI.transfer(109, 0x00, SPI_CONTINUE);
     SPI.transfer(109, 0x00, SPI_CONTINUE);
     SPI.transfer(109, 0x00);
     one = 5;  
  }
  //Place incoming bytes into the array
  if (Serial.available() >= (pixCount + 2)) { // Channels + 2
      for (int i=0; i < (pixCount + 3); i++) { // Channels + 3
        incomingByte[i] = ((Serial.read()/2) + 128);
      }

      
  }
      // Skip the first 2 bytes on Renard protocol and output to RGB strip
      for (int i=2; i < (pixCount + 3); i++) { //Channels + 3
        //shiftOut(dataPin, clockPin, MSBFIRST, incomingByte[i]);      		
        SPI.transfer(109, incomingByte[i], SPI_CONTINUE);
        
      }
     // Latch the output
      SPI.transfer(109, 0x00, SPI_CONTINUE);
      SPI.transfer(109, 0x00, SPI_CONTINUE);
      SPI.transfer(109, 0x00); 
      //delayMicroseconds(150);
      //delay(25);


}

Yes I'm aware Adafruit has a library but I'm a DIY geek/junkie and I want to learn this myself, not cheat. Thank you in advance

I would recommend using the Adafruit library as a starting point. Nothing wrong with looking at proven code when building your own (IMO).

BTW, if you're against using prebuilt libraries, then you aren't using the Arduino platform, right? :wink:

djjoshuad:
I would recommend using the Adafruit library as a starting point. Nothing wrong with looking at proven code when building your own (IMO).

I am/have. The Due is slightly different and I need to spend some more time with the datasheet comparing. I'm seeing this code pop up in the library and in a few examples online but I didn't see it in the Due datasheet at first glance so maybe these registers have changed:
while(!(SPSR & (1<<SPIF))); Or maybe not. Need to spend more time with it.

djjoshuad:
BTW, if you're against using prebuilt libraries, then you aren't using the Arduino platform, right? :wink:

LoL who said I'm against libraries? It's a simple difference of me sending 3 bytes to a library and having it magically work, OR me taking the time to learn to set up the cool new extended SPI abilities on the awesome Due myself and having that skill. Almost there.

Thank you

Hey Gorak!

Have you find a solution to activate SPI on Arduino Due?
I also try to connect a 256x64 Graphic OLED but no luck...

Probably SPI related data must be done with the library functions defined at http://arduino.cc/en/Reference/DueExtendedSPI

I don't see a function to turn SPI off & on like is used in the graphics code such as that written by Adafruit. Will keep looking.