This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Direct bit I/O

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);
}

Parents
  • But you are actually wrong on several accounts.

    The sentence "Better continue with the C classes." was not designed to be denigrating.

    You did use the xor construct, missing the meaning of ^ when used in a C expression, as in contrast to the Keil extension of declaring bit variables.

    And no, you did not several posts up said that you understood the concept.

    You did say:
    "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."

    That must be read as relating to the ternary operator.

    After having received a quick lesson about the ternary operator, you answered with "Got it--nice shorthand. Thanks."

    Still no mention that you understood the ^ operator.

    So, since only the ternary operator was described, I thought that I could be nice - yes, as in helpful - and continue what Dan Henry and And Neil started by describing the meaning of the xor operator.

    I realize that "Better continue with the C classes" can be read as "You should continue with...", but if you think about it again, it can also be read as: "Since we are describing C functionality, let's continue by describing this construct, that you are also having troubles with."

    It is always dangerous to start throwing punches around, unless you are really, really sure what you are doing.

Reply
  • But you are actually wrong on several accounts.

    The sentence "Better continue with the C classes." was not designed to be denigrating.

    You did use the xor construct, missing the meaning of ^ when used in a C expression, as in contrast to the Keil extension of declaring bit variables.

    And no, you did not several posts up said that you understood the concept.

    You did say:
    "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."

    That must be read as relating to the ternary operator.

    After having received a quick lesson about the ternary operator, you answered with "Got it--nice shorthand. Thanks."

    Still no mention that you understood the ^ operator.

    So, since only the ternary operator was described, I thought that I could be nice - yes, as in helpful - and continue what Dan Henry and And Neil started by describing the meaning of the xor operator.

    I realize that "Better continue with the C classes" can be read as "You should continue with...", but if you think about it again, it can also be read as: "Since we are describing C functionality, let's continue by describing this construct, that you are also having troubles with."

    It is always dangerous to start throwing punches around, unless you are really, really sure what you are doing.

Children
  • Not really throwing punches; I expressed my gratitude to all--you too. Obviously, I am a neophyte on the HL side of embedded programming, or I would not have asked such an (for you) elementary question. I didn't just take the OPs suggestion and paste it, but also wanted to know _how_ it worked. The reason that I said that I thought the classes reference was gratutitous, was that my inexperience was implicit in such a fundamental question. Of course I need to learn more. Anyway, thanks again for a more complete explanation--it all helps!