7.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.

SERCOM0 USART with PPS

  1. Create a new project and add SERCOM0 device resource as explained in USART with Direct Pin Enable (See USART with Direct Pin Enable from Related Links) mode.
  2. Find SERCOM0 Pin description from Curiosity Board User's Guide (EV60G68A).
    Table 7-1. USB Serial Converter Pin Assignment
    Pin on MCP2200Pin on PIC32WM-BW1002UC ModuleDescription

    TX

    PA6, SERCOM0_PAD1

    UART RX pin of the PIC32WM-BW1002UC Module

    RX

    PA5, SERCOM0_PAD0

    UART TX pin of the PIC32WM-BW1002UC Module

    RTS

    PA4, SERCOM0_PAD3

    UART CTS pin of the PIC32WM-BW1002UC Module

    CTS

    PA3, SERCOM0_PAD2

    UART RTS pin of the PIC32WM-BW1002UC Module

  3. Assign a new pin for SERCOM0_PAD0, SERCOM0_PAD1, SERCOM0_PAD2, SERCOM0_PAD3 from PPS input/output group tables as mentioned in Datasheet (see PIC32WM-BW1 Wi-Fi® and Bluetooth® Low Energy Combo MCU Module Data Sheet under Referenced Documentation from Related Links.

    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

    Figure 7-10. Input Pin Selection Group 3
  4. Open Pin settings from Window>MPLAB Code Configuratior v5>Harmony>Pin Configuration tab and select desired pin functions
    Figure 7-11. Pin Configuration
  5. Open project graph from MCC and go to “System” configuration options and select SERCOM0 in PPS mode.

Generate Code

For instructions on code generation, refer to MPLAB Code Configurator (MCC) Code Generation section from Related Links.

PPS input/output remaping code can be found in this generated plib_gpio.c file.

Figure 7-12. plib_gpio.c
  • 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 (See USART with Direct Pin Enable from Related Links.

Testing

  1. Connect the PIC32WM-BW1 Curiosity board to PC, program the application example.
  2. Disconnect the board from USB Type-C COM Port and connect it from mikroBUS UART.
  3. The above mentioned pins are brought out to mikroBUS in following manner:
    Table 7-2. mikroBUS Pins
    UART to FTDI PinsmikroBUS Pins
    TXSDA (RPA7)
    RXSCL (RPA8)
    CTSMOSI (RPA9)
    RTSRST (RPA3)
    VCC3.3V
    GNDGND
    Figure 7-13. Setup
Figure 7-14. Terminal Window