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

about the sbit

Hi,

Why I cannot use P1^1 directly in source code if i didn't use sbit definition in Keil_C51?

Another thing is, how to implement the following function about the "dynamic bit" in Keil_c51 V6.02:

{
char count;
for(count=0; count<8; count++)
{ ...
P1^count = ...;
...
}
}

Thanks.

John

Parents
  • "Why I cannot use P1^1 directly in source code"

    Neither ANSI nor original K&R 'C' provides any notation to access the individual bits of a value; the sbit is Keil's own extension - and that's just the way they've decided to do it!

    Note that '^' is the 'C' Exclusive-Or operator.

    As you were instructed when you posted the message, please use the &ltpre&gt and &lt/pre&gt tags when posting code:

    { 
       char count;
       for(count=0; count<8; count++)
       { 
          ...
          P1^count = ...;
          ...
       }
    }

    No, you can't do that.
    You can't even do it in assembler.

    You'll have to either use a switch to select the appropriate bit, or shift & mask.

    It's been discussed before - use the search

Reply
  • "Why I cannot use P1^1 directly in source code"

    Neither ANSI nor original K&R 'C' provides any notation to access the individual bits of a value; the sbit is Keil's own extension - and that's just the way they've decided to do it!

    Note that '^' is the 'C' Exclusive-Or operator.

    As you were instructed when you posted the message, please use the &ltpre&gt and &lt/pre&gt tags when posting code:

    { 
       char count;
       for(count=0; count<8; count++)
       { 
          ...
          P1^count = ...;
          ...
       }
    }

    No, you can't do that.
    You can't even do it in assembler.

    You'll have to either use a switch to select the appropriate bit, or shift & mask.

    It's been discussed before - use the search

Children
No data