8.1 Parallel I/O (PIO) Ports

All port pins have 12 registers directly associated with their operation as digital I/Os. The Data Direction register (TRISx) determines whether the pin is an input or an output. If the data direction bit is a ‘1’, then the pin is an input.

All port pins are defined as inputs after a Reset.

PinFunction
Reads from the latch (LATx)Read the latch
Writes to the latchWrite the latch
Reads from the port (PORTx)Read the port pins
Writes to the port pinsWrite the latch

Any bit and its associated data and control registers that are not valid for a particular device are disabled. This means the corresponding LATx and TRISx registers, as well as the port pin, are read as zeros.

When a pin is shared with another peripheral or function that is defined as an input only, it is nevertheless regarded as a dedicated port because there is no other competing source of outputs. Table 8-1 shows the pin availability. Figure 8-1 shows the 5V input tolerant pins across this device.

Table 8-1. Pin and ANSELx Availability
DeviceRx15Rx14Rx13Rx12Rx11Rx10Rx9Rx8Rx7Rx6Rx5Rx4Rx3Rx2Rx1Rx0
PORTA
dsPIC33CKXXXMC502/102XXXXX
dsPIC33CKXXXMC503/103XXXXX
dsPIC33CKXXXMC505/105XXXXX
dsPIC33CKXXXMC506/106XXXXX
ANSELAXXXXX
PORTB
dsPIC33CKXXXMC502/102XXXXXXXXXXXXXXXX
dsPIC33CKXXXMC503/103XXXXXXXXXXXXXXXX
dsPIC33CKXXXMC505/105XXXXXXXXXXXXXXXX
dsPIC33CKXXXMC506/106XXXXXXXXXXXXXXXX
ANSELBXXXXXXXX
PORTC
dsPIC33CKXXXMC502/102
dsPIC33CKXXXMC503/103XXXXXX
dsPIC33CKXXXMC505/105XXXXXXXXXXXXXX
dsPIC33CKXXXMC506/106XXXXXXXXXXXXXXXX
ANSELCXXXXXX
PORTD
dsPIC33CKXXXMC502/102
dsPIC33CKXXXMC503/103
dsPIC33CKXXXMC505/105XXXX
dsPIC33CKXXXMC506/106XXXXXXXXXXXXXXXX
ANSELDXX
Figure 8-1. Block Diagram of a Typical Shared Port Structure