Skip to content

This example is useful for getting started with PIC32CM MCU families by using Microchip development tools, including Curiosity Nano board for respective MCU family.Based on user input, LED toggles at a specific rate and prints the same on serial terminal.

License

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/pic32cm-arm-cortex-m0plus-getting-started-vscode

Repository files navigation

Microchip Technologies Inc.

Getting Started With the Arm® Cortex®-M0+ Based PIC32CM PL10 Microcontroller

The PIC32CM PL10 microcontroller family based on the Arm® Cortex®-M0+ core is engineered to address the performance, efficiency, and scalability requirements of modern embedded applications. With a rich set of integrated peripherals and a flexible development ecosystem, the PIC32CM PL10 family enables rapid prototyping and streamlined application development across industrial, consumer, and IoT cases.

This application example demonstrates a real-time peripheral-driven control workflow using the PIC32CM PL10 microcontroller. It showcases the coordinated operation of key resources, including Real-Time Clock (RTC), External Interrupt Controller (EIC), Direct Memory Access Control (DMAC), SERCOM-based Universal Asynchronous Receiver-Transmitter (USART) and General-Purpose Input/Output (GPIO). The application implements dynamic LED control with user input handling and real-time status reporting over a serial interface, highlighting efficient event-driven firmware design.

The example is developed using Microchip’s supported toolchain and software frameworks, including MPLAB Tools for Visual Studio Code (VS Code®), MPLAB® X IDE, MPLAB Code Configurator (MCC) and the CMSIS-based driver environment. While the PIC32CM-PL10 family is used as the reference platform, the application concepts are applicable across the broader PIC32CM product family.

For detailed step-by-step instructions on project creation, peripheral configuration, code generation, build flow and programming procedures refer to the Application Note Getting Started With the Arm® Cortex®-M0+ Based PIC32CM Microcontroller Families. The Application Note provides a comprehensive walkthrough of the development environment setup using Visual Studio Code (VS Code®), MPLAB® X IDE, MPLAB Code Configurator (MCC) and MPLAB Tools for CMSIS-based workflows. It also includes guided instructions for configuring clock sources, peripheral modules, pin multiplexing, and debugging interfaces required to successfully reproduce this application example on the PIC32CM PL10 Curiosity Nano platform.

Related Documentation

Software Used

Hardware Used

Block Diagram


Figure 1: Block Diagram

Setup

All peripheral and clock configurations for this example are generated using MPLAB® Code Configurator (MCC) inside Visual Studio Code for the PIC32CM6408PL10 microcontroller. The peripheral configuration is as per the table below.

Sr. No. Peripheral Configuration Usage
1 Clock Control Clock Source - HFINTOSC
Frequency - 24 MHz
Divider - 1
Clock Tuning - Enabled
APBCMASK - 0x0C8CU
System Clock
2 SERCOM1 Mode - USART with Internal Clock
Data Order - LSB First
IBON - Enabled
Frame Format - Standard USART
Sampling Rate - 16x
Baud Rate - 115200
Character Size - 8 bits
Stop Bits - 1
Parity - None
Used for sending and receiving data from the terminal
3 EIC Clock Source – ULP32K
Enable EIC Channel3
Enable Interrupt
Ext Interrupt3 Edge Selection – Rising Edge
Enable filter
For the switch press event
4 RTC Enable Compare 0 interrupt
Compare Value – 0x200
Enable Interrupt
Generate an interrupt every 500 ms
5 DMAC DMAC Channel 0 – SERCOM1_Transmit
SEnable Interrupt
Transfers one byte from the user buffer to the USART transmit buffer on each trigger

Pin Configuration

|Sr. No.| Pin | Usage | |--|--|--|--| | 1 | PB0 | SERCOM1_PAD0 | | 2 | PB1 | SERCOM1_PAD1 | | 3 | PB2 | LED (GPIO as Output) | | 4 | PB3 | Switch (GPIO as Input) |

Demo Overview

This application implements a real-time LED control application on the PIC32CM PL10 Curiosity Nano evaluation board. The application uses the on-board LED and mechanical switch to showcase timer-driven operation, interrupt-based user input handling and non-blocking serial communication.

  • LED Toggle Operation (Default Mode)
    After programming and reset, the application starts automatically and toggles the on-board LED at a default interval of 500 ms. The LED toggling is driven by the RTC compare interrupt, ensuring accurate timing independent of the main execution loop. Each toggle event is accompanied by a status message transmitted over the serial interface.

  • LED Toggle Speed Control Using Switch
    The on-board mechanical switch allows dynamic control of the LED blinking rate. Each press advances the LED toggle period through the following sequence: 500 ms (Default)
    1 second
    2 seconds
    4 seconds
    Back to 500 ms
    The EIC detects the switch press event, while the RTC compare value is updated in real time to reflect the newly selected toggle interval. The selected blink rate is reported on the serial terminal.

  • UART Status Reporting Using DMAC
    UART communication is implemented using the SERCOM peripheral in combination with the DMAC. This enables efficient, non-blocking transmission of status messages without CPU intervention. Each LED toggle and speed change event generates a corresponding message that is transmitted to the host PC through the virtual COM port.

Operation

Follow the steps below to run the Getting Started firmware, switch between LED blinking speed using the on-board mechanical switch.

  1. Power the Board.
  • Connect the PIC32CM-PL10 Curiosity Nano to your PC using a USB type-C cable
  • The board automatically powers ON and executes LED blinking at 500 ms blink rate
  1. Open the UART Terminal.
  • Launch MPLAB Data Visualizer
  • Locate the COM port corresponding to the Curiosity Nano board
  • Set baud rate = 115200
  • Open the terminal
  1. Press the on-board mechanical switch to change the LED blinking interval between 500 ms, 1 s, 2 s and 4 s. The routine operates in a cyclic sequence, progressing from 500 ms to 1 s, then to 2 s and 4 s and returning to 500 ms with each subsequent switch press.


Figure 2: Output Window

Summary

The Getting Started with the PIC32CM PL10 Curiosity Nano application demonstrates real-time LED control with user input handling and status reporting on the PIC32CM6408PL10 microcontroller. This application highlights the use of GPIO, RTC, EIC, DMAC and USART peripherals, providing a practical reference for event-driven firmware development on the Curiosity Nano platform.

About

This example is useful for getting started with PIC32CM MCU families by using Microchip development tools, including Curiosity Nano board for respective MCU family.Based on user input, LED toggles at a specific rate and prints the same on serial terminal.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages