Im using a speciality driver IC, the HV5122. Its basically a high voltage, 32-output shift register. (imagine a 32bit 595 shift register).
I'm chaining a few of these.
In the first place, i used a function like this
void setOutputs(unsigned long firstValue, ){
digitalWrite(OE, LOW); //Disable Outputs to prevent flicker
for ( unsigned long i=0; i<32; i++){
digitalWrite(DATA, bitRead(firstValue,i)); //Select postion to Read and set state
digitalWrite(CLK, HIGH); // Set Clock Pin High,
digitalWrite(CLK,LOW); // Set Clock Pin Low
}
digitalWrite(OE, HIGH); //Enable Outputs
}
this took about 500 microseconds to shift 32bits out, wich was way to slow, making the output flicker.
i modifed the code to not use digitalWrite and directly set the output by
PORTE |= _BV(PE4)
This worked for two chained of these.
Now i starting to worry, if i chain about 10 of these, which would result in 320bit to shift out.
I know that the SPI connection does something in form of "shift", it has a clock and data line.
Is it possible to use the SPI pins SCK and MOSI for this?