- PIC has five ports.
- Port A, Port B, Port C, Port D, Port E.
- PIC is an 8bit.
- Port pins can be accessed 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 in this way.
- P0_3=1; (High) // Port 0-3rd pin
- P0_4=0; (Low) // Port 0-4th pin
- In byte instruction we have to access entire port pins.
In port 0 all pin should keep low.
- P0 = 0x00;
0x 0 | 0 ; = 0x00.
- In port 0 MSB should keep high and LSB should keep low.
0x F | 0 ; = 0xF0.
- To access the port pin as an input and output we need to config microcontroller registers.
- We need to set the direction for pins by using the TRIS register.
- Port A Pins is accessed as output then TRISA=0x00.
- Port A Pins is accessed as input then TRISA=0xFF.