11.4.6 Considerations for Peripheral Pin Selection

The ability to control Peripheral Pin Selection introduces several considerations into application design. Peripheral Pin Selects are not available on default pins in the device’s default (Reset) state. More specifically, because all RPINRx registers reset to ‘1’s and RPORx registers reset to ‘0’s, this means all PPS inputs are tied to Vss, while all PPS outputs are disconnected. This means that before any other application code is executed, the user must initialize the device with the proper peripheral configuration. Because the IOLOCK bit resets in the unlocked state, it is not necessary to execute the unlock sequence after the device has come out of Reset. For application safety, however, it is always better to set IOLOCK and lock the configuration after writing to the control registers.

Choosing the configuration requires a review of all Peripheral Pin Selects and their pin assignments, particularly those that will not be used in the application. In all cases, unused pin-selectable peripherals should be disabled completely. The RPn functions will be cleared as default.

The assignment of a peripheral to a pin does not perform any other configuration of the pin’s I/O circuitry. This means that adding a pin-selectable output to a pin may mean inadvertently driving an existing peripheral input when the output is driven. Users must be familiar with the behavior of other fixed peripherals that share a remappable pin and know when to enable or disable them. To be safe, fixed digital peripherals that share the same pin should be disabled when not in use.

Along these lines, configuring a remappable pin for a specific peripheral does not automatically turn that feature on. The peripheral must be specifically configured for operation and enabled as if it were tied to a fixed pin. Where this happens in the application code (immediately following device Reset and peripheral configuration or inside the main application routine) depends on the peripheral and its use in the application.

A final consideration is that Peripheral Pin Select functions neither override analog inputs nor reconfigure pins with analog functions for digital I/Os. If a pin is configured as an analog input on device Reset, it must be explicitly reconfigured as a digital I/O when used with a Peripheral Pin Select.

Configuring UART1 Input and Output Functions provides a configuration for bidirectional communication with flow control using UART1. The following input and output functions are used:

  • Input Functions: U1RX, U1CTS
  • Output Functions: U1TX, U1RTS

Configuring UART1 Input and Output Functions


//Configure Input Functions(See Table 11-10)

// Assign U1Rx To Pin RP35
_U1RXR = 35;

// Assign U1CTS To Pin RP36
_U1CTSR = 36;

// Configure Output Functions
// Assign U1Tx To Pin RP37
_RP37 = 9;                      // 9= U1TX (see Table 11-13)

// Assign U1RTS To Pin RP38
_RP38 = 10;                      // 10 = U1RTS (see Table 11-13)