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

Port Pin toggle

I wrote a code for to toggle the port that is given below
#include<reg51.h>

sbit CLOCK = P0^2;

void main()
{
while(1)
{

CLOCK = CLOCK^1;
}
}
its not toggling in the IDE please guide me
Mahesh

Parents
  • You can fine which is better.

    On any halfway sane compiler, the two bits of code should produce exactly the same assembly output.

    Dont see the size of the c file.

    But that's the whole point. Toggling a bit is simple enough that it can be put into one line of code instead of eight, ... unless you get paid by lines of code, in which case the first solution is to be preferred.

    Unnecessarily bloating the source code makes maintenance more difficult.

Reply
  • You can fine which is better.

    On any halfway sane compiler, the two bits of code should produce exactly the same assembly output.

    Dont see the size of the c file.

    But that's the whole point. Toggling a bit is simple enough that it can be put into one line of code instead of eight, ... unless you get paid by lines of code, in which case the first solution is to be preferred.

    Unnecessarily bloating the source code makes maintenance more difficult.

Children