Would you not want to shift out the upper byte first? I could be misinterpreting your setup.
Ask Electronics
For questions about component-level electronic circuits, tools and equipment.
Rules
1: Be nice.
2: Be on-topic (eg: Electronic, not electrical).
3: No commercial stuff, buying, selling or valuations.
4: Be safe.
You're probably right, but that should only change the order of the outputs right?
What does shiftDataOut do? You loop over it but you give the whole byte to it anyway in each loop.
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 just bitwise and it resulting in the same thing. For example, starting with input_bin
:
1000 0000 0000 0000
>> 8
0000 0000 1000 0000
& 0xFF
0000 0000 1000 0000
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_value = 0b1
for i = 1 to 16:
latch(low)
shift_out(output_value)
latch(high)
output_value = output_value << 1
That is, if I interpereted correctly that you want the shift registers to output the following:
output_count, upper_shift_register, lower_shift_register
1, 00000000, 00000001
2, 00000000, 00000010
3, 00000000, 00000100
.
.
.
16, 10000000, 00000000
Note: Lemmy has a bug where it doesn't format some symbols correctly, so the left angle bracket gets formatted as <
. The same issue exists for the right angle bracket, the ampersand, and I would presume others.
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;