9.2 USART with Peripheral Pin Select (PPS)
The Peripheral Pin Select (PPS) feature allows digital signals to be moved from their default pin location to another location. To enable a digital peripheral’s input and/or output signals, the appropriate PPS registers must be configured. This can be extremely handy for routing circuit boards. There are cases where a change of I/O position can make a circuit board easier to route. Sometimes mistakes are found too late to fix so having the option to change a pinout mapping in software rather than creating a new printed circuit board can be very helpful.
PPS block diagram and various pin selection tables are explained in the PIC32CX-BZ2 and WBZ45 Datasheet (DS70005504A) chapter 6.
SERCOM0 USART with PPS
1. Create a new project and add SERCOM0 device resource as explained in USART with Direct Pin Enable mode.
2. Find SERCOM0 Pin description from Evaluation kit User’s Guide (DS50003367A).
3. Assign a new pin for SERCOM0_PAD0, SERCOM0_PAD1, SERCOM0_PAD2, SERCOM0_PAD3 from PPS input/output group tables mentioned in datasheet (DS70005504A).
As per the following table, SERCOM0_PAD1 input pin can be mapped to any of the given RPn listed on this table. Similar tables are present in Datasheet for SERCOM0_PAD1, SERCOM0_PAD2, SERCOM0_PAD3.
4. Open Pin settings from Window->MPlab Code configuratior v5->Harmony->Pin Configuration tab and select your desired pin functions.
5. Open your project graph from MCC code configurator and go to system configuration options and select SERCOM0 in "PPS" mode.
Generate Code
For instructions, refer to MPLAB Code Configurator(MCC) Code Generation
PPS input/output remaping code can be find in this generated plib_gpio.c
file.
SERCOM0_PAD3(in)->RA9 Pin setting will set PPS_SCOM0P3R to 15 (binary value 1111)
SERCOM0_PAD1(in)->RA8 Pin setting will set PPS_SCOM0P1R to 9 (binary value 1001)
SERCOM0_PAD0(out)->RA7 Pin setting will set PPS_RPA7G2R to 1 (binary value 00001)
SERCOM0_PAD2(out)->RA3 Pin setting will set PPS_RPA3G1R to 2 (binary value 00010)
Create a "hello world" application as mentioned in USART with Direct Pin Enable section.
Testing
Connect the WBZ451 Curiosity board to PC, program the application example. User can verify the data coming from UART Tx pin :SERCOM0_PAD0(RA7 in this case) using a logic analyzer. User can also verify this application using one FTDI cable. Connect FTDI ground pin and FTDI RX pin to appropriate Tx pin on WBZ451 and verify the message on TeraTerm window.
1) Verify using Logic analyzer.
2) Terminal window