im using 8051 and had a problem writing a code to interface the LED using serial port interface.Im using the I/O controller.the problem is when i ON the LED it light all the 7 leds.There is 7 output port. i try to use a bitwise as to ON the LED of bit 0: if((c&0x01)=='0'){ OPORT=0x00;}
else if(c=='1') { OPORT=0xff; }
thanks
Yes, I'm aware of the bit-addressing in the 8051.
Note the specific sentence in the first post: "the problem is when i ON the LED it light all the 7 leds.There is 7 output port."
Then note that the OP used the declaration:
char xdata OPORT _at_ 0x0000;
and then performed assigns:
OPORT = 0xff;
or
OPORT = 0x00;
To my eyes, that doesn't look like an attempt at using bit-addressable variables - hence my comment about the general method to set or clear a bit.
I think that the OP code will need a number of refining steps, and I don't think it is a good idea to just post a complete rewrite of the code. Each single change to the code must be followed my an understanding why.
I feel that switching to bdata, sbit, overloading of the ^ operator etc is a separate step.