Beginner Lab 8: Universal Asynchronous Receiver Transmitter (UART) Interrupt Mode
Objective
- Understand the principles of Universal Asynchronous Receiver Transmitter (UART) communication and its implementation using interrupt mode on a PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit.
- Compare polling-based UART communication with interrupt-driven UART communication by transmitting a received data buffer using UART interrupts.
- Gain practical experience in configuring and handling UART interrupts for efficient I/O operations.
- Develop a foundational understanding of Nested Vectored Interrupt Controller (NVIC) configuration and interrupt handling concepts in embedded systems.
Overview
This lab is designed to implement UART communication using interrupt mode on the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit. Expanding upon the polling-based UART communication introduced in previous exercises, this lab highlights the differences between polling and interrupt-driven methods. The UART peripheral on the PIC32CM LS00 device will be configured to transmit a received data buffer utilizing UART interrupts. Completion of this lab provides practical experience with interrupt-driven input/output, demonstrates how UART events trigger interrupt service routines, and introduces the basic operation of the NVIC. This lab introduces essential interrupt-handling concepts relevant to real-time embedded systems.
Lab Activities
- Configure the SERCOM3 peripheral in Universal Synchronous Asynchronous Receiver Transmitter (USART) mode and assign the appropriate USART pins using MPLAB® X IDE.
- Set up Arm® TrustZone® for Armv8-M by configuring the Serial Communication (SERCOM) peripheral as non-secure and ensure that the SERCOM interrupt is enabled in the NVIC.
- Generate the project and add the application code to the generated project files, implementing callback functions for SERCOM USART read and write operations to enable interrupt-driven communication.
- Observe the output by verifying that the data entered is echoed back through USART communication using a terminal application such as Tera Term.
Expected Outcomes
Upon completion of this lab, the following skills will be acquired:
- Successfully configure the SERCOM peripheral for USART communication and assign the appropriate TX and RX pins.
- Set up Arm TrustZone for Armv8-M and ensure that the corresponding NVIC interrupt is enabled.
- Develop and integrate application code to implement interrupt-driven USART communication using SERCOM USART callback functions.
- Verify the output by confirming that the entered 10 characters are echoed back through USART communication using a terminal application such as Tera Term or PuTTY.
Lab Source Files and Solutions
This ZIP file contains the completed solution project for this lab. It also contains the source files needed to perform the lab as per the following step-by-step instructions (see the "Lab Index" section on this page).
for this lab.
Lab Index
- Step 1: Polling vs Interrupt, NVIC and ISR
- Step 1.1 - Polling vs Interrupt-Driven Communication
- Step 1.2 - Nested Vectored Interrupt Controller (NVIC)
- Step 1.3 - Interrupt Service Routine (ISR)
- Step 2: Configure SERCOM3 as USART Peripheral and Pin Configuration
- Step 2.1 - Configure SERCOM3 as USART Peripheral
- Step 2.2 - Pin Configuration for SERCOM3 USART and LED
- Step 2.3 - Arm TrustZone for Armv8-M
- Step 2.4 - NVIC Verify
- Step 3: Generate Code
- Step 3.1 - Generate Code
- Step 4: Add application Code to the Project
- Application Code for the Project
- Step 5: Build, Program and Observe the Output
- Step 5.1 - Build, Hardware Setup, and Program
- Step 5.2 - Observe the Output