-
TLC5916 Configuration Code Setting

TLC5916 Writing Config Code The TLC5916 data sheet clearly shows that you write the configuration code (which controls the LED current) by shifting seven bits in, then raising LE during the 8th SCK pulse while simultaneously shifting the 8th bit.
That makes no sense whatsoever: you couldn’t use standard SPI hardware in a chained configuration, because you’d have to blip LE while shifting.
In fact, the chip doesn’t work that way. You set the config code in Special Mode just like you set the LED driver bits in Normal Mode: shift ’em all in, then blip LE to latch ’em into the parallel holding register.
Here’s the code to make it happen…
DisableSPI(); // manual SPI control digitalWrite(PIN_DISABLE_DISPLAY,HIGH); // initial condition digitalWrite(PIN_LATCH_DO,LOW); PulsePin(PIN_SCK); // 1 digitalWrite(PIN_DISABLE_DISPLAY,LOW); PulsePin(PIN_SCK); // 2 digitalWrite(PIN_DISABLE_DISPLAY,HIGH); PulsePin(PIN_SCK); // 3 digitalWrite(PIN_LATCH_DO,HIGH); // sets Special Mode PulsePin(PIN_SCK); // 4 digitalWrite(PIN_LATCH_DO,LOW); PulsePin(PIN_SCK); // 5 //-- Send brightness level EnableSPI(); // turn on SPI hardware SendRecSPI(Brightness); SendRecSPI(Brightness); SendRecSPI(Brightness); SendRecSPI(Brightness); SendRecSPI(Brightness); PulsePin(PIN_LATCH_DO); // latch new shift reg contents into drivers //-- put LED drivers back in Normal Mode DisableSPI(); digitalWrite(PIN_DISABLE_DISPLAY,HIGH); // initial condition digitalWrite(PIN_LATCH_DO,LOW); PulsePin(PIN_SCK); // 1 digitalWrite(PIN_DISABLE_DISPLAY,LOW); PulsePin(PIN_SCK); // 2 digitalWrite(PIN_DISABLE_DISPLAY,HIGH); PulsePin(PIN_SCK); // 3 digitalWrite(PIN_LATCH_DO,LOW); // sets Normal Mode PulsePin(PIN_SCK); // 4 digitalWrite(PIN_LATCH_DO,LOW); PulsePin(PIN_SCK); // 5 digitalWrite(PIN_DISABLE_DISPLAY,LOW); // turn the LEDs on again
The SendRecSPI() function does exactly what you’d expect:
byte SendRecSPI(byte Dbyte) { // send one byte, get another in exchange SPDR = Dbyte; // assume it's OK to send a new byte while (! (SPSR & (1 << SPIF))) { // wait for shift to finish continue; } return SPDR; // SPIF will be cleared }I don’t know. Maybe the chip also works the way they show in the datasheet, but I doubt it’s worth finding out.