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.

TLC5958: sample code

Part Number: TLC5958

Hi,

I started working on TLC5958 Led Driver . I have read the datasheet of the 48 channel TLC5958 but it doesn't provide any software information.

Kindly provide me the sample code of TLC5958 as soon as possible .Its urgent for us. 

Thanks.

Regards,

Twinkle

  • Hi, Twinkle,

    I would recommand you to take a look about TLC59581, which is an update of TLC5958.

    Except for the datasheet, there's also an application report for how to use this part.

    TLC5958 also has such kind of application report:

    And here is a simple code for TLC59581, just for your reference.

    TLC59581 Sample Code.zip

    If you think this answers your question, please help to click "Resolve".

    Thanks.

    Regards,

    Kenneth

  • Hi,Kenneth

    i have written a code for TLC 5958  just like the sample code you provided. First i sending the GS data then the Vertical Synchronization (Vsync) Command but still i  am not getting any data  either on  OUT pins or SOUT pin. i am attaching the snapshot of GS data and vsync command . 

    Image Discription:

    Yellow --> SIN

    Blue-->SCLK

    pink -->LAT

    GSdata waveform  :

     

    Vertical Synchronization (Vsync) Command waveform :

    can you check the waveform and tell me what i am doing wrong .

    Thanks.

    Regards,

    Twinkle

  • Hi,Kenneth

    i have written a code for TLC5958 as the sample code you have provided. In code  first i am sending the data than the Vertical Synchronization (Vsync) Command. but still I am not getting any output either on OUT pins or on SOUT pin . i am attaching the waveform of  data and the command .

    Image Discription

    yellow -- SIN

    blue -- SCLK

    pink --LAT

    Data waveform :

    Command Waveform ;

    Can you please take a look at a waveform and tell me what i am doing wrong.

    Thanks.

    Regards,

    Twinkle

  • Hi, Twinkle,

    From your first figure, do you send 0 to GS data latch?

    Thanks.
    Regards,
    Kenneth
  • Hi, Kenneth

    Yes, I am sending 0 to GS data latch and after that i am sending a Vertical Synchronization (Vsync) Command. but all OUT pins are showing High(1) output. Do i need to send any other signal to see the desired output on OUT pins.

    Thanks.
    Regards,
    Twinkle
  • Hi, Twinkle,

    You need to send GS data to turn on the channels.

    Please try to send GS=0xFFFF(or some value not 0) for each channel to test.

    Please let me know if this solves your problem.
    Thanks.
    Regards,
    Kenneth
  • Hi, Kenneth

    i have sent GS=0xFFFF and other values for each channel but not getting the desired output. I am also sending the GCLK signal .
    can you tell me more about the GCLK and when to send it
  • Hi, Twinkle,

    For a quick test, you can send continous GCLK after Vsync. 

    But from your description, it seems this doesn't work?

    For more details about GCLK please refer to the application report chapter 3.

    Please also make sure the WRTGS just contain one SCLK rising edge and you input 16 times 48 bit data.

    Thanks.

    Regards,

    Kenneth

  • Hi, Kenneth

    I am sending WRTGS command 16 times with 48 bit data. than I am sending the Data to display at LAT falling edge. and after that i am sending vsync comamnd than giving GCLK continuously after 2.5 us delay. but not getting the desired Output. I have checked everything. The sample code that you provided is it working on any board.?  because i have tried to do that way too but it's not working. I am not able to control TLC5958 LED driver. I have checked the waveform of Vsync command and  WRTGS command and both seems ok as the information provided in application Report . but i am not able to control any OUT pins of 5958. If you have any other sample code that is working on any LED Driver Board please send me .

    Thanks.

    Regards,

    Twinkle  

  • Hi, kenneth

    Please provide me the example code of TLC 5958 for SPI communication. I want to communicate with TLC 5958 through SPI but there are so many limitations of SCLK and LAT in TLC5958 so please send me the sample code for SPI communication.
  • Hi, Twinkle ,

    We don't have the sample code for TLC5958.

    Please refer to the code of TLC59581 since they are quite similar.

    Thanks.
    Regards,
    Kenneth
  • Hi, kenneth

    The sample code that you provided is not working as I am not able to Control any OUT pins. I have sent you the waveform and told my issues . can you please tell me what i am doing wrong. and if the TLC59581 has the SPI interface than Provide me the Sample code for SPI communication  too.  

    Thanks

    Regards,

    Twinkle

  • Hi, Twinkle,

    Sorry but we don't have SPI code currently.

    Would you attach your code for me to take a look?

    Thanks.
    Regards,
    Kenneth
  • 12127.main.c
    
    #include "asf.h"
    #include "stdio_serial.h"
    #include "conf_uart_serial.h"
    
    
    
    
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    static struct usart_module cdc_uart_module;
    
    static void configure_console(void)
    {
    	struct usart_config usart_conf;
    
    	usart_get_config_defaults(&usart_conf);
    	usart_conf.mux_setting = CONF_STDIO_MUX_SETTING;
    	usart_conf.pinmux_pad0 = CONF_STDIO_PINMUX_PAD0;
    	usart_conf.pinmux_pad1 = CONF_STDIO_PINMUX_PAD1;
    	usart_conf.pinmux_pad2 = CONF_STDIO_PINMUX_PAD2;
    	usart_conf.pinmux_pad3 = CONF_STDIO_PINMUX_PAD3;
    	usart_conf.baudrate    = CONF_STDIO_BAUDRATE;
    
    	stdio_serial_init(&cdc_uart_module, CONF_STDIO_USART_MODULE, &usart_conf);
    	usart_enable(&cdc_uart_module);
    }
    
    void TLC5958_init()
    {
    	struct port_config pin;
    	port_get_config_defaults(&pin);
    	pin.direction = PORT_PIN_DIR_OUTPUT;	//Set pin direction as output 
    	port_pin_set_config(PIN_PA18, &pin);    //for sin
    	port_pin_set_config(PIN_PA19, &pin);    //for sclk
    	port_pin_set_config(PIN_PA22, &pin);	//for LAT
    	port_pin_set_config(PIN_PA23, &pin);	//for GCLK
    	//	port_pin_set_config(PIN_PA13, &pin);
    	//	port_pin_set_config(PIN_PB23, &pin);	//Enable
    }
    
    
    
    
    void SIN(char i)
    {
    	if(i==0)  port_pin_set_output_level(PIN_PA18,0);	//SIN LOW
    	else   port_pin_set_output_level(PIN_PA18,1);		//SIN high
    }
    
    void SCLK(char i)
    {
    	if(i==0)  port_pin_set_output_level(PIN_PA19,0);	//SCLK LOW
    	else    port_pin_set_output_level(PIN_PA19,1);		//SCLK High
    }
    
    void LAT(char i)
    {
    	if(i==0)  port_pin_set_output_level(PIN_PA22,0);	//LAT low
    	else   port_pin_set_output_level(PIN_PA22,1);		//LAT High 
    }
    
    
    void GLKc(char i)
    {
    	if(i==0)  port_pin_set_output_level(PIN_PA23,0);		//GLK Low								
    	else  port_pin_set_output_level(PIN_PA23,1);	//GCLK high
    }
    
    
    void send_data_48channel_command(uint16_t *temp)
    {   
    	uint16_t temp1,temp2;
    	LAT(0);			//LAT low
    	for(int k=47;k>=0;k--)
    	{
    		//if(k==0)
    		//LAT(1);
    		
    		temp1=1<<(k%16);
    		temp2=temp[k/16]&temp1;
    		if(temp2==temp1)
    		SIN(1);			//Send Data 
    		else
    		SIN(0);			//send Data
    		
    		SCLK(0);		//SCLK-low
    		delay_cycles(6);
    		SCLK(1);		//SCLK-high
    		if(k==1)	//check value for WRTGS command 
    		LAT(1);		//LAT-high
    	}
    	SCLK(0);		//SCLK-low
    	delay_cycles(6);
    	LAT(0);			//LAT-low
    }
    
    
    void SendVsyncData()
    {
    	int k;
    	LAT(0);			//LAT-low
    	for(k=47;k>=3;k--)
    	{
    		SIN(1);		//SIN high
    		SCLK(0);	//SCLK low
    		delay_cycles(6);
    		SCLK(1);	//SCLK-high
    	}
    	SCLK(0);		//SCLK-low
    	
    	LAT(1);			//LAT- high
    	for(k=2;k>=0;k--)
    	{
    		SIN(1);		//send SIN as high 
    		SCLK(0);	//SCLK - low
    		delay_cycles(6);
    		SCLK(1);	//SCLK-high
    	}
    	SCLK(0);		//SCLK-low
    
    	LAT(0);			//LAT-low
    
    }
    
    
    
    
    
    
    
    
    
    
    
    int main(void)
    {
    
    	system_init();
    	//configure_console();
    	delay_init();
    	TLC5958_init();
    	uint16_t buffer[]={0b0000111100001111,0b0000000000000000, 0b1111111111111111};
    	while(1)
    	{
    				
    		//GLKc(1);
    		for(int i=0;i<16;i++)
    		send_data_48channel_command(buffer);
    		SendVsyncData();             
    		
    		/**** Send GCLK continuously 257 times ******/
    		delay_us(2.5);
    		for(int i=0;i<257;i++)
    		{
    		GLKc(1);
    		GLKc(0);
    		delay_us(1);
    		}                      
    	
    	}
    }
    #ifdef __cplusplus
    }
    #endif
    
    Hi kenneth,

    I am attaching my source code main that have all the information.please check the code and tell me what i am doing wrong.

    Thanks

    Regards

    Twinkle

  • Hi, Twinkle,

    Would you please modify part of the code as following?

    int main(void)
    {

    system_init();
    //configure_console();
    delay_init();
    TLC5958_init();
    uint16_t buffer[]={0b0000111100001111,0b0000000000000000, 0b1111111111111111};

    for(int i=0;i<16;i++)
    {send_data_48channel_command(buffer);}
    SendVsyncData();

    while(1)
    {
    GLKc(1);
    GLKc(0);
    }
    }

    Please let me know if this solves your problem.
    Thanks.
    Regards,
    Kenneth
  • Hi kenneth,
    I modified my code just like you said and given the gclk continuously in while 1 loop . but still i am not getting the desired output on OUT pins that i have send from SIN my all OUT pins are high . can you please tell me if there is any other problem in my code.

    Thanks.
    with Regards
    Twinkle
  • Hi, Twinkle,

    That's very strange.

    Would you provide your schematic and the waveform of the SCLK/SIN/LAT/ GCLK for the whole GS data write period and the last WRTGS zoom in figure?

    Let me take a look and see where is wrong.

    Sorry again for the trouble you meet now.

    Thanks.
    Regards,
    Kenneth
  • Hi kenneth,

    I am attaching the waveform of SCLK /LAT/SIN/GCLK . 

    This is the waveform when i  am sending data on LAT falling edge.

    This is the waveform of WRTGS command.

    After sending the GS data 16 times i am sending the vsync command .the wave form of the command is :

    after that i have tried to send GCLK 257 times or in  a while(1) loop as you said but not getting the desired output on OUT pins in both conditions .

    I am also attaching the snapshots of the schematics .

    Diagram 1:

    Diagram 2 :

    Diagram 3:

    please check the wave-forms and tell me if i am doing anything wrong . 

    Thanks

    Regards

    Twinkle

  • Hi, Twinkle,

    One thing please help to check:

    Is there 17 LAT signal in the red square block?

    For the schematic, I'm not able to see it clear.

    But it seems you are using multiplexing. So how so you control the line control IC? Do you test whether the line control MOSFET turns ON?

    Thanks.

    Regards,

    Kenneth

  • Hi Kenneth,

    Yes,there are 17 latch signals, 16 for GS data & WRTGS command and 1 for Vsync command(as you mentioned in your sample code).

    Line control Ic  is getting its input from out pins of TLC5958,Mosfet IC is switching correctly when checked it individually but to check its switching in the board we need output at 48 channel driver IC,that is TLC5958,WE are unable to get desired output on TLC5958 out pins.We have already checked output on OUT pins by Multi-meter but,not getting desired output.

    Thanking You,

    Regards,

    Twinkle

  • Hi, Twinkle,

    I'm curious about "Line control Ic  is getting its input from out pins of TLC5958".

    I would suggest you to remove everything connected to OUT channels, and just add a resistor like 200ohm or an LED to Vled like 5V.

    Then test the OUT to see if there is desired output.

    Thanks.

    Regards,

    Kenneth

  • Hi Kenneth,

    I have removed everything connected to OUT channels and just added an LED to OUT channel but still not getting the output on OUT pins. i have checked the waveform of SOUT pin it is same as SIN but i ma unable to trigger OUT channels of TLC5958.

    Thanks

    Regards.

    Twinkle

  • Hi, Twinkle,

    I double check about the code by driving TLC5958 and there's no problem.

    The OUT can be turned ON/OFF as expected.

    Please help to check your hardware to make sure everything is good.

    Thanks.
    Regards,
    Kenneth