Cornell University ECE4760
I/O Ports

PIC32MX250F128B

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:
// PORT B
#define EnablePullDownB(bits) CNPUBCLR=bits; CNPDBSET=bits;
#define DisablePullDownB(bits) CNPDBCLR=bits;
#define EnablePullUpB(bits) CNPDBCLR=bits; CNPUBSET=bits;
#define DisablePullUpB(bits) CNPUBCLR=bits;
//PORT A
#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

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 24, 2017