This example project demonstrates basic UART communication using the SERCOM peripheral on a PIC32CM JH00 device. The application transmits the message “Hello World” once every 500 ms using the SysTick timer, and the output can be viewed on a serial terminal connected to the board. This project provides a straightforward introduction to initializing the SERCOM for UART operation and sending periodic messages.
While this project uses a PIC32CM JH00 device, the same initialization and communication principles apply to other PIC32CM M0+ devices.
- MPLAB® X IDE 6.25.0 or newer
- MPLAB® XC32 4.60 or newer
- MPLAB® Code Configurator (MCC) v5.6.2
- MPLAB® Harmony v3 v5.8.2
This example project was developed in MPLAB X IDE and can also be opened in VS Code® using the MPLAB Extension Pack. Follow the provided instructions here to import and run the project in VS Code®.
For a step-by-step walkthrough on importing the project, watch the video: Importing an MPLAB® X Project into Microsoft® VS Code®
- Getting Started: Serial Communication
- Arm® Cortex®-Based Microcontrollers (MCUs)
- SERCOM USART on Microchip Cortex Devices (SAM and PIC32CM)
UART communication is based on a simple point-to-point connection between two devices. One device’s TX (transmit) pin connects to the other device’s RX (receive) pin, and vice versa. This crossover allows data to flow in both directions, as shown in the following figure.
In this configuration, the UART provides a straightforward way to exchange data without the need for a clock signal. For communication to work correctly, both devices must be configured with the same parameters:
- Baud Rate – Defines the speed of communication in bits per second. If the baud rates do not match, the timing of bits will drift and data will be corrupted.
- Data Bits – Specifies how many bits represent the actual data (commonly 8). Both devices must agree to properly interpret each frame.
- Parity – An optional error-checking bit (None, Even, or Odd). If enabled, both sides must use the same setting to validate data integrity.
- Stop Bits – Mark the end of each data frame (typically 1 or 2). Mismatched stop bits cause framing errors.
Together, these settings ensure that the transmitted bits are correctly packaged, sent, and interpreted on the receiving side.
In this example, the concept is applied using the SERCOM1 peripheral configured as a UART. The onboard debugger uses a Communications Device Class (CDC) interface that appears on the host computer as a virtual COM port, allowing the data to stream in both directions between the host and the target device.
Characters sent from the host are transmitted on the debugger’s CDC TX pin, while characters received on the CDC RX pin are returned to the host. The UART output can be viewed in a terminal program such as the MPLAB Data Visualizer, making it easy to monitor or interact with the application over a USB without extra hardware.
The application performs the following sequence:
- SERCOM1 is initialized as a UART interface with the chosen baud rate.
- The SysTick timer is initialized and provides a 500 ms time base.
- A fixed message string,
Hello World, is transmitted over the USB CDC connection to the host computer. - After 500 ms, the process repeats continuously.
Once programmed, the device continuously sends the Hello World message, which appears in a terminal window on the host computer through the Curiosity Nano’s CDC virtual COM port.
- Connect the Debug USB port of the PIC32CM JH00 Curiosity Nano to a PC using a Micro-USB to USB 2.0 cable.
- If not already installed, download and install MPLAB X IDE version 6.25 or newer.
- If not already installed, download and install the XC32 C-Compiler version 4.60 or newer.
- Clone or download this project from GitHub to the local machine.
- If downloaded as a
.zipfile, extract the files to a location preferably as close as possible to the root directory. - In MPLAB X IDE, go to File → Open Project. Navigate to the extracted location and select the project file:

- Click the Make and Program Device button in the MPLAB X IDE toolbar to program the device. Then, verify that the device is successfully programmed.

To view the output of this project, launch the MPLAB Data Visualizer from the MPLAB X IDE toolbar. In the Data Visualizer, select the serial COM port associated with the PIC32CM JH00 Curiosity Nano and confirm that the settings match the configured SERCOM UART parameters in the Project Configuration section.
The UART pins can be probed with a logic analyzer, where the output should decode as "Hello World\r\n" at the configured baud rate, confirming proper signal operation.

