Peripheral Pin Select Library
The Peripheral Pin Select library enables user to have more than one digital peripheral multiplexed on a single pin.
Users may independently map the input and/or output of any one of many digital peripherals to any one of these I/O pins.
The peripherals managed by the Peripheral Pin Select library are all digital only peripherals.
A key difference between pin select and non pin select peripherals is that pin select peripherals are not associated
with a default I/O pin. The peripheral must always be assigned to a specific I/O pin before it can be
used.
In contrast, non pin select peripherals are always available on a default pin, assuming that the peripheral
is active and not conflicting with another peripheral.
When a pin selectable 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.

- For input only, peripheral pin select functionality does not have priority over TRISx settings. Therefore, when configuring RPn pin for input, the corresponding bit in the TRISx register must also be configured for input (set to 1).
- This library applies applies only to the MCUs with Peripheral Pin Select functionality (PIC32MX1xxFxxxB, PIC32MX1xxFxxxC, PIC32MX1xxFxxxD, PIC32MX2xxFxxxB, PIC32MX2xxFxxxC and PIC32MX2xxFxxxD).
Library Routines
Unlock_IOLOCK
Prototype |
void Unlock_IOLOCK(); |
---|---|
Description |
Unlocks I/O pins for Peripheral Pin Mapping. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
Unlock_IOLOCK(); |
Notes |
None. |
Lock_IOLOCK
Prototype |
void Lock_IOLOCK(); |
---|---|
Description |
Locks I/O pins for Peripheral Pin Mapping. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
Lock_IOLOCK(); |
PPS_Mapping
Prototype |
unsigned PPS_Mapping(unsigned short rp_num, unsigned short direction, unsigned short funct_name); |
---|---|
Description |
Sets desired internal MCU module to be mapped on the requested pins. |
Parameters |
|
Returns |
|
Requires |
Nothing. |
Example |
PPS_Mapping(_RPC6, _OUTPUT, _U1TX); // Sets pin PORTC.B6 to be Output and maps UART1 Transmit to it PPS_Mapping(_RPC7, _INPUT, _U1RX); // Sets pin PORTC.B7 to be Input and maps UART1 Receive to it |
Notes |
Use this routine when |
PPS_Mapping_NoLock
Prototype |
unsigned PPS_Mapping_NoLock(unsigned short rp_num, unsigned short input_output, unsigned short funct_name); |
---|---|
Description |
Sets desired internal MCU module to be mapped on the requested pins. This function doesn't use Unlock_IOLOCK and Lock_IOLOCK routines, so the user must call them before and after this function call (very useful if |
Parameters |
|
Returns |
|
Requires |
Nothing. |
Example |
Unlock_IOLOCK(); PPS_Mapping(_RPC6, _OUTPUT, _U1TX); // Sets pin PORTC.B6 to be Output and maps UART1 Transmit to it PPS_Mapping(_RPC7, _INPUT, _U1RX); // Sets pin PORTC.B7 to be Input and maps UART1 Receive to it Lock_IOLOCK(); |
Notes |
None. |
Remappable Pins
Pin Identifer | Description |
---|---|
_RPA0 | Remappable Pin PORTA.B0 |
_RPA1 | Remappable Pin PORTA.B1 |
_RPA2 | Remappable Pin PORTA.B2 |
_RPA3 | Remappable Pin PORTA.B3 |
_RPA4 | Remappable Pin PORTA.B4 |
_RPA8 | Remappable Pin PORTA.B8 |
_RPA9 | Remappable Pin PORTA.B9 |
_RPB0 | Remappable Pin PORTB.B0 |
_RPB1 | Remappable Pin PORTB.B1 |
_RPB2 | Remappable Pin PORTB.B2 |
_RPB3 | Remappable Pin PORTB.B3 |
_RPB4 | Remappable Pin PORTB.B4 |
_RPB5 | Remappable Pin PORTB.B5 |
_RPB6 | Remappable Pin PORTB.B6 |
_RPB7 | Remappable Pin PORTB.B7 |
_RPB8 | Remappable Pin PORTB.B8 |
_RPB9 | Remappable Pin PORTB.B9 |
_RPB10 | Remappable Pin PORTB.B10 |
_RPB11 | Remappable Pin PORTB.B11 |
_RPB12 | Remappable Pin PORTB.B12 |
_RPB13 | Remappable Pin PORTB.B13 |
_RPB14 | Remappable Pin PORTB.B14 |
_RPB15 | Remappable Pin PORTB.B15 |
_RPC0 | Remappable Pin PORTC.B0 |
_RPC1 | Remappable Pin PORTC.B1 |
_RPC2 | Remappable Pin PORTC.B2 |
_RPC3 | Remappable Pin PORTC.B3 |
_RPC4 | Remappable Pin PORTC.B4 |
_RPC5 | Remappable Pin PORTC.B5 |
_RPC6 | Remappable Pin PORTC.B6 |
_RPC7 | Remappable Pin PORTC.B7 |
_RPC8 | Remappable Pin PORTC.B8 |
_RPC9 | Remappable Pin PORTC.B9 |
Direction Parameters
Direction Parameter | Description |
---|---|
_INPUT | Sets selected pin as input |
_OUTPUT | Sets selected pin as output |
Input Functions
Function Name | Description |
---|---|
_REFCLKI | Reference Input Clock |
_OCFA | Output Compare Fault A Input |
_OCFB | Output Compare Fault B Inputk |
_IC1 | Input Capture 1 |
_IC2 | Input Capture 2 |
_IC3 | Input Capture 3 |
_IC4 | Input Capture 4 |
_IC5 | Input Capture 5 |
_INT1 | External Interrupt 1 |
_INT2 | External Interrupt 2 |
_INT3 | External Interrupt 3 |
_INT4 | External Interrupt 4 |
_SDI1 | SPI1 Data Input |
_SDI2 | SPI2 Data Input |
_SS1 | SPI1 Slave Select Input |
_SS2 | SPI2 Slave Select Input |
_T2CK | Timer2 External Clock |
_T3CK | Timer3 External Clock |
_T4CK | Timer4 External Clock |
_T5CK | Timer5 External Clock |
_U1CTS | UART1 Clear To Send |
_U2CTS | UART2 Clear To Send |
_U1RX | UART1 Receive |
_U2RX | UART2 Receive |
Output Functions
Function Name | Description |
---|---|
_C1OUT | Comparator 1 Output |
_C2OUT | Comparator 2 Output |
_OC1 | Output Compare 1 |
_OC2 | Output Compare 2 |
_OC3 | Output Compare 3 |
_OC4 | Output Compare 4 |
_OC5 | Output Compare 5 |
_REFCLKO | REFCLK output signal |
_SDO1 | SPI1 Data Output |
_SDO2 | SPI2 Data Output |
_SS1X | SPI1 Slave Synchronization or Frame Pulse I/O |
_SS2X | SPI2 Slave Synchronization or Frame Pulse I/O |
_U1RTS | UART1 Request To Send |
_U2RTS | UART2 Request To Send |
_U1TX | UART1 Transmit |
_U2TX | UART2 Transmit |
What do you think about this topic ? Send us feedback!