I think you got and and or switched, first two lines should be fine for shifting the top 8 bits down.
Comment on Shift register missing bits
Kalcifer@lemm.ee 1 year ago
The first two lines of the for loop,
byte upper_byte = input_bin >> 8; byte lower_byte = input_bin & 0x00FF;
don’t really accomplish anything. The first line is bit shifting to the right 8, and then you write over that with all 1s. For example, starting with input_bin
:
1000 0000 0000 0000 >> 8 0000 0000 1000 0000 & 0xFF 0000 0000 1111 1111
So, every time you go through a cycle of the for loop, you’ll just start with the same values in upper_byte
, and lower_byte
. To sequentially output each shifted value, you’ll instead want something like:
output = 0b1 for i = 0 to 17: shift_out(output) latch(high) output = output << 1
mvirts@lemmy.world 1 year ago
Kalcifer@lemm.ee 1 year ago
I don’t follow what you mean.
FuzzChef@feddit.de 1 year ago
I think what he refers to is that you seem to do a xor operation for the second line instead of the logical and.
Kalcifer@lemm.ee 1 year ago
2nd line of what?
mvirts@lemmy.world 1 year ago
Yes that’s what I was thinking
quiescentcurrent@discuss.tchncs.de 1 year ago
You’re 100% right, I’ve lost ‘i’ somewhere in my debugging process
byte upper_byte = input_bin >> (8+i) ; byte lower_byte = (input_bin >> i) & 0x00FF;