This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TLC5971 latch timing question

Other Parts Discussed in Thread: TLC5971

I'm using an 8-bit SPI to talk to the TLC5971.  The SCKI runs at 4MHz (250ns period) when the SPI is sending 8-bit chunks of data.  The timing between the last SCKI and the first SCKI of the next 8-bits of data is ~5.24us.  This is working, but based on the specification I would not have expected this to work.  In the specification the minimum latch timing from the last SCKI is 1.34us or it is 8 times the SCKI period so in my case it would have been 8*250ns = 2us.  Am I reading the specification incorrectly?  What is the latch timing?

Here is how I’m setting the FC register:

  bit 213: BLANK = 0

  bit 214: DSPRPT = 1

  bit 215: TMGRST = 0

  bit 216: EXTGCK = 0

  bit 217: OUTTMG = 1

Thanks,

Garrett

  • Hello Garrett-san,

    In your case, data will be generated after 2us from last SCKI. So you have to send next 8bits data in 224bits within 2us. 

    To resove this, you have to change SCKI speed to slow 

      

    The time of 1.32us or 8 SCKIs after latch pulse needs for next data.    

      

    Best regards

    K.Narisawa

     

  • With bit 216: EXTGCK set to 1 then I was no longer able to write to the LED.  This changes the PWM GS clock to SCKI.  So the timing

    for the latch must be some multiple of the internal clock when this bit is set to 0.  I just don’t see where this is specified in the specification.

  • Hello Garrett-san,

    I attached sample code for external clock mode 1pc and 3pcs of cascading and also internal clock mode too.

    Please refere  for programing.

    2148.TLC5971x_Sample_Code.zip

    On page28 and page29 datasheet, it shows the external mode operation, but it's simple.

    Could you please look at attaching file?

     

    Best Regards

    K.Narisawa   

     

  • Hi Kiyoshi,

    I've taken a look at the code and it makes sense on how to program the device.  I'm sending 8-bits of data at a time using my SPI.  Are there any timing requirements between these SCKI pulses that make up the 224 bits?  Here is a picture of what I'm concerned about?


    Thanks,

    Garrett

  • Hello Garrett-san,

    I'm sorry my late response.

    I attached a file to think of latch timing and non latch timing.

    8176.TLC5971_timing.pdf

    In case of sending 224bits data by 8bits of chuncks, it have period A  x 8times over between 8bits and 8bits,it works internal latch automatically.

    So it must control this space by controller side.

    Best Regards

    K.Narisawa

        

  • Thanks for all your Kiyoshi, this now makes sense.  

  • Hello Kiyoshi  and all-

    I'm also having a few problems with setting up the TLC5971- probably not understanding the data sheet well enough - can anyone just help me get going?

     

    I have a single TLC5971 with Vcc/Vref connected to +5V and 1k resistors connected from the outputs to +5V. R ref is 4K7

    I'm sending the following bit string:

     

    %10010110  %01011111 %11111111 %11111111  as the setup string followed by 12 sets of data bytes, each of %00001111  %00000000

     

    ie the control code of $25, outtmg=1, extgck=0, tmgrst=0, dsprpt=1 , blank=0

    then the 3 global brightness registers set at %1111111 followed by the data bytes

    Data and clock pulses verified by 'scope but nothing from the outputs??

    Clocking speed is 250kHz and there's no spacing between the bytes. Time between strings of 224 bits is about 40msecs so should be plenty of time for the internal latch to operate.

    I'm sure there's a simple explanation but I can't see it!

     

    Thanks

     

     

  • Bit 216 EXTCLK is set to 0 so your using internal grayscal clock mode. Follow the procedures on page 27 of the specification to program the part. When you first power up the VCC all OUTXn are off because BLANK is set to 1. Write the 224-bit data packet to configure the part. Then subsequent writes can be done to program the RGB.

    Here is the procedure I use. First I configure the driver:
    SendData8(0x96); // 6-bit Decoder
    SendData8(0x5f); // 5-bit FC
    SendData8(0xff); // 21-bit BC
    SendData8(0xff); ///////////////////

    SendData8(0x00); // LED1: Blue MSB
    SendData8(0x00); // LED1: Blue LSB
    SendData8(0x00); // LED1: Green LSB
    SendData8(0x00); // LED1: Green LSB
    SendData8(0x00); // LED1: Red LSB
    SendData8(0x00); // LED1: Red LSB

    SendData8(0x00); // LED2: Blue MSB
    SendData8(0x00); // LED2: Blue LSB
    SendData8(0x00); // LED2: Green LSB
    SendData8(0x00); // LED2: Green LSB
    SendData8(0x00); // LED2: Red LSB
    SendData8(0x00); // LED2: Red LSB

    SendData8(0x00); // LED3: Blue MSB
    SendData8(0x00); // LED3: Blue LSB
    SendData8(0x00); // LED3: Green LSB
    SendData8(0x00); // LED3: Green LSB
    SendData8(0x00); // LED3: Red LSB
    SendData8(0x00); // LED3: Red LSB

    SendData8(0x00); // LED3: Blue MSB
    SendData8(0x00); // LED3: Blue LSB
    SendData8(0x00); // LED3: Green LSB
    SendData8(0x00); // LED3: Green LSB
    SendData8(0x00); // LED3: Red LSB
    SendData8(0x00); // LED3: Red LSB

    Now I write to it to turn on the LEDs:
    SendData8(0x96); // 6-bit Decoder
    SendData8(0x5f); // 5-bit FC
    SendData8(0xff); // 21-bit BC
    SendData8(0xff); ///////////////////

    SendData8(0x00); // LED1: Blue MSB
    SendData8(0x00); // LED1: Blue LSB
    SendData8(0x00); // LED1: Green LSB
    SendData8(0x00); // LED1: Green LSB
    SendData8(0xff); // LED1: Red LSB
    SendData8(0xff); // LED1: Red LSB

    SendData8(0x00); // LED2: Blue MSB
    SendData8(0x00); // LED2: Blue LSB
    SendData8(0xff); // LED2: Green LSB
    SendData8(0xff); // LED2: Green LSB
    SendData8(0x00); // LED2: Red LSB
    SendData8(0x00); // LED2: Red LSB

    SendData8(0xff); // LED3: Blue MSB
    SendData8(0xff); // LED3: Blue LSB
    SendData8(0x00); // LED3: Green LSB
    SendData8(0x00); // LED3: Green LSB
    SendData8(0x00); // LED3: Red LSB
    SendData8(0x00); // LED3: Red LSB

    SendData8(0x00); // LED3: Blue MSB
    SendData8(0x00); // LED3: Blue LSB
    SendData8(0x00); // LED3: Green LSB
    SendData8(0x00); // LED3: Green LSB
    SendData8(0x00); // LED3: Red LSB
    SendData8(0x00); // LED3: Red LSB

    Hope this helps,

    Garrett

  • Thanks Garrett,

    So from your example, it looks as though I'm using the correct control/set-up bits but after power-up, I first need to run the 224-bit string with all the 24 data bytes =0 before the device will accept subsequent non-zero values for the data?

    Edward

  • Yes, give that a try.

    - Garrett

  • All fine and running now---- it helps not to connect the iref pin to ground!!! (this was the problem all along).

    Thanks for your help in confirming the start-up code.

    Regards

    Edward

  • hello Garret
    I have to drive 6 tlc5971 with a microcontroller Zilog implementing SPI.
    You can give me some advice?

    Best regards.

    Thanks

    gfranchi@alice.it

  • I'm driving 21 TLC5971 with a 8-bit micro-controller.  To give the controller some time to do other operations like interrupts or check for timers I backed the SPI clock down to under 1MHz.  The other thing to consider is the power distribution.  Ensure that your board/connectors can handle the current draw of the LED driver.  Hope this helps.

    - Garrett

  • Hi, thank you for the code. It is so useful. Can you help me please with this quote of code? I will be grateful if you can explain me why you do this.

    Cheers from Argentina.

    Thanks.

    if (test_bit(PORTA, SW)) {
    DATA_IN();

    }

  • Hello Franchi,

    I am working on a project to control LED driver TLC5971. Please could you kindly send me the code you have written, It will help me alot to save time.

    Kind regards

    Sidney
  • Hello Garrett,

    I am working on a project to control LED driver TLC5971. Please could you kindly send me the code you have written, It will help me alot to save time.

    Kind regards

    Sidney
  • Here is a pretty basic program to get started with.  Hope if helps.

    TLC5971.c
    //----------------------------------------------------------------------------
    // C main line
    //----------------------------------------------------------------------------
    
    #include <m8c.h>        // part specific constants and macros
    #include "PSoCAPI.h"    // PSoC API definitions for all User Modules
    #include <stdio.h>      // Standard functions
    
    // Configuration Functions
    void Configure_SPI(void);
    void Configure_ProcPorts(void);
    void Configure_TLC5971(void);
    
    // Delay Functions
    void Delay_ms(int x);
    void SixUsDelay(void);  // Used for programming LED Driver
    
    // Communication Functions
    void SendData32(int x);
    void SendData8(int x);
    void Program (int ctrl, int L1BG, int L1R2B, int L2GR, int L3BG, int L3R4B, int L4GR);
    
    // Individual constant light LED functions
    void Brown(void);
    void Orange(void);
    void White(void);
    void Yellow(void);
    void Violet(void);
    void Lime(void);
    void Cyan(void);
    
    void BLU2(void);
    void BLU2GRN2(void);
    void BLU2GRN4(void);
    void BLU2GRN6(void);
    void BLU2GRN8(void);
    void BLU2RED2(void);
    void BLU2RED4(void);
    void BLU2RED6(void);
    void BLU2RED8(void);
    void BLU4(void);
    void BLU4GRN2(void);
    void BLU4GRN4(void);
    void BLU4GRN6(void);
    void BLU4GRN8(void);
    void BLU4RED2(void);
    void BLU4RED4(void);
    void BLU4RED6(void);
    void BLU4RED8(void);
    void BLU6(void);
    void BLU6GRN2(void);
    void BLU6GRN4(void);
    void BLU6GRN6(void);
    void BLU6GRN8(void);
    void BLU6RED2(void);
    void BLU6RED4(void);
    void BLU6RED6(void);
    void BLU6RED8(void);
    void BLU8(void);
    void BLU8GRN2(void);
    void BLU8GRN4(void);
    void BLU8GRN6(void);
    void BLU8GRN8(void);
    void BLU8RED2(void);
    void BLU8RED4(void);
    void BLU8RED6(void);
    void BLU8RED8(void);
    void GRN2(void);
    void GRN2RED2(void);
    void GRN2RED4(void);
    void GRN2RED6(void);
    void GRN2RED8(void);
    void GRN4(void);
    void GRN4RED2(void);
    void GRN4RED4(void);
    void GRN4RED6(void);
    void GRN4RED8(void);
    void GRN6(void);
    void GRN6RED2(void);
    void GRN6RED4(void);
    void GRN6RED6(void);
    void GRN6RED8(void);
    void GRN8(void);
    void GRN8RED2(void);
    void GRN8RED4(void);
    void GRN8RED6(void);
    void GRN8RED8(void);
    void Off(void);
    void RED2(void);
    void RED4(void);
    void RED6(void);
    void RED8(void);
    
    // Multiple constant light LED functions
    void AllGreen(void);
    void AllWhite(void);
    void AllYellow(void);
    void AllBrown(void);
    void AllOff(void);
    void AllRed(void);
    
    void OrangeLimeCyanViolet(void);
    void RedGreenBlueOff(void);
    void OrangeYellowBrownViolet(void);
    
    void OrangeBrownBrownBrown(void);
    void BrownOrangeBrownBrown(void);
    void BrownBrownOrangeBrown(void);
    void BrownBrownBrownOrange(void);
    
    // LED light show functions
    void AllBlinkYellow(void);
    void AllFadeInBrown(void);
    void AllFadeOutBrown(void);
    void AllFadeOutYellow(void);
    void AllBrownOneOrangeToRight(void);
    void AllBrownOneOrangeToLeft(void);
    void AllBrownOneOrangeSlide(void);
    
    
    // Global Variables
    DELAY = 5000;
    long int DECODER = 0x25;     // bits 223-218 decoder: 6b'100101
    long int FC = 0x12;          // 5 bits
                                 //// bit 217 (OUTTMG): 1 OUTXn off/on rising edge, 0 OUTXn off/on falling edge
                                 //// bit 216 (EXTCLK): 1 SCKI GS clock, 0 internal GS clock 
                                 //// bit 215 (TMGRST): 1 enabled GS counter reset OUTXn off, 0 disabled
                                 //// bit 214 (DSPRPT): 1 enable auto display repeat, 0 disabled
                                 //// bit 213 (BLANK): 1 enable blanking, 0 disabled
    long int BC = 0x1FFFFF;      // 21 bits
                                 //// bit 212-206: BC data for blue
                                 //// bit 205-199: BC data for green
                                 //// bit 198-192: BC data for red
    int thirty_two = 32;
    int LED_CNT = 4;
    
    void main(void){
      // M8C_EnableGInt ;     // Uncomment this line to enable Global Interrupts
                              // Would be needed if using timer interrupt
     
      Configure_SPI();        // Configure SPI
      Configure_ProcPorts();  // Configure Ports for communcation
      Configure_TLC5971();    // Configure TLC5971
    
      while(1) {
      	AllBlinkYellow();
    	AllFadeInBrown();
    	AllBrownOneOrangeSlide();
    	AllFadeOutBrown();
      }
    }
    
    //-------------------------
    // Configuration Functions
    //-------------------------
    void Configure_SPI(void) {
      // SPIM_1_EnableInt();                                    /* Enable Interrupt */
      SPIM_1_Start(SPIM_1_SPIM_MODE_0 | SPIM_1_SPIM_MSB_FIRST);  //Set to mode 0 & shift MSB first
    	                                                         //Data changes on falling edge, rising
    															 //edge latches data
    }
    
    void Configure_ProcPorts(void){
      // Configure GPIO for strong output
      PRT2DM0 = 0x01;
      PRT2DM1 = 0x00;
      PRT2DM2 = 0x00;
    
      // Enable the differential driver, only needed for TLC5970 design
      PRT2DR = 0x01;
    }
    
    void Configure_TLC5971(void) {
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      
      SendData8(0x00);      // LED1: Blue MSB
      SendData8(0x00);      // LED1: Blue LSB
      SendData8(0x00);      // LED1: Green LSB
      SendData8(0x00);      // LED1: Green LSB
      SendData8(0x00);      // LED1: Red LSB
      SendData8(0x00);      // LED1: Red LSB
      
      SendData8(0x00);      // LED2: Blue MSB
      SendData8(0x00);      // LED2: Blue LSB
      SendData8(0x00);      // LED2: Green LSB
      SendData8(0x00);      // LED2: Green LSB
      SendData8(0x00);      // LED2: Red LSB
      SendData8(0x00);      // LED2: Red LSB
    
      SendData8(0x00);      // LED3: Blue MSB
      SendData8(0x00);      // LED3: Blue LSB
      SendData8(0x00);      // LED3: Green LSB
      SendData8(0x00);      // LED3: Green LSB
      SendData8(0x00);      // LED3: Red LSB
      SendData8(0x00);      // LED3: Red LSB
    
      SendData8(0x00);      // LED3: Blue MSB
      SendData8(0x00);      // LED3: Blue LSB
      SendData8(0x00);      // LED3: Green LSB
      SendData8(0x00);      // LED3: Green LSB
      SendData8(0x00);      // LED3: Red LSB
      SendData8(0x00);      // LED3: Red LSB
    }
    
    //-------------------------
    // Delay Functions
    //-------------------------
    void Delay_ms(int x){
      int y = 0;
      int z = 0;
    	
      while ( y < x ) {
        while ( z < 62 ) {   // This is is 1ms
    	  z++;
        }
        y++;
      }
    }
    
    void SixUsDelay(void){
      // SysClk = 24MHz
      // NOP takes 4 clock cycles
      // 6us = 1/24MHz * 4 * 32
    //  int y;
    //  for (y = 1; y<= 32; y++) {
    //    asm("NOP");
    //  }
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
      asm("NOP");
    }
    
    //-------------------------
    // Communication Functions
    //-------------------------
    void SendData32 (int x) {
      int y;
      while( ! (SPIM_1_bReadStatus() & SPIM_1_SPIM_TX_BUFFER_EMPTY ) );
      for (y = 24; y >= 0; y-=8){
        int program = x >> y;
    	x = x & 0xff;
    	SPIM_1_SendTxData(x);
      }
    }
    
    void SendData8 (int x) {
      int y;
      while( ! (SPIM_1_bReadStatus() & SPIM_1_SPIM_TX_BUFFER_EMPTY ) );
      SPIM_1_SendTxData(x);
    }
    
    void Program (int ctrl, int L1BG, int L1R2B, int L2GR, int L3BG, int L3R4B, int L4GR){
      SendData32(ctrl);
      SendData32(L1BG);
      SendData32(L1R2B);
      SendData32(L2GR);
      SendData32(L3BG);
      SendData32(L3R4B);
      SendData32(L4GR);
      Delay_ms(DELAY); // Time to shift data into latches
    }
    
    //-------------------------
    // Individual constant light LED functions
    //-------------------------
    void Brown(void){
      SendData8(0x10);      // Blue MSB
      SendData8(0x10);      // Blue LSB
      SendData8(0x45);      // Green LSB
      SendData8(0x45);      // Green LSB
      SendData8(0x8b);      // Red LSB
      SendData8(0x8b);      // Red LSB
    }
    void Orange(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x80);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void Violet(void){
      SendData8(0xff);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void Yellow(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void White(void){
      SendData8(0xff);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void Lime(void){
      SendData8(0x00);      // LED2: Blue MSB
      SendData8(0x00);      // LED2: Blue LSB
      SendData8(0xff);      // LED2: Green LSB
      SendData8(0xff);      // LED2: Green LSB
      SendData8(0x80);      // LED2: Red LSB
      SendData8(0x00);      // LED2: Red LSB
    }
    void Cyan(void){
      SendData8(0xff);      // LED3: Blue MSB
      SendData8(0xff);      // LED3: Blue LSB
      SendData8(0xff);      // LED3: Green LSB
      SendData8(0xff);      // LED3: Green LSB
      SendData8(0x00);      // LED3: Red LSB
      SendData8(0x00);      // LED3: Red LSB
    }
    void BLU2(void){
      SendData8(0x40);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU2GRN2(void){
      SendData8(0x40);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x40);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU2GRN4(void){
      SendData8(0x40);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x80);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU2GRN6(void){
      SendData8(0x40);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xbf);      // Green MSB
      SendData8(0xff);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU2GRN8(void){
      SendData8(0x40);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xff);      // Green MSB
      SendData8(0xff);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU2RED2(void){
      SendData8(0x40);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green MSB
      SendData8(0x00);      // Green LSB
      SendData8(0x40);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU2RED4(void){
      SendData8(0x40);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green MSB
      SendData8(0x00);      // Green LSB
      SendData8(0x80);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU2RED6(void){
      SendData8(0x40);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green MSB
      SendData8(0x00);      // Green LSB
      SendData8(0xbf);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void BLU2RED8(void){
      SendData8(0x40);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green MSB
      SendData8(0x00);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void BLU4(void){
      SendData8(0x80);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU4GRN2(void){
      SendData8(0x80);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x40);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU4GRN4(void){
      SendData8(0x80);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x80);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU4GRN6(void){
      SendData8(0x80);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green MSB
      SendData8(0x00);      // Green LSB
      SendData8(0xbf);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void BLU4GRN8(void){
      SendData8(0x80);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xff);      // Green MSB
      SendData8(0xff);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU4RED2(void){
      SendData8(0x80);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green MSB
      SendData8(0x00);      // Green LSB
      SendData8(0x40);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU4RED4(void){
      SendData8(0x80);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green MSB
      SendData8(0x00);      // Green LSB
      SendData8(0x80);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU4RED6(void){
      SendData8(0x80);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green MSB
      SendData8(0x00);      // Green LSB
      SendData8(0xbf);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void BLU4RED8(void){
      SendData8(0x80);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green MSB
      SendData8(0x00);      // Green LSB
      SendData8(0xff);      // Red MSB
      SendData8(0xff);      // Red LSB
    }
    void BLU6(void){
      SendData8(0xbf);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU6GRN2(void){
      SendData8(0xbf);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x40);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU6GRN4(void){
      SendData8(0xbf);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x80);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU6GRN6(void){
      SendData8(0xbf);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0xbf);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU6GRN8(void){
      SendData8(0xbf);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU6RED2(void){
      SendData8(0xbf);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x40);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU6RED4(void){
      SendData8(0xbf);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x80);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU6RED6(void){
      SendData8(0xbf);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xbf);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void BLU6RED8(void){
      SendData8(0xbf);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void BLU8(void){
      SendData8(0xff);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU8GRN2(void){
      SendData8(0xff);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x40);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU8GRN4(void){
      SendData8(0xff);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x80);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU8GRN6(void){
      SendData8(0xff);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0xbf);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU8GRN8(void){
      SendData8(0xff);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void BLU8RED2(void){
      SendData8(0xff);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x40);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU8RED4(void){
      SendData8(0xff);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x80);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void BLU8RED6(void){
      SendData8(0xff);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xbf);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void BLU8RED8(void){
      SendData8(0xff);      // Blue MSB
      SendData8(0xff);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void GRN2(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x40);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN2RED2(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x40);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x40);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN2RED4(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x40);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x80);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN2RED6(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x40);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xbf);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void GRN2RED8(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x40);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void GRN4(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x80);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN4RED2(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x80);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x40);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN4RED4(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x80);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x80);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN4RED6(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x80);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xbf);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void GRN4RED8(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x80);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void GRN6(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xbf);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN6RED2(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xbf);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0x40);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN6RED4(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xbf);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0x80);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN6RED6(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xbf);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xbf);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void GRN6RED8(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xbf);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void GRN8(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN8RED2(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0x40);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN8RED4(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0x80);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void GRN8RED6(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xbf);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void GRN8RED8(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void Off(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void RED2(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x40);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void RED4(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x80);      // Red LSB
      SendData8(0x00);      // Red LSB
    }
    void RED6(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xbf);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    void RED8(void){
      SendData8(0x00);      // Blue MSB
      SendData8(0x00);      // Blue LSB
      SendData8(0x00);      // Green LSB
      SendData8(0x00);      // Green LSB
      SendData8(0xff);      // Red LSB
      SendData8(0xff);      // Red LSB
    }
    
    //-------------------------
    // Multiple constant light LED functions
    //-------------------------
    void RedGreenBlueOff(void){
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      
      RED8();
      GRN8();
      BLU8();
      Off();
    }
    void OrangeYellowBrownViolet(void){
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      
      Orange();
      Yellow();
      Violet();
      Brown();
    }
    void AllYellow(void){
      int y;
    
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      
      for (y =0; y < LED_CNT; y++) {
        Yellow();
      }
    }
    void AllBrown(void){
      int y;
    
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      
      for (y =0; y < LED_CNT; y++) {
    	Brown();
      }
    }
    void AllWhite(void){
      int y;
    
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      
      for (y =0; y < LED_CNT; y++) {
    	White();
      }
    }
    void AllOff(void){
      int y;
    
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      
      for (y =0; y < LED_CNT; y++) {
    	Off();
      }
    }
    
    void OrangeLimeCyanViolet(void){
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      
      Orange();
      Lime();
      Cyan();
      Violet();
    }
    void AllRed(void){
      int y;
    
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      
      for (y =0; y < LED_CNT; y++) {
    	RED8();
      }
    }
    void AllGreen(void){
      int y;
    
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      
      for (y =0; y < LED_CNT; y++) {
    	  GRN8();
      }
    }
    void OrangeBrownBrownBrown(void){
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      Orange();
      Brown();
      Brown();
      Brown();
    }
    void BrownOrangeBrownBrown(void){
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      Brown();
      Orange();
      Brown();
      Brown();
    }
    void BrownBrownOrangeBrown(void){
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      Brown();
      Brown();
      Orange();
      Brown();
    }
    void BrownBrownBrownOrange(void){
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      Brown();
      Brown();
      Brown();
      Orange();
    }
    
    //-------------------------
    // LED light show functions
    //-------------------------
    void AllBlinkYellow(void){
      int y = 10000;
      AllYellow();
      Delay_ms(y);
      AllFadeOutYellow();
      AllOff();
      Delay_ms(y);
      AllYellow();
      Delay_ms(y);
      AllFadeOutYellow();
      AllOff();
      Delay_ms(y);
      AllYellow();
      Delay_ms(y);
      AllFadeOutYellow();
      AllOff();
      Delay_ms(y);
      AllYellow();
      Delay_ms(y);
      AllFadeOutYellow();
      AllOff();
      Delay_ms(y);
      AllYellow();
      Delay_ms(y);
      AllFadeOutYellow();
      AllOff();
      Delay_ms(y);
      AllYellow();
      Delay_ms(y);
      AllFadeOutYellow();
      AllOff();
      Delay_ms(y);
    }
    
    void AllFadeInBrown(void){
      int y = 10000;
      AllOff();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x44);      // 5-bit FC
      SendData8(0x08);      // 21-bit BC
      SendData8(0x10);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x48);      // 5-bit FC
      SendData8(0x10);      // 21-bit BC
      SendData8(0x20);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x4c);      // 5-bit FC
      SendData8(0x18);      // 21-bit BC
      SendData8(0x30);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x50);      // 5-bit FC
      SendData8(0x20);      // 21-bit BC
      SendData8(0x40);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
    
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x54);      // 5-bit FC
      SendData8(0x28);      // 21-bit BC
      SendData8(0x50);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
    
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x58);      // 5-bit FC
      SendData8(0x30);      // 21-bit BC
      SendData8(0x60);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
    
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5c);      // 5-bit FC
      SendData8(0x38);      // 21-bit BC
      SendData8(0x70);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
    
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
    }
    
    void AllFadeOutBrown(void){
      int y = 10000;
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5c);      // 5-bit FC
      SendData8(0x38);      // 21-bit BC
      SendData8(0x70);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x58);      // 5-bit FC
      SendData8(0x30);      // 21-bit BC
      SendData8(0x60);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x54);      // 5-bit FC
      SendData8(0x28);      // 21-bit BC
      SendData8(0x50);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x50);      // 5-bit FC
      SendData8(0x20);      // 21-bit BC
      SendData8(0x40);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x4c);      // 5-bit FC
      SendData8(0x18);      // 21-bit BC
      SendData8(0x30);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x48);      // 5-bit FC
      SendData8(0x10);      // 21-bit BC
      SendData8(0x20);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x44);      // 5-bit FC
      SendData8(0x08);      // 21-bit BC
      SendData8(0x10);      ///////////////////
      Brown();
      Brown();
      Brown();
      Brown();
      Delay_ms(y);
      
      AllOff();
      Delay_ms(y);
    }
    
    void AllFadeOutYellow(void){
      int y = 6000;
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5f);      // 5-bit FC
      SendData8(0xff);      // 21-bit BC
      SendData8(0xff);      ///////////////////
      Yellow();
      Yellow();
      Yellow();
      Yellow();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x5c);      // 5-bit FC
      SendData8(0x38);      // 21-bit BC
      SendData8(0x70);      ///////////////////
      Yellow();
      Yellow();
      Yellow();
      Yellow();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x58);      // 5-bit FC
      SendData8(0x30);      // 21-bit BC
      SendData8(0x60);      ///////////////////
      Yellow();
      Yellow();
      Yellow();
      Yellow();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x54);      // 5-bit FC
      SendData8(0x28);      // 21-bit BC
      SendData8(0x50);      ///////////////////
      Yellow();
      Yellow();
      Yellow();
      Yellow();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x50);      // 5-bit FC
      SendData8(0x20);      // 21-bit BC
      SendData8(0x40);      ///////////////////
      Yellow();
      Yellow();
      Yellow();
      Yellow();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x4c);      // 5-bit FC
      SendData8(0x18);      // 21-bit BC
      SendData8(0x30);      ///////////////////
      Yellow();
      Yellow();
      Yellow();
      Yellow();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x48);      // 5-bit FC
      SendData8(0x10);      // 21-bit BC
      SendData8(0x20);      ///////////////////
      Yellow();
      Yellow();
      Yellow();
      Yellow();
      Delay_ms(y);
      
      SendData8(0x96);      // 6-bit Decoder
      SendData8(0x44);      // 5-bit FC
      SendData8(0x08);      // 21-bit BC
      SendData8(0x10);      ///////////////////
      Yellow();
      Yellow();
      Yellow();
      Yellow();
      Delay_ms(y);
      
      AllOff();
      Delay_ms(y);
    }
    
    void AllBrownOneOrangeToRight(void){
      int y = 18000;
    
      OrangeBrownBrownBrown();
      Delay_ms(y);
    
      BrownOrangeBrownBrown();
      Delay_ms(y);
    
      BrownBrownOrangeBrown();
      Delay_ms(y);
    
      BrownBrownBrownOrange();
      Delay_ms(y);
    }
    
    void AllBrownOneOrangeToLeft(void){
      int y = 18000;
    
      BrownBrownBrownOrange();
      Delay_ms(y);
    
      BrownBrownOrangeBrown();
      Delay_ms(y);
    
      BrownOrangeBrownBrown();
      Delay_ms(y);
    
      OrangeBrownBrownBrown();  
      Delay_ms(y);
    }
    
    void AllBrownOneOrangeSlide(void){
      int y = 18000;
      AllBrown();
      Delay_ms(y);
      
      AllBrownOneOrangeToRight();
      Delay_ms(y);
      
      AllBrown();
      Delay_ms(y);
      
      AllBrownOneOrangeToLeft();
      Delay_ms(y);
    
      AllBrown();
      Delay_ms(y);
      
      AllBrownOneOrangeToRight();
      Delay_ms(y);
      
      AllBrown();
      Delay_ms(y);
    }
    

  • Please how did you arrive at the value of ~5.24us , because 8*250ns = 2us. If 1.34us is added to this value it give 3.34us NOT 5.24us. May be I am getting confused here. My SCKI runs at 12.5MHz what should i use for the minimum latch timing from the last SCKI?
  • I have attached here the codes for controlling TLC5971 using Atmega1284p microcontroller. Please I would appreciate if I can get some feedback.

    #include "usartSPI.h"
    #include "tlc5971_poecie.h"
    #include <avr/io.h>
    
    
    // this struct is implementation dependent on packing and endian.
    struct TLC5971 {
    	uint16_t GS[4][3];
    	uint8_t BCB:7;
    	uint8_t BCG:7;
    	uint8_t BCR:7;
    	uint8_t BLANK:1;
    	uint8_t DSPRPT:1;
    	uint8_t TMGRST:1;
    	uint8_t EXTGCK:1;
    	uint8_t OUTTMG:1;
    	uint8_t cmd:6;
    } tlc5971;
    
    void tlc5971_init()
    {
    	tlc5971.BLANK = 1;
    	tlc5971.DSPRPT = 0;
    	tlc5971.TMGRST = 1;
    	tlc5971.EXTGCK = 1;
    	tlc5971.OUTTMG = 0;
    	tlc5971.BCR = 127;
    	tlc5971.BCG = 127;
    	tlc5971.BCB = 127;
    }
    
    
    void sendBits(void)
    {
    	uint8_t n; 
    	uint8_t	*p = (uint8_t*)&tlc5971;
    	
    	for (n = 28; n-- > 0; )
    	{
    		usartSPI_transfer(p[n]);
    	}
    	_delay_us(3);
    }
    
    
    int main(void)
    {
    	tlc5971_init();
    	tlc5971.cmd = 0x25;
    	tlc5971.TMGRST = 1;
    	tlc5971.DSPRPT = 1;
    	tlc5971.BCR = 127;
    	tlc5971.BCR = 0;
    	tlc5971.BCB = 20;
    	tlc5971.GS[0][BLUE] = 0xAAAA;	// 1010 1010 1010 1010
    	tlc5971.GS[3][RED] = 0x5555;	// 0101 0101 0101 0101
    	
    	usartSPI_init();
    	
    	while(1)
    	{
    		CS_lo();
    		sendBits();
    		CS_hi();
    	}
    }

  • Hello Garrett,

    Thanks for the code. Please can you explain to me the function of this piece of code. what is the use of the for loop?

    void DATA_IN_3()
    {
    
    	for (i=0;i<=64865;i++)
    	{
    		PORTC=0x00;    // EXTCLK
    		PORTC=0x02;    // 
    	}
    
    	WRT_CMD();
    	Func_Data();  
    	BC_Data_#1();
    	GS_Data_#1();
    	
    	WRT_CMD();
    	Func_Data();  
    	BC_Data_#2();
    	GS_Data_#2();
    	
    	WRT_CMD();
    	Func_Data();  
    	BC_Data_#3();
    	GS_Data_#3();
    
    	DelaymS(3); //3ms wait time
    
    }
    

  • I am using Atmega1284p microcontroller with T_CPU of 12.5MHz with a baud rate of 921600, but when I use a logic analyzer to get the signal, the logic analyzer show a frequency of shows 49.6KHz for the SPI. I was expecting a frequency of 921.600KHz. Please is my thinking correct?

    Then what should be my timing gap? I am using 5us now

  • This is prototyping code.  I'm just toggling a LED using PORTC.

  • Thank Garrett,

    I am using Atmega1284p microcontroller with T_CPU of 12.5MHz with a baud rate of 921600, but when I use a logic analyzer to get the signal, the logic analyzer show a frequency of shows 49.6KHz for the SPI. I was expecting a frequency of 921.600KHz. Please is my thinking correct?

    Then what should be my timing gap? I am using 5us now

  • Why 96h is send as MSB instead of 25h.