I have a bit-addressable var (ibase) that I am loading with a value and then rotating--placing the msb on an I/O pin (SData). The SData pin never changes--it stays high. What am I doing wrong? Thanks!
for(i=0;i<8;i++) { SClock = 0; SData = ibase^7; ibase = _irol_(ibase,1); delay(); SClock = 1; timer0_delay(5); }
Wow, thanks! That did it. So that I don't continue to suffer in ignorance, just what did that do? (I understand the 0x80 mask, but what about the ? 1 : 0 syntax)?
Thanks.
This line:
SData = ibase^7;
doesn't do what you think. You've fallen into the somewhat common trap of believing that the
sbit var=bitvar^bitno
syntax extends to all expressions involving bit-addressable variables. Well, it doesn't. You need something along the lines of
SData = (ibase & 0x80) ? 1 : 0;
View all questions in Keil forum