Beginner Lab 12: DMA Demonstration
Last modified by Microchip on 2026/06/29 11:00
Objective
- Demonstrate and compare data transfer operations with and without CPU intervention by performing memory-to-memory transfers using both Direct Memory Access (DMA) and non-DMA (CPU-driven) methods on the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit.
- Measure and compare the number of transfer cycles required for each method using the SysTick timer, emphasizing the performance advantages of DMA-based transfers.
- Transmit transfer status and cycle count information to a serial console via SERCOM Universal Asynchronous Receiver/Transmitter (UART).
- Implement and analyze the application using MPLAB® X IDE.
Overview
This lab exercise demonstrates the effectiveness of DMA in enhancing data transfer efficiency within embedded systems, using the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit. The application is developed and tested in MPLAB X IDE.
Two memory-to-memory data transfer methods are implemented and evaluated:
- CPU-driven transfer (without DMA): The CPU actively copies data between memory locations.
- DMA-driven transfer (without CPU intervention): The DMA controller autonomously performs the data transfer.
Lab Activities
- Configure the DMA controller by setting the source address, destination address, transfer size, and enabling the DMA channel.
- Set up the SysTick timer in the project to function as a transfer cycle counter. Initialize the SysTick counter before starting the memory transfer. Read the cycle count after the transfer completes.
- Configure SERCOM UART for serial communication to print transfer status messages and transfer cycle counts to the console. Verify correct UART operation by observing the output on the serial terminal.
- Implement application code to perform memory-to-memory data transfers both with and without DMA, allowing observation of CPU intervention.
- Observe and compare the UART console outputs from both methods. Analyze the differences in transfer cycles for DMA and non-DMA transfers, confirming that DMA-based transfers complete in fewer cycles and operate more efficiently.
Expected Outcomes
Upon completing this lab, you will be able to:
- Configure and initialize the DMA controller by correctly setting the source address, destination address, transfer size and enabling the DMA channel for memory-to-memory data transfers.
- Set up and use the SysTick timer as a transfer cycle counter to measure and compare the number of cycles consumed during data transfer operations.
- Configure SERCOM UART for serial communication and verify its operation by observing transfer status messages and cycle count outputs on a serial console.
- Develop and integrate application code to perform memory-to-memory data transfers both with and without DMA, demonstrating the impact of CPU intervention.
- Observe, analyze, and compare UART console outputs from both transfer methods to evaluate performance differences.
- Conclude that DMA-based data transfers require fewer transfer cycles and operate more efficiently than CPU-driven transfers, reinforcing the advantages of using DMA in embedded systems.
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: DMA Based CPU Optimization
- Step 1.1 - Direct Memory Access (DMA)
- Step 1.2 - DMA-Based Data Transfer and CPU Resource Optimization
- Step 2: Configure SERCOM3, SysTick and DMA
- Step 2.1 - Configure SERCOM3 as USART peripheral
- Step 2.2 - Pin Configuration for SERCOM 3
- Step 2.3 - Configure SysTick Timer
- Step 2.4 - Arm® TrustZone® for Armv8-M
- Step 2.5 - Configure DMA
- Step 3: Generate Code
- Step 3.1 - Generate Code
- Step 4: Add Application Code to the Project
- Step 4.1 - Application Code for CPU-driven transfer
- Step 4.2 - Application Code for DMA-driven transfer
- Step 5: Build, Program and Observe the Output
- Step 5.1 - Build, Hardware setup, and Program
- Step 5.2 - Observe the Output for CPU-Driven Transfer
- Step 5.3 - Observe the Output for DMA-Driven Transfer
- Step 5.4 - Output Comparison for CPU-Driven and DMA-Driven transfers