This example project is already provided as a preconfigured MPLAB X project. Start by opening the project in MPLAB X IDE. Once the project is loaded, launch the MPLAB® Code Configurator (MCC) in Harmony to review the configuration.
For detailed instructions on how to create and set up a new MPLAB X project and open MCC Harmony, refer to the this Microchip online reference here
When opened in MCC Harmony, the Project Graph provides a visual overview of the project, showing the active components and their interactions.
With the Project Graph open, review the configuration step by step. Use the following checklist to confirm each setting before proceeding:
Open the Clock Configurator from the Plugins section in the Project Graph to verify the system clock is set to 48 MHz.
To check the system clock, go to Project Graph → Plugins → Clock Configurator
Note: Most Harmony v3 projects default to the 48 MHz internal oscillator.
The SysTick is a built-in timer that allows the application to create precise delays without relying on software loops. In this demonstration, it will be used to add a fixed delay between each Hello World message sent over the UART.
To enable SysTick:
The device includes multiple SERCOM peripherals that can be configured as UART, SPI, or I²C. On the Curiosity Nano, only SERCOM1 is internally routed to the onboard debugger’s CDC interface, so it must be used for sending the UART data to a terminal over a USB.
This information is available in the Pinout section of the Curiosity Nano User's Guide.
To add and configure SERCOM1:
- Once added, Select SERCOM1 in the Project Graph. In the Configuration Options panel, apply the following settings:
- Operation Mode: USART with internal Clock. Enables UART mode for the selected SERCOM instance using the internal clock.
- Transmit/Receive Enable: Enable both Transmit is required to send data to the terminal; receive is optional but recommended for flexibility.
- Baud Rate: Set to 115200.
- All other settings can remain at default for this project.

After configuring SERCOM1, the UART TX and RX pins must be mapped to the I/O lines connected to the debugger’s CDC interface. This enables UART messages to be sent and received through the Curiosity Nano’s USB connection
According to the Curiosity Nano user guide:
To assign the pins:
- In the Pin Settings tab. Locate PA16 (Pin #35) and PA17 (Pin #36) in the Pin Table.
With the UART and SysTick configured, the final step is to generate the code. The MCC creates the initialization files, peripheral drivers, and APIs for UART communication and SysTick timing, preparing the project for application development.

This code defines a macro for "Hello World", starts the SysTick timer, and enters a loop that sends the "Hello_World" message over the UART using SERCOM1_USART_Write(). Timing is provided by SYSTICK_DelayMs() to create a 500 ms delay and prevent flooding the terminal.
SYSTICK_TimerStart()– starts the SysTick timer so delay functions are available.SYSTICK_DelayMs(x)– creates a blocking delay for the specified number of milliseconds.SERCOM1_USART_Write()– sends a buffer of bytes over the SERCOM1 UART interface.
#define Hello_World "Hello World \r\n"
int main(void)
{
/* Initialize all modules */
SYS_Initialize(NULL);
SYSTICK_TimerStart();
while (true)
{
SERCOM1_USART_Write(Hello_World, sizeof(Hello_World));
SYSTICK_DelayMs(500);
}
/* Execution should not come here during normal operation */
return (EXIT_FAILURE);
}This project showed how to configure the SERCOM in UART mode on a PIC32CM M0+ device using MCC Harmony. The system clock, SysTick timer, and SERCOM1 peripheral were set up to send a "Hello World" message every 500 ms over the Curiosity Nano’s USB CDC interface. This simple example provides a foundation for expanding into bidirectional communication or more advanced embedded applications.
- Getting Started with Blink LED on PIC32CM M0+ Devices
- Getting Started with Analog-to-Digital Converters (ADC) on PIC32CM M0+ Devices
- Getting Started with QTouch® Button and Peripheral Touch Controller on PIC32CM M0+ Devices
- Getting Started with SERCOM (I²C) Communication on PIC32CM M0+ Devices
- Getting Started with SERCOM (SPI) Communication on PIC32CM M0+ Devices













