# Setting MSB high on an STP08CP05 (LED driver) turns off all LEDs

I am using an Arduino UNO to control a STP08CP05 - an 8 bit LED driver that has a shift register that allows it to be controlled with an SPI interface: A clock (CLK) pin and a data (SDI) pin.

There is also a latch input, which 'copies' the 8 bits from the shift register to an output array, I think. There's also an output enable pin that is always set low (to enable the output permanently.)

The problem:

If the first bit that is written to the chip while clocking in the 8 bits (in my case the MSB) is set high (on) then all the LEDS turn off. If the MSB bit is low, then the 7 other bits work fine (the correct 7 LEDs light up correctly etc.) The problem is the strange behaviour around the MSB.

Why do all the LEDs turn off if the first bit sent (the MSB) is high?

Here is the code using the SPI library:

#include <SPI.h>
void setup() {
pinMode(10, OUTPUT); //LE control
SPI.begin();
//I've tried changing the SPI mode, etc. I think MODE0 is correct here.
SPI.beginTransaction(SPISettings(10000, MSBFIRST, SPI_MODE0));
}
void loop() {
while (1) {
SPI.transfer(64); //sets 2nd to last LED (works), but (128) won't work.
digitalWrite(10,HIGH); //Toggle LE pin
digitalWrite(10,LOW);
delay(100);
}
}


To try to understand the problem I switched to clocking in the data programmatically (avoiding the library,) but this just reproduces the same problem:

void setup() {
const int clockPin = 13;
const int MOSIPin = 11;
pinMode(10, OUTPUT);
pinMode(MOSIPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}

void loop() {
const int clockPin = 13;
const int MOSIPin = 11;
while (1) {
for (int n = 0;n<8;n++) {
digitalWrite(clockPin,LOW);
int out;
//this sets the 2nd to last LED (this works) but if it was (n==0) it won't work.
if (n==1) { out=HIGH; } else { out=LOW; }
digitalWrite(MOSIPin,out);
digitalWrite(clockPin,HIGH);
}
digitalWrite(clockPin,LOW);
digitalWrite(10,HIGH); //Toggle LE pin
digitalWrite(10,LOW);
delay(100);
}
}


Useful notes from the datasheet:

• Please post the schematics, and a photo of PCB or breadboard to see if what you built has errors or matches the original intention how it is supposed to be built. Sep 13, 2021 at 10:11
• Thanks Justme - I've reread my question, and your comment made me look at things again. Sorry to have wasted your time. Thanks so much for the help! Hopefully my answer will be useful for someone in the future who has the same, strange bug. Sep 13, 2021 at 20:31