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.

TLC59731: SPI C-Code not working

Part Number: TLC59731
Other Parts Discussed in Thread: TLC5973

Hello,

I just need a simple code example to get one single TLC59731 going.

As I understand I just need to send for bytes via SPI:

void set_rgb_led(signed int8 red, signed int8 green, signed int8 blue)
  {
  spi_write(0x3a); // init
  spi_write(red); // red
  spi_write(green); // green
  spi_write(blue); // blue
  }

But this does actually work somehow: when I continuosly write values from a counter into the RGB values the LEDs turn sometimes on and off.

But I am not able to have any control.

So what is missing or wrong?

  • Hi Michael,
    Could you post what the data you send out with the waveform?
    Thanks!
    Summer
  • I just got it:

    unsigned int16 pTime = 1; // in useconds
    void writeRgbZero() { output_high(rgb_out); delay_us(pTime); output_low(rgb_out); delay_us(pTime); delay_us(pTime); delay_us(pTime); delay_us(pTime); delay_us(pTime); } void writeRgbOne() { output_high(rgb_out); delay_us(pTime); output_low(rgb_out); delay_us(pTime); delay_us(pTime); output_high(rgb_out); delay_us(pTime); output_low(rgb_out); delay_us(pTime); delay_us(pTime); } void writeRgData(unsigned int8 data) { if (bit_test(data,7)) writeRgbOne(); else writeRgbZero(); if (bit_test(data,6)) writeRgbOne(); else writeRgbZero(); if (bit_test(data,5)) writeRgbOne(); else writeRgbZero(); if (bit_test(data,4)) writeRgbOne(); else writeRgbZero(); if (bit_test(data,3)) writeRgbOne(); else writeRgbZero(); if (bit_test(data,2)) writeRgbOne(); else writeRgbZero(); if (bit_test(data,1)) writeRgbOne(); else writeRgbZero(); if (bit_test(data,0)) writeRgbOne(); else writeRgbZero(); } void set_rgb_led(signed int8 red, signed int8 green, signed int8 blue) { writeRgbZero(); writeRgbZero(); writeRgbOne(); writeRgbOne(); writeRgbOne(); writeRgbZero(); writeRgbOne(); writeRgbZero(); writeRgData(red); // red writeRgData(green); // green writeRgData(blue); // blue delay_us(pTime); delay_us(pTime); delay_us(pTime); delay_us(pTime); }

    Some sample code would be very helpful in adition to the datasheet.....

  • Hi Micheal,

        I am sorry we have no sample code in the hand, but could you download sample code from ti outside.

    hackster.io/alpcaner92/tlc5973-led-driver-msp432-with-bluetooth-02d2ad becasue there is free project with MSP432 and TLC5973.

    Any more concern please let me know, thanks!

    Summer

  • Hi Michael,

    I'll close this thread due to inactivity.

    You can reply to this thread directly if you have more questions and it will open again.

    If you think this helps, please click "Resolve".

    Thanks.
    Regards,
    Kenneth