
dsPIC33/PIC24 Family Reference Manual
DS30009711C-page 16
2006-2019 Microchip Technology Inc.
4.5
Considerations for Peripheral Pin Selection
The ability to control Peripheral Pin Selection introduces several considerations into application
design that should be considered.This is particularly true for several common peripherals which
are only available as remappable peripherals.
Before any other application code is executed, the user must initialize the device with the proper
peripheral configuration. Since 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 the sake of
application safety, however, it is always a good idea to set IOLOCK and lock the configuration
after writing to the control registers.
Choosing the configuration requires the review of all Peripheral Pin Selects and their pin
assignments, especially those that will not be used in the application. In all cases, unused pin-
selectable peripherals should be disabled. Unused peripherals should have their inputs assigned
to V
SS
. I/O pins with unused RPn functions should be configured with the NULL (‘
0
’) peripheral
output.
The assignment of an RPn pin to the peripheral input or output depends on the peripheral and
its use in the application. It is better to be done immediately following device Reset and before
the peripheral configuration.
The assignment of a peripheral output to a particular pin does not automatically perform any
other configuration of the pin’s I/O circuitry. This means 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. To be
safe, fixed digital peripherals that share the same pin should be disabled when not in use.
Configuring a remappable pin for a specific peripheral input 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.
A final consideration is that Peripheral Pin Select functions neither override analog inputs, nor
reconfigure pins with analog functions for digital I/O. If a pin is configured as an analog input on
device Reset, it must be explicitly reconfigured as digital I/O when used with a Peripheral Pin
Select.
4.5.1
BASIC STEPS TO USE PERIPHERAL PIN SELECTION (PPS)
1.
Disable any fixed digital peripherals on the pins to be used.
2.
Switch pins to be used for digital functionality (if they have analog functionality) using the
ADxPCFG register.
3.
Unlock the OSCCON register and clear bit, IOLOCK (not needed after device Reset).
4.
Set RPINRx and RPORy registers appropriately.
5.
Unlock the OSCCON register and set bit, IOLOCK, to ‘
1
’.
6.
Configure and enable newly mapped PPS peripherals.
shows 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