Cornell University ECE4760
I/O Ports


I/O Port Layout

I/O Port structure

General purpose i/o pins have a variety of functions on the PIC32.
See also Chapter 12 of the Hardware Reference Manual and Chapter 10 of PLIB

Pullup/pulldown macros

The poorly documented CNPDB register (Change Notice Pull-down Enable B) selects input bits to pull down.
See section 12.2.6 of the i/o reference manual. For instance, setting:
CNPDB = BIT_7 | BIT_8 | BIT_9

pulls down B7, B8, and B9. To be safe, you should probably clear the CNPUB register to turn off pull up resistors.
If you include the following macros:
#define EnablePullDownB(bits) CNPUBCLR=bits; CNPDBSET=bits;
#define DisablePullDownB(bits) CNPDBCLR=bits;
#define EnablePullUpB(bits) CNPDBCLR=bits; CNPUBSET=bits;
#define DisablePullUpB(bits) CNPUBCLR=bits;
#define EnablePullDownA(bits) CNPUACLR=bits; CNPDASET=bits;
#define DisablePullDownA(bits) CNPDACLR=bits;
#define EnablePullUpA(bits) CNPDACLR=bits; CNPUASET=bits;
#define DisablePullUpA(bits) CNPUACLR=bits;

Then you can just write
EnablePullDownB( BIT_7 | BIT_8 | BIT_9);

There is support for pullup in PLIB (ConfigCNPullups) but it is not organized by port bit number and there is
no support for pulldowns that I could find.


PPS redirects specific logical input/output signals to groups of i/o pins. For instance, one of the input capture inputs, IC1, can be routed to one of 8 different physical pins (see input table below). This feature helps with fitting designs onto the relatively few pins on the PDIP PIC32. Note that not all logical device signals can be PPS routed. For example, when an SPI channel is turned on, SCL1 and SCL2, the SPI clock lines are at fixed i/o pins 25 and 26 (RB14 and RB15). When a SPI channel is disabled, the respective clock pin can be used for general i/o.

Using PPS input-- PIC32MX250F128B Peripheral Pin Select (PPS) input table
-- example -- UART receive pin
specify PPS group, signal, logical pin name
PPSInput(2, U2RX, RPB11); //Assign U2RX to pin RPB11 -- Physical pin 22 on 28 PDIP
Note that the groups (1 to 4) are delimited by horzontal lines in the righthand column.

Using PPS output -- PIC32MX250F128B Peripheral Pin Select (PPS) output table
-- example -- UART transmit pin
specify PPS group, logical pin name, signal
PPSOutput(4, RPB10, U2TX); //Assign U2TX to pin RPB10 -- Physical pin 21 on 28 PDIP
Note that the groups (1 to 4) are delimited by horzontal lines in the righthand column.

Copyright Cornell University July 16, 2018