I read a while back that to prevent flickering while updating the Adafruit TCL5947 and to permit smooth fading, the /OE and LAT pins should simply be tied together. I can confirm that this does work perfectly, but there is another issue. I would like to make sure that the output of the 5947 is disabled at power up. With the pins connected, all of the LEDs flash on full for about a second from powerup until initialized in setup().
My first attempt at a solution (attached schematic) was to hold the 5947 /OE pin high with a PNP transistor until setup() sets Arduino pin 7 to HIGH which switches the transistor off. The idea was to disconnect OE from +5v, allowing it to then follow the LAT pin to prevent flicker.
It all works as expected except for there is now a very quick, bright flash as soon as the Arduino pin 7 goes high. I have confirmed that this has to do with the LAT pin being tied to OE. With OE straight to the transistor's emitter and LAT going straight to Arduino pin 6, the output disabling on startup works as expected, but the fade/flicker issue is back in the 5947.
Does anyone know of a different solution? It's fine if it requires additional components. I think that what I am trying to accomplish is to hold the /OE pin high at powerup, then switch it over to being "connected" to the latch pin during setup().
#include "Adafruit_TLC5947.h"
#define NUM_TLC5947 1
#define data 4
#define clock 5
#define latch 6
#define oe 7
Adafruit_TLC5947 tlc = Adafruit_TLC5947(NUM_TLC5947, clock, data, latch);
void setup() {
// Note that the output-enable pin of the 5947 is held high at power up
tlc.begin();
// make sure all outputs are initialized to 0
for (uint8_t i = 0; i < 24; i++) {
tlc.setPWM(i, 0);
}
tlc.write();
// wait just in case
delay(100);
// enable output - inverted since we're hitting the base of a PNP transistor. HIGH disconnects OE from +5v
pinMode(oe, OUTPUT);
digitalWrite(oe, HIGH);
// another just-in-case hail-mary delay
delay(100);
// TEST: fade in from dark.
for (uint16_t j = 0; j < 4096; j+=10) {
for (uint8_t i = 0; i < 24; i++) {
tlc.setPWM(i, j);
}
tlc.write();
delay(1);
}
}