Some pins for these I/O ports are multiplexed with an alternate function for the peripheral features on the device.
In general, when a peripheral is enabled, that pin may not be used as a general purpose I/O pin.
3.1 PORTA and the TRISA Register PORTA is a 6-bit wide, bi-directional port.
The corresponding data direction register is TRISA.
Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode).
Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an output (i.e., put the contents of the output latch on the selected pin).
Reading the PORTA register reads the status of the pins, whereas writing to it will write to the port latch. All write operations are read-modify-write operations.
Therefore, a write to a port implies that the port pins are read, the value is modified and then written to the port data latch.
Pin RA4 is multiplexed with the Timer0 module clock input to become the RA4/T0CKI pin.
The RA4/T0CKI pin is a Schmitt Trigger input and an open drain output.
All other PORTA pins have TTL input levels and full CMOS output drivers.
Other PORTA pins are multiplexed with analog inputs and analog VREF input. The operation of each pin is selected by clearing/setting the control bits in the
ADCON1 register (A/D Control Register1).
The TRISA register controls the direction of the RA pins, even when they are being used as analog inputs.
The user must ensure the bits in the TRISA register are maintained set when using them as analog inputs.
Note: On a Power-on Reset, these pins are configured
as analog inputs and read as '0'.
3.2 PORTB and the TRISB Register
PORTB is an 8-bit wide, bi-directional port.
The corresponding data direction register is TRISB.
Setting a TRISB bit (= 1) will make the corresponding PORTB pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISB bit (= 0) will make the corresponding PORTB pin an output (i.e., put the contents of the output latch on the selected pin).
Three pins of PORTB are multiplexed with the Low Voltage Programming function: RB3/PGM, RB6/PGC and RB7/PGD.
The alternate functions of these pins are described in the Special Features Section.
Each of the PORTB pins has a weak internal pull-up.
A single control bit can turn on all the pull-ups. This is performed
by clearing bit RBPU (OPTION_REG<7>).
The weak pull-up is automatically turned off when the port
pin is configured as an output.
The pull-ups are disabled on a Power-on Reset.