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.

TLC5948A: I have some questions about TLC5948A.

Part Number: TLC5948A

Dear TI team:

     I have some questions about TLC5948A. thanks!

     1. How can we modify Grayscale control?  Is there a description of the relevant software process?

     2. Can you provide reference code or driver for reference?

  • Hi,

      you can first refer to the following

    TLC5948A_Sample Code.c
    /* --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
     *             ------------------
     *         /|\|                  |
     *          | |                  |
     *          --|RST               |
     *            |                  |
     *            |                  |
     *            |                  |
     *            |                  |
     *            |                  |
     * Author: 
    *******************************************************************************/
    /* DriverLib Includes */
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    #define uhar unsigned char
    #define uint unsigned int
    #define  PSMODE_0   0
    #define  OLDENA_0   0
    #define  OLDENA_1   1
    #define  IDMCUR_0   0
    #define  IDMCUR_1   1
    #define  IDMCUR_2   2
    #define  IDMCUR_3   3
    #define  IDMRPT_0   0
    #define  IDMRPT_1   1
    #define  IDMENA_0   0
    #define  IDMENA_1   1
    #define  LATTMG_0   0
    #define  LATTMG_1   1
    #define  LATTMG_2   2
    #define  LATTMG_3   3
    #define  LSDVLT_0   0
    #define  LSDVLT_1   1
    #define  LSDVLT_2   2
    #define  LSDVLT_3   3
    #define  LODVLT_0   0
    #define  LODVLT_1   1
    #define  LODVLT_2   2
    #define  LODVLT_3   3
    #define  ESPWM_0   0
    #define  ESPWM_1   1
    #define  TMGRST_0   0
    #define  TMGRST_1   1
    #define  DSPRPT_0   0
    #define  DSPRPT_1   1
    #define  BLANK_0   0
    #define  BLANK_1   1
    
    void SendControldata(char PSMODE_data,char OLDENA,char IDMCUR_data,char IDMRPT, char IDMENA, char LATTMG_data,char LSDVLT_data,char LODVLT_data,char ESPWM,char TMGRST,char DSPRPT,char BLANK,char BC_data,char *DC_data) //
    {
        int k;
        char temp1,temp2;
      //MSB is 1
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5 ); //MSB is 1 SDA
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
        __delay_cycles(6); //6/25M=240ns
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
      // no control data  [255:137]
        for(k=255;k>=137;k--)
         {
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );//SDA 1
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
            __delay_cycles(6); //6/25M=240ns
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
         }
        //PSMODE[136:134]  3bits
         for(k=136;k>=134;k--)
         {
             temp1=1<<(k-134);
             temp2=PSMODE_data&temp1;
             if(temp2==temp1)
                 {
                  GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=1
                 }
             else
                 {
                  GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=0
                  }
             GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
             __delay_cycles(6); //6/25M=240ns
             GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
         }
         //OLDENA is 1 or 0  133th bit
        if(OLDENA==0)
          {
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
          }//SDA 0
        else
          {
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5 );
          }//SDA 1
          GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
          __delay_cycles(6); //6/25M=240ns
          GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
       //IDMCUR[132:131]  2bits
         for(k=132;k>=131;k--)
             {
                 temp1=1<<(k-131);
                 temp2=IDMCUR_data&temp1;
                 if(temp2==temp1)
                     {
                      GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=1
                     }
                 else
                     {
                      GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=0
                      }
                 GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                 __delay_cycles(6); //6/25M=240ns
                 GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
             }
       //IDMRPT is 1 or 0   130th bit
        if(IDMRPT==0)
           {GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );}//SDA 0
        else
           {GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5 );}//SDA 1
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
        __delay_cycles(6); //6/25M=240ns
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
         //IDMENA is 1 or 0  129th bit
        if(IDMENA==0)
           {GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );}//SDA 0
        else
           {GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5 );}//SDA 1
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
        __delay_cycles(6); //6/25M=240ns
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
        //LATTMG[128:127]  2bits
          for(k=128;k>=127;k--)
              {
                  temp1=1<<(k-127);
                  temp2=LATTMG_data&temp1;
                  if(temp2==temp1)
                      {
                       GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=1
                      }
                  else
                      {
                       GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=0
                       }
                  GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                  __delay_cycles(6); //6/25M=240ns
                  GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
              }
          //LSDVLT[126:125]  2bits
          for(k=125;k>=126;k--)
              {
                  temp1=1<<(k-126);
                  temp2=LSDVLT_data&temp1;
                  if(temp2==temp1)
                      {
                       GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=1
                      }
                  else
                      {
                       GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=0
                       }
                  GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                  __delay_cycles(6); //6/25M=240ns
                  GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
              }
          //LODVLT[124:123]  2bits
          for(k=124;k>=123;k--)
              {
                  temp1=1<<(k-123);
                  temp2=LODVLT_data&temp1;
                  if(temp2==temp1)
                      {
                       GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=1
                      }
                  else
                      {
                       GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=0
                       }
                  GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                  __delay_cycles(6); //6/25M=240ns
                  GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
              }
           //ESPWM is 1 or 0  122th bit
        if(ESPWM==0)
           {GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );}//SDA 0
        else
           {GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5 );}//SDA 1
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
        __delay_cycles(6); //6/25M=240ns
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
          //TMGRST is 1 or 0   121th bit
        if(TMGRST==0)
           {GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );}//SDA 0
        else
           {GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);}//SDA 1
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
        __delay_cycles(6); //6/25M=240ns
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
         //DSPRPT is 1 or 0  120th bit
        if(DSPRPT==0)
           {GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );}//SDA 0
        else
           {GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);}//SDA 1
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
        __delay_cycles(6); //6/25M=240ns
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
        //BLANK is 1 or 0  119th bit
        if(BLANK==0)
           {GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );}//SDA 0
        else
           {GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);}//SDA 1
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
        __delay_cycles(6); //6/25M=240ns
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
        //send BC data[118:112]
        for(k=118;k>=112;k--)
          {
                  temp1=1<<(k-112);
                  temp2=BC_data&temp1;
                  if(temp2==temp1)
                    {
                      GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=1
                    }
                  else
                    {
                      GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=0
                    }
                  GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                  __delay_cycles(6); //6/25M=240ns
                  GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
            }
          //send DC data [111:0]  DCRn[7:0] DCGn[7:0] DCBn[7:0]
          for (k=111;k>=0;k--)
               {
                    temp1=1<<(k%7);
                    temp2=DC_data[k/7]&temp1;
                    if(temp2==temp1)
                              {
                             GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5); //SDA=1
                              }
                          else
                              {
                              GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 ); //SDA=0
                              }
                          GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                          __delay_cycles(6); //6/25M=240ns
                          GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
               }
       // __delay_cycles(6); //6/25M=240ns*/
       GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-low
      // __delay_cycles(1); //6/25M=240ns
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//XLAT-high
       __delay_cycles(6); //Twh1 XLAT high-level pulse width  6/25M=240ns
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7); //XLAT-low
    }
    
    void SendGSdata(int *temp) //
    {
        int k,temp1,temp2;
      //  Send MSB=0
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );// SIN=0
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
        __delay_cycles(6); //6/25M=240ns
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
      //  Send 0-767 bits data; each 16 bits is a channel GSpwm data
        for(k=255;k>=0;k--)
        {
            temp1=1<<(k%16);
            temp2=temp[k/16]&temp1;
            if(temp2==temp1)
               {GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN5);} //SIN=1
            else
               {GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );} //SIN=0
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
            __delay_cycles(6); //6/25M=240ns
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
        }
       //__delay_cycles(6); //6/25M=240ns*/
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-low
      // __delay_cycles(1); //6/25M=240ns
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN7);//XLAT-high
        __delay_cycles(6); //Twh1 XLAT high-level pulse width  6/25M=240ns
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN7 ); //XLAT-low
    }
    
    void readdata(int *temp)
    {
        int k;
       /* GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
        __delay_cycles(6); //6/25M=240ns
        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
        */
        for(k=255;k>=0;k--)
        {          GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
                   GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                   __delay_cycles(6); //6/25M=240ns
                   GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
                   temp[k/16]=(temp[k/16]<<1)|GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN2);
        }
    }
    void ReadSIDdata(char LOD1,char LOD2 ,char LSD1,char LSD2,char OLD1,char OLD2,char TEF,char PTW,char ISF)
    {
        int k;
       for(k=255;k>=248;k--)    //Reserved
           {
               GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
               GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
               __delay_cycles(6); //6/25M=240ns
               GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
            }
        for(k=247;k>=240;k--)   //LOD out8 to out15
        {
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
            __delay_cycles(6); //6/25M=240ns
            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
    
            LOD1=(LOD1<<1)|GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN2);
         }
        for(k=239;k>=232;k--)   //Reserved
              {
                  GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
                  GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                  __delay_cycles(6); //6/25M=240ns
                  GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
               }
        for(k=231;k>=224;k--)   //LOD out0 to out7
           {
               GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
               GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
               __delay_cycles(6); //6/25M=240ns
               GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
               LOD2=(LOD2<<1)|GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN2);
            }
        for(k=223;k>=216;k--)   //Reserved
                 {
                     GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
                     GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                     __delay_cycles(6); //6/25M=240ns
                     GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
                  }
        for(k=215;k>=208;k--)//LSD out8 to out15
           {
               GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
               GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
               __delay_cycles(6); //6/25M=240ns
               GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
               LSD1=(LSD1<<1)|GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN2);
            }
        for(k=207;k>=200;k--)   //Reserved
            {
                GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
                GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                __delay_cycles(6); //6/25M=240ns
                GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
              }
        for(k=199;k>=192;k--)   //LSD out0 to out7
               {
                   GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
                   GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                   __delay_cycles(6); //6/25M=240ns
                   GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
                   LSD2=LSD2<<1|GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN2);
                }
        for(k=191;k>=184;k--)   //Reserved
                {
                    GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
                    GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                    __delay_cycles(6); //6/25M=240ns
                    GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
                  }
        for(k=183;k>=176;k--)   //OLD out8 to out15
                   {
                       GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
                       GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                       __delay_cycles(6); //6/25M=240ns
                       GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
                      OLD1=OLD1<<1|GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN2);
                    }
        for(k=175;k>=168;k--)   //Reserved
                    {
                        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
                        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                        __delay_cycles(6); //6/25M=240ns
                        GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
                      }
        for(k=167;k>=160;k--)   //OLD out0 to out7
                       {
                           GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
                           GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                           __delay_cycles(6); //6/25M=240ns
                           GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
                          OLD2=OLD2<<1|GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN2);
                        }
        for(k=159;k>=152;k--)   //Reserved
                        {
                            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
                            GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
                            __delay_cycles(6); //6/25M=240ns
                            GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
                          }
    
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
        __delay_cycles(6); //6/25M=240ns
       GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
       TEF=TEF<<1|GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN2);
    
       GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
       GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
       __delay_cycles(6); //6/25M=240ns
       GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
       PTW=PTW<<1|GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN2);
    
       GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN5 );
       GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-Low
       __delay_cycles(6); //6/25M=240ns
       GPIO_setOutputHighOnPin(GPIO_PORT_P3,GPIO_PIN6);//SCL-high
       ISF=ISF<<1|GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN2);
    }
    
    int main(void)
    {
        //char LOD_1=0;char LOD_2=0;char LSD_1=0;char LSD_2=0;char OLD_1=0;char OLD_2=0;char TEF_1=0;char PTW_1=0;char ISF_1=0;
        char LOD3=0,LOD4=0,LSD3=0,LSD4=0,OLD3=0,OLD4=0,TEF1=0,PTW1=0,ISF1=0;
        int readdata1[16];
        char DC_data_1[]={0x0f,0x0f,0x0f,
                          0x0f,0x0f,0x0f,
                          0x0f,0x0f,0x0f,
                          0xff,0xff,0xff,
                          0xff,0xff,0xff,
                          0x0f};
        char BC_data_1=0x7f;
        int GS_data[]={ 0xffff,0xFFFF,0xFFFF,
                        0xffff,0xffff,0xffff,
                        0xffff,0xffff,0xffff,
                        0xffff,0xffff,0xffff,
                        0xffff,0xffff,0xffff,
                        0xffff};
        int GS_data_1[]={ 0x0000,0x0000,0x0fff,
                           0x0fff,0x0fff,0x0fff,
                           0x0fff,0x0fff,0x0fff,
                           0xffff,0xffff,0xffff,
                           0xffff,0xffff,0xffff,
                           0x0fff};
        int GS_data_2[]={ 0x0000,0x0000,0x0000,
                           0x0fff,0x0fff,0x0fff,
                           0x0fff,0x0fff,0x0fff,
                           0xffff,0xffff,0xffff,
                           0xffff,0xffff,0xffff,
                           0x0fff};
    
        /* Stop Watchdog  */
        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_1);  //MODOSC:Internal low-power oscillator with 25-MHz typical frequency
             MAP_CS_initClockSignal(CS_ACLK, CS_MODOSC_SELECT, CS_CLOCK_DIVIDER_1);
             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);
             GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
             GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
             GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2);
             GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0|GPIO_PIN1|GPIO_PIN2);
    
             GPIO_setAsOutputPin(GPIO_PORT_P3, GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);//P3.5 SIN P3.6 SCLK P3.7 XLAT
             GPIO_setOutputLowOnPin(GPIO_PORT_P3, GPIO_PIN5|GPIO_PIN6|GPIO_PIN7);
             //GPIO_setAsInputPinWithPullDownResistor(GPIO_PORT_P5, GPIO_PIN2);//
             GPIO_setAsInputPin(GPIO_PORT_P5, GPIO_PIN2);   //P5.2 SOUT
             GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P4,GPIO_PIN2|GPIO_PIN3,GPIO_PRIMARY_MODULE_FUNCTION);// P4.3->MCLK   P4.2->ACLK
             SendControldata(PSMODE_0,OLDENA_1,IDMCUR_0,IDMRPT_0, IDMENA_0, LATTMG_0,LSDVLT_0,LODVLT_0,ESPWM_0,TMGRST_1,DSPRPT_1,BLANK_0,BC_data_1,DC_data_1);
             SendGSdata(GS_data);
            // ReadSIDdata(LOD_1,LOD_2,LSD_1,LSD_2,OLD_1,OLD_2,TEF_1,PTW_1,ISF_1);
             //SendControldata( PSMODE_0,OLDENA_0,IDMCUR_0,IDMRPT_0, IDMENA_0, LATTMG_0,LSDVLT_0,LODVLT_0,ESPWM_0,TMGRST_0,DSPRPT_0,BLANK_1,BC_data_1,DC_data_1);
             //SendControldata( PSMODE_0,OLDENA_0,IDMCUR_0,IDMRPT_0, IDMENA_0, LATTMG_0,LSDVLT_0,LODVLT_0,ESPWM_0,TMGRST_0,DSPRPT_0,BLANK_0,BC_data_1,DC_data_1);
             /*__delay_cycles(60000000); //6/25M=240ns
             SendGSdata(GS_data_1);
             SendControldata( PSMODE_0,OLDENA_0,IDMCUR_0,IDMRPT_0, IDMENA_0, LATTMG_0,LSDVLT_0,LODVLT_0,ESPWM_0,TMGRST_0,DSPRPT_0,BLANK_1,BC_data_1,DC_data_1);
             SendControldata( PSMODE_0,OLDENA_0,IDMCUR_0,IDMRPT_0, IDMENA_0, LATTMG_0,LSDVLT_0,LODVLT_0,ESPWM_0,TMGRST_0,DSPRPT_0,BLANK_0,BC_data_1,DC_data_1);
             __delay_cycles(60000000); //6/25M=240ns
               //SendGSdata(GS_data_2);
                * */
    
        while(1)
        {
    
           // SendControldata( PSMODE_0,OLDENA_0,IDMCUR_0,IDMRPT_0, IDMENA_1, LATTMG_3,LSDVLT_0,LODVLT_0,ESPWM_0,TMGRST_1,DSPRPT_1,BLANK_0,BC_data_1,DC_data_1);
           SendGSdata(GS_data);
           SendGSdata(GS_data);
        //   __delay_cycles(60000);
    
           readdata(readdata1);
           if((readdata1[14]&0x0001)!=0)
                         {GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);}
                        else
                         {GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);}
                if((readdata1[14]&0x0002)!=0)
                  {GPIO_setOutputHighOnPin(GPIO_PORT_P2, GPIO_PIN0);}
                 else
                  {GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0);}
                if((readdata1[14]&0x0004)!=0)
                  {GPIO_setOutputHighOnPin(GPIO_PORT_P2, GPIO_PIN1);}
                 else
                  {GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN1);}
                if((readdata1[14]&0x0008)!=0)
                  {GPIO_setOutputHighOnPin(GPIO_PORT_P2, GPIO_PIN2);}
                 else
                  {GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN2);}
            /*SendGSdata(GS_data_1);
                   SendControldata( PSMODE_0,OLDENA_0,IDMCUR_0,IDMRPT_0, IDMENA_0, LATTMG_0,LSDVLT_0,LODVLT_0,ESPWM_0,TMGRST_0,DSPRPT_0,BLANK_1,BC_data_1,DC_data_1);
                   SendControldata( PSMODE_0,OLDENA_0,IDMCUR_0,IDMRPT_0, IDMENA_0, LATTMG_0,LSDVLT_0,LODVLT_0,ESPWM_0,TMGRST_0,DSPRPT_0,BLANK_0,BC_data_1,DC_data_1);
                   __delay_cycles(60000000); //6/25M=240ns
                   */
        }
    }
    
    .

  • Hi engineer,

        Do you have any more questions?

  • Dear Charles:

        No , thanks!

  • Hi engineer,

        OK, I will close this thread. Your "resolved" confirmation is preferred if you don't have any more questions.