8051 have four ports
- They are Port 0, Port 1, Port 2, Port 3.
- 8051 is a 8bit.
- Port pins can be access by.
- Bit instruction.
- Byte instruction.
- In bit instruction each port pins value assigned individually.
- In port0 3rd pin should keep high and 4th pin should keep low it can be done by this way.
- P0_3=1; (High) // Port 0 3rd pin:
- P0_4=0; (Low) // Port 0 4th pin:
- Byte instruction is use to access entire port pins.
Example In port 0 all pin should keep low. P0=0x00; 0x0000|0000; 0x 0 | 0 = 0x00. In port 0 MSB should be high and LSB should be low P0=0xF0; 0x1111|0000; 0x F | 0 = 0xF0.