9.5 Considerations for Peripheral Pin Selection
The ability to control Peripheral Pin Selection introduces several considerations into application design that most users would never think of otherwise. This is particularly true for several common peripherals, which are only available as remappable peripherals.
The main consideration is that the 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.
The NVMKEY unlock sequence must be executed as an Assembly language
routine. If the bulk of the application is written in C, or another high-level language,
the unlock sequence should be performed by writing in-line assembly or by using the
__builtin_write_RPCON(value)
function provided by the compiler.
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. Unused peripherals should have their inputs assigned to an unused RPn pin function. I/O pins with unused RPn functions should be configured with the null peripheral output.