MPLAB® Harmony v3 Peripheral Libraries on PIC32CM GV-VL (Arm® Cortex®-M0+) MCUs: Step 2

Last modified by Microchip on 2025/09/29 09:46

Note: This video provides an overview of configuring the Real-Time Clock (RTC), Clock, and Universal Synchronous Asynchronous Receiver Transmitter (USART) with STDIO using MPLAB® Code Configurator (MCC).

Configure RTC Peripheral Library

Click on the Device Resources tab on the left side of the MCC. In Device Resources, expand Libraries > Harmony > Peripherals > RTC.

Double-click or drag and drop RTC to add the RTC Peripheral Library (PLIB) to the project graph.

Project Graph

Open the Clock Configurator.

In the Clock Easy View, navigate to the 32 KHz Oscillators Controller and select the two checkboxes for the 32K High Accuracy Internal Oscillator. Go to GCLK Generator X, select the checkbox next to GCLK Generator X, and select OSC32K as the clock source for GCLK2. Ensure that the clock source for GCLK2 is set to 32.768 KHz.

Clock Configurator

Go to Peripheral Clock Selection and click on Peripheral Clock Configuration to open the Peripheral Clock Configuration dialog box, and select GCLK2 for RTC.​​​​

Peripheral Clock Configuration

 

Click on the RTC in the Project Graph. In the Configuration Options, configure the RTC PLIB to generate a compare interrupt every 500 milliseconds.

Project Graph

Note: The Compare Value is set as 0x200. This compare value generates an RTC compare interrupt every 500 milliseconds.

Back to Top


Configure SERCOM 2 (USART) Peripheral Library, STDIO Extensions, and USART Pins

Under the Device Resources tab, expand Libraries > Harmony > Peripheral > SERCOM. Double-click on SERCOM2 to add the SERCOM instance 2 to the project.

Device Resources tab

Right-click the Yellow UART diamond icon in SERCOM2 and select STDIO from the Available Consumers to configure the USART. This setup enables functions like printf() to transmit data to the terminal, allowing the LED's periodic toggling rate to be displayed on the console.

Available Consumers

Select the SERCOM2 Peripheral Library in the Project Graph and verify that the default SERCOM Operation Mode configuration is set as USART. Configure it as shown in the accompanying image. Verify the default baud rate is set to 115200 Hz.

SERCOM2 Peripheral Library

Note: The application will use the SERCOM2 (as USART) PLIB for printing LED toggling rate on the serial terminal.

By setting up STDIO (Standard Input / Output) to utilize the USART peripheral, functions such as printf() can transmit data through the serial port. This is useful for communicating with your microcontroller using a terminal application (Tera Term) on your computer.

Open the Pin Configuration tabs by clicking MCC > Project Graph > Plugins > Pin Configuration.

Pin Configuration tabs

Select the MCC Pin Settings tab and sort the entries by Ports, as shown in the accompanying image.

MCC Pin Settings

Now, select the pin that is used for USART transmit.

  • Enable USART_TX (SERCOM2_PAD0) on PA12 (Pin #29).
  • Enable USART_RX (SERCOM2_PAD1) on PA13 (Pin #30).

MCC Pin Settings

Back to Top