ShiftPWM support topic. Latest update: Schematics, high power LED's, LED strips

:slight_smile: You can do bit shift in C with >> and << operator!
int X;
X = 0x1; // hex
X = X << 2; // move bits 2 places left
or
X = X >> 7; // moves bits 7 bits right

But I really think you can just use XOR and AND instructions togheter to achive bit change for each one of 8 bits inside the serialized word. I use this a lot with PIC (sorry, I used to program in ASM pic and now using arduino too)

You can use A,B,C,D as variables that control each bit time (like on time).
and aa,bb,cc,dd as as timer variable for each pin
A,B,C and aa,bb,cc may be nibbles, this way you can store 2 information peer byte.

byte counter;
if(counter == 0){
resetAllPins and send out();
fillZeroAll aa,bb,cc,dd counters;
send_ZERO_DataToSPI and SET START BIT at SPI
}else{
(aa XOR counter)? out = out AND aaPinBit // if they are equal, them result is ZERO and so i change the pinBit
(bb XOR counter)? out = out AND bbPinBit //
sendDataToSPI and SET START BIT at SPI
}
counter ++;
if (counter >100) counter =0; // reset counter - I supose use 100 levels for each PWM out, but you can use less; that depend of
// int frequency and what you want

Surely you have to create a for loop to change all the 8 bits
Also you have to create a simple way to generate aaPinBit, bbPinBit, ccPinBit, and so on, but
there are some elegant way to do this.
I this you can achive good results.
You maybe dont need to use BIT ROT operators (>> and <<)
Pehaps to create the __PinBin you should use (>> <<);
but i supose that will be better to use some pre-calculated data that create __PinBit and take care of witch bit you are using with reference to witch of the ~500 out that you are testing.
YOu can achive great performance with ASM. Dont get woried about it.
It is easy after you get in touch. And you will enjoy the results!
Sorry my poor english.
Good luck.
I realy delight with your work.
With is you blog or page?