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. Additional information on I/O ports may be found in the PIC® Mid-Range Reference Manual (DS33023).
1. PORTA and the TRISA Register
PORTA is a 6-bit wide, bidirectional port. The corresponding data direction register is TRISA(Transport and Rceive Index Storage). Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e., put the corresponding output driver in a High-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 the analog VREF input for both the A/D converters and the comparators. The operation of each pin is selected by clearing/setting the appropriate control bits in the ADCON1 and/or CMCON registers.
Note: On a Power-on Reset, these pins are configured as analog inputs and read as ‘0’. The comparators are in the off (digital) state.
The TRISA register controls the direction of the port 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.
TABLE 4-1: PORTA FUNCTIONS
Name | Bit# | Buffer | Function |
---|---|---|---|
RA0/AN0 | bit 0 | TTL | Input/output or analog input. |
RA1/AN1 | bit 1 | TTL | Input/output or analog input. |
RA2/AN2/VREF-/CVREF | bit 2 | TTL | Input/output or analog input or VREF- or CVREF. |
RA3/AN3/VREF+ | bit 3 | TTL | Input/output or analog input or VREF+. |
RA4/T0CKI/C1OUT | bit 4 | ST | Input/output or external clock input for Timer0 or comparator output. Output is open-drain type. |
RA5/AN4/SS/C2OUT | bit 5 | TTL | Input/output or analog input or slave select input for synchronous serial port or comparator output. |
Legend: TTL = TTL input, ST = Schmitt Trigger input
2. PORTB and the TRISB Register
PORTB is an 8-bit wide, bidirectional 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 High-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).
5. PORTE and TRISE Register
PORTE has three pins (RE0/RD/AN5, RE1/WR/AN6 and RE2/CS/AN7) which are individually configurable as inputs or outputs. These pins have Schmitt Trigger input buffers.
The PORTE pins become the I/O control inputs for the microprocessor port when bit PSPMODE (TRISE<4>) is set. In this mode, the user must make certain that the TRISE<2:0> bits are set and that the pins are configured as digital inputs. Also, ensure that ADCON1 is config- ured for digital I/O. In this mode, the input buffers are TTL.
Register 4-1 shows the TRISE register which also controls the Parallel Slave Port operation.
PORTE pins are multiplexed with analog inputs. When selected for analog input, these pins will read as ‘0’s.
TRISE controls the direction of the RE pins, even when they are being used as analog inputs. The user must make sure to keep the pins configured as inputs when using them as analog inputs.
Note: On a Power-on Reset, these pins are configured as analog inputs and read as ‘0’.