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.

TLC6C5716-Q1: Need Sample code for TLC6C5716-Q1

Part Number: TLC6C5716-Q1

Hi Team,

I am working on TLC6C5716-Q1 communication to micro via SPI. Is there any reference guide/ sample code/ fit data documents available to Kick start the project.

  • Hi Sumit,

    our expert is on the business trip and she will replay once back to the office.

    BR

    Monet Xu

  • Hi Simit,

    You could refer to this:

    TLC6C5716-Q1 EVM Programming.pptx

    BR, Gracie

  • Hi Gracie,
    Sorry for the late reply i was on vacation and thanks for the support. 
    i am not able to relate page 3 and 4 of the ppt you have shared. can you please help me out bit more on it.

  • Hi Sumit,

    It's just the procedure of starting this LED driver. You may refer to the datasheet to see each command and that should be matching the log detail in page 4.

    BR, Gracie

  • Hi Gracie,

    Please share any sample code if you have.

  • Hi sumit,

    I will reply to you later. Actually its just written as the slides.

    BR, Gracie

  • /* --COPYRIGHT--,BSD
     * Copyright (c) 2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     * --/COPYRIGHT--*/
    /******************************************************************************
     * MSP432 Empty Project
     *
     * Description: An empty project that uses DriverLib
     *
     *                MSP432P401
     *             ------------------
     *         /|\|                  |--
     *          | |              P5.0|--GSLAT
     *          --|RST               |--
     *            |              P5.2|--BLNK
     *     GSSIN--|P3.5          P4.3|--GSCKR/G/B
     *          --|              |--
     *     GSSCK--|P3.7              |--
     *          --|                  |--
     * Author: 
     *******************************************************************************/
    /* DriverLib Includes */
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    static volatile uint32_t aclk, mclk, smclk, hsmclk, bclk;
    
    #define CPU_F ((double)25000000)
    
    #define delay_us(x) __delay_cycles((long)(CPU_F*(double)x/1000000.0))
    #define delay_ms(x) __delay_cycles((long)(CPU_F*(double)x/1000.0))
    
    char DCdata0[]={
                    0x00,0x00,0x00,//R0 G0 B0
                    0x00,0x00,0x00,//R1 G1 B1
                    0x00,0x00,0x00,//R2 G2 B2
                    0x00,0x00,0x00,//R3 G3 B3
                    0x00,0x00,0x00,//R4 G4 B4
                    0x00,0x00,0x00,//R5 G5 B5
                    0x00,0x00,0x00,//R6 G6 B6
                    0x00,0x00,0x00,//R7 G7 B7
    };
    char DCdata1[]={
                    0xff,0xff,0xff,//R0 G0 B0
                    0xff,0xff,0xff,//R1 G1 B1
                    0xff,0xff,0xff,//R2 G2 B2
                    0xff,0xff,0xff,//R3 G3 B3
                    0xff,0xff,0xff,//R4 G4 B4
                    0xff,0xff,0xff,//R5 G5 B5
                    0xff,0xff,0xff,//R6 G6 B6
                    0xff,0xff,0xff,//R7 G7 B7
    };
    
    int GSdata0[]={
                   0x000,0x000,0x000,//R0 G0 B0
                   0x000,0x000,0x000,//R1 G1 B1
                   0x000,0x000,0x000,//R2 G2 B2
                   0x000,0x000,0x000,//R3 G3 B3
                   0x000,0x000,0x000,//R4 G4 B4
                   0x000,0x000,0x000,//R5 G5 B5
                   0x000,0x000,0x000,//R6 G6 B6
                   0x000,0x000,0x000,//R7 G7 B7
    };
    int GSdata1[]={
                   0xfff,0xfff,0xfff,//R0 G0 B0
                   0xfff,0xfff,0xfff,//R1 G1 B1
                   0xfff,0xfff,0xfff,//R2 G2 B2
                   0xfff,0xfff,0xfff,//R3 G3 B3
                   0xfff,0xfff,0xfff,//R4 G4 B4
                   0xfff,0xfff,0xfff,//R5 G5 B5
                   0xfff,0xfff,0xfff,//R6 G6 B6
                   0xfff,0xfff,0xfff,//R7 G7 B7
    };
    
    void SendDCData(int CMD, int UD, char GS_MODE, char DSTMR, char ADSRPM, char DC_Range_Blue, char DC_Range_Green, char DC_Range_Red, char BCB, char BCG, char BCR, char *DCdata)//Send DC/BC/FC data thru GS Data Path
    {
        GPIO_setOutputHighOnPin(GPIO_PORT_P5,GPIO_PIN0 ); //LATCH-High for DC Mode
        int k,temp1,temp2;
        /*Command Code BITS 287-276*/
        for(k=287;k>=276;k--)
        {
            temp1=1<<(k-276);
            temp2=CMD&temp1;
            if(temp2==temp1)
            {
                GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
            }
            else
            {
                GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
            }
            //GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
            __delay_cycles(6);
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        }
        /*No Value BITS 275-216*/
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
        for(k=275;k>=216;k--)
        {
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
            __delay_cycles(6);
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        }
        /*User Define BITS 215-199*/
        for(k=215;k>=199;k--)
        {
            temp1=1<<(k-199);
            temp2=UD&temp1;
            if(temp2==temp1)
            {
                GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
            }
            else
            {
                GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
            }
            //GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
            __delay_cycles(6);
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        }
        /*GS Counter Mode BITS 198-197*/
        for(k=198;k>=197;k--)
        {
            temp1=1<<(k-197);
            temp2=GS_MODE&temp1;
            if(temp2==temp1)
            {
                GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
            }
            else
            {
                GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
            }
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
            __delay_cycles(6);
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        }
        /*Display Timing Reset Mode BITS 196*/
        if(DSTMR==1)
        {
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
        }
        else
        {
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
        }
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
        __delay_cycles(6);
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        /*Auto Display Repeat Mode BITS 195*/
        if(ADSRPM==1)
        {
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
        }
        else
        {
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
        }
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
        __delay_cycles(6);
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        /*Dot correction adjustment range for the BLUE color output BITS 194*/
        if(DC_Range_Blue==1)
        {
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
        }
        else
        {
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
        }
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
        __delay_cycles(6);
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        /*Dot correction adjustment range for the GREEN color output BITS 193*/
        if(DC_Range_Green==1)
        {
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
        }
        else
        {
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
        }
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
        __delay_cycles(6);
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        /*Dot correction adjustment range for the RED color output BITS 192*/
        if(DC_Range_Red==1)
        {
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
        }
        else
        {
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI- Low
        }
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
        __delay_cycles(6);
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        /*Global Brightness Control Blue BITS 191-184*/
        for(k=191;k>=184;k--)
        {
            temp1=1<<(k-184);
            temp2=BCB&temp1;
            if(temp2==temp1)
            {
                GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
            }
            else
            {
                GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
            }
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
            __delay_cycles(6);
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        }
        /*Global Brightness Control Green BITS 183-176*/
        for(k=183;k>=176;k--)
        {
            temp1=1<<(k-176);
            temp2=BCG&temp1;
            if(temp2==temp1)
            {
                GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
            }
            else
            {
                GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
            }
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SDI-Low
            __delay_cycles(6);
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        }
        /*Global Brightness Control Red BITS 175-168*/
        for(k=175;k>=168;k--)
        {
            temp1=1<<(k-168);
            temp2=BCR&temp1;
            if(temp2==temp1)
            {
                GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
            }
            else
            {
                GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
            }
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
            __delay_cycles(6);
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        }
        /*Dot Correction Data BITS 167-0*/
        for(k=167;k>=0;k--)
        {
            temp1=1<<(k%7);
            temp2=DCdata[k/7]&temp1;
            if(temp2==temp1)
            {
                GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
            }
            else
            {
                GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
            }
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
            __delay_cycles(6);
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        }
    
        GPIO_setOutputLowOnPin(GPIO_PORT_P5,GPIO_PIN0 ); //LATCH-Low
        __delay_cycles(6);
        GPIO_setOutputHighOnPin(GPIO_PORT_P5,GPIO_PIN0);//LATCH-High
        __delay_cycles(6);
    }
    
    void SendGSData(int *temp)// Send Gray Scale data
    {
        GPIO_setOutputLowOnPin(GPIO_PORT_P5,GPIO_PIN0 ); //GSLAT-Low for GS Mode
        int k,temp1,temp2;
        for(k=287;k>=0;k--)
        {
            temp1=1<<(k%12);
            temp2=temp[k/12]&temp1;
            if(temp2==temp1)
            {
                GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - High
            }
            else
            {
                GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5);//SDI - Low
            }
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
            __delay_cycles(6);
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-High
        }
    
        //GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7);//SCK-Low
    
        GPIO_setOutputHighOnPin(GPIO_PORT_P5,GPIO_PIN0);//LATCH-High
        __delay_cycles(6);
        GPIO_setOutputLowOnPin(GPIO_PORT_P5,GPIO_PIN0 ); //LATCH-Low
        __delay_cycles(6);
    }
    
    int main(void)
    
    {
        MAP_WDT_A_holdTimer();
        /* Setting the DCO Frequency to a non-standard 8.33MHz */
        // MAP_CS_setDCOFrequency(8330000);
    
        /* Initializing the clock source as follows:
         *      MCLK = MODOSC/4 = 6MHz
         *      ACLK = REFO/2 = 16kHz
         *      HSMCLK = DCO/2 = 1.5Mhz
         *      SMCLK = DCO/4 = 750kHz
         *      BCLK  = REFO = 32kHz
         */
        MAP_CS_initClockSignal(CS_MCLK, CS_MODOSC_SELECT, CS_CLOCK_DIVIDER_128);  //MODOSC:Internal low-power oscillator with 25-MHz typical frequency
        MAP_CS_initClockSignal(CS_ACLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_2);
        MAP_CS_initClockSignal(CS_HSMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_2);
        MAP_CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_4);
        MAP_CS_initClockSignal(CS_BCLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1);
        /*
         *  Getting all of the frequency values of the CLK sources using the
         * convenience functions */
        aclk = CS_getACLK();
        mclk = CS_getMCLK();
        smclk = CS_getSMCLK();
        hsmclk = CS_getHSMCLK();
        bclk = CS_getBCLK();
    
        GPIO_setAsOutputPin(GPIO_PORT_P3, GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setAsOutputPin(GPIO_PORT_P5, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2);
        GPIO_setOutputLowOnPin(GPIO_PORT_P3, GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
        GPIO_setOutputLowOnPin(GPIO_PORT_P5, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2);
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P4,GPIO_PIN3,GPIO_PRIMARY_MODULE_FUNCTION);
    
        GPIO_setOutputHighOnPin(GPIO_PORT_P5, GPIO_PIN2);
        /*SendDCData(double CMD, int UD, char GS_MODE, char DSTMR, char ADSRPM, char DC_Range_Blue, char DC_Range_Green, char DC_Range_Red, char BCB, char BCG, char BCR, char *DCdata)*/
    
        while(1)
        {
            SendDCData(0, 0x3, 0x00, 0, 1, 0, 0, 0, 10, 10, 10, DCdata1);
            SendGSData(GSdata1);
            delay_ms(80);
        }
    
    
        //SendDCData(0, 3, 0x00, 0, 1, 0, 0, 0, 0, 0, 0, DCdata0);
        /*while(1)
        {
            delay_ms(10);
            SendDCData(0x53A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, DCdata0);
            delay_ms(10);
        }*/
    
    }
    
    
    
    Hi Sumit,

    Pls see attached.

    BR, Gracie

  • Hi Gracie,
    Thanks for the sample code, but i am not getting how the LEDs are being controlled using these two functions. Please brief it, it will be very helpful.

  • Hi Sumit,

    What's your application of this device? The end equipment? one or daisy chain?

    And could you elaborate which 2 functions?

    This LED driver is a sires interface, common shift register to transfer the brightness (GS data) and store the control data.

    BR, Gracie 

  • Hi Gracie,
    the 2 function i am talking about is the SendDCData() & SendGSData().

    The end equipment is, i have a Microcontroller which is connected to only one TLC6C5716-Q1 via SPI to control 10 LEDs.  

  • Hi, Sumit

    Our expert is out of office and will reply you on Thursday.

  • Hi Sumit,

    Basically you need to send DC data to the corresponding location 

    You can see at start, you need to configure to low 205-bit FC-BC-DC Data in the 288-bit shift register. It's the initial setting. And then you can send GS data to refresh the brightness.

    BR, Gracie

  • Hi Gracie,

    Thanks for your continuous support, please clarify one last question.

    Q1. //Send DC/BC/FC data thru GS Data Path............ you can find this comment at line no. 104 of the software you have provided. what does GS data path mean, is it sending data thru SendGSData() function? according to my understanding we software is sending FC BC DC data thru SendDCData().

    Q2. In function SendDCData() how to set the values of these arguments  "char DC_Range_Blue, char DC_Range_Green, char DC_Range_Red, char BCB, char BCG, char BCR,"  please let me know where can i find it i am using TLC6C5716-Q1 Automotive 16-Channel, Full Diagnostics, Constant-Current LED Driver document for reference.

    Thanks,

    Sumit

  • Hi sumit,

    I will feedback to you later.

    BR, Gracie

  • Hi Sumit,

    Sorry for replying late. I was on sick leave..

    I didn't see any conflicts here.

    GS_mode is defined in sendDCdata() because GS_mode could be selected 8/10/12 bit for the resolution.

    The GS data is in sendGSdtata.

    BR, Gracie