PIC32 Ports Overview

Last modified by Microchip on 2023/11/09 09:01

General purpose I/O pins are the simplest of peripherals. They allow the PIC32 MCU to monitor and control other devices. To add flexibility and functionality, some pins are multiplexed with alternate function(s). These functions depend on which peripheral features are on the device. In general, when a peripheral is functioning, that pin may not be used as a general-purpose I/O pin.

Following are some of the key features of this module:

  • Individual output pin open-drain enable/disable
  • Individual input pin weak pull-up enable/disable
  • Monitor selective inputs and generate an interrupt when a change in pin state is detected
  • Operation during Sleep and Idle modes
  • Single cycle bit manipulation using CLR, SET, and INV registers

Hardware Abstraction Model

I/O Ports

ports hw model

All port pins have three controls directly associated with their operation as digital I/O. The data direction control determines whether the pin is an input or an output. All port pins are defined as inputs after a reset. Writes to a port are latched and, if programmed as an output, driven by a buffer to the pin. The value of the pin can be read directly from an input buffer, (after it has been synchronized to the clock), regardless of whether the pin direction has been selected as input or output. Additionally, the value being driven by the latch before the output buffer can also be read.

Internal pull-up resistors are available on selected port pins to eliminate the need to use external pull-up resistors. These pull-ups can be controlled by this library. The open-drain feature allows the generation of outputs higher than VDD on any desired digital-only pins by using external pull-up resistors.

The output slew rate of some port pins is programmable to select either the standard transition rate or a reduced transition rate of 'x' times the standard to minimize EMI.

Back to top

Input Change Notification

The input change notification feature of the I/O ports allows the microcontrollers to generate interrupt requests to the processor in response to a change of state on selected input pins. This feature is capable of detecting input changes of states even in Sleep mode when the clocks are disabled.

Back to top

Peripheral Pin Select

ports pps in hw model

In addition to general-purpose I/O control, this library also provides a low-level abstraction of the PPS module on Microchip microcontrollers with a convenient C language interface. The alternate pin function selections are used to steer specific peripheral input and output functions between different pins.

The number of available pins is dependent on the particular device and its pin count. Pins that support the PPS feature include the designation 'RPn' or 'RPIn' in their full pin designation, where 'RP' designates a remappable peripheral and 'n' is the remappable pin number. RP is used to designate pins that support both remappable input and output functions, while RPI indicates pins that only support remappable input functions.

The peripherals managed by PPS are all digital-only peripherals. These include general serial communications (UART and SPI), general-purpose timer clock inputs, timer-related peripherals (Input Capture and Output Compare), comparator digital output, interrupt-on-change inputs, etc.

ports pps out hw model

In comparison, some digital-only peripheral modules are never included in the peripheral pin select feature. This is because the peripheral’s function requires special I/O circuitry on a specific port and cannot be easily connected to multiple pins. These modules include I2C, among others. A similar requirement excludes all modules with analog inputs, such as the Analog-to-Digital Converter (ADC).

If multiple peripherals are enabled on the same pin(s), there is an internal priority that decides which function is mapped to the pin. When a remappable peripheral is active on a given I/O pin, it takes priority over all other digital I/O and digital communication peripherals associated with the pin. Priority is given regardless of the type of peripheral that is mapped. Remappable peripherals never take priority over any analog functions associated with the pin. In other words, If an analog function is enabled on the pin, the PPS input will be disabled.

Back to top

Detailed Overview

For more detail on the I/O Ports for a specific PIC32 device, please view the family reference manual chapter for that device, for example:

Back to top