Demonstrating 8-bit PIC® MCU Direct Memory Access (DMA)


This tutorial shows how to configure the PIC18F57Q43 Direct Memory Access (DMA) feature using Microchip’s MPLAB® Code Configurator (MCC). MCC is used to configure Core Independent Peripherals (CIPs) such as the DMA, Universal Asynchronous Receiver Transmitter (UART), Analog-to-Digital Converter (ADC), Timer, and Pulse Width Modulator (PWM).

A video version of this training is available on Microchip Technology's YouTube™ Channel "How to use DMA on 8 bit PIC® MCUs".


This tutorial makes use of Microchip’s Curiosity Nano Evaluation Boards and Microchip’s Curiosity Nano Adapter Boards to simplify hardware integration.

It showcases the capability of the PIC18F57Q43 DMA to transfer data between CIPs without using any CPU bandwidth.

The PIC18F57Q43 DMA is designed to service data transfers between different memory regions directly, without intervention from the CPU. By eliminating the need for CPU-intensive management of handling interrupts intended for data transfers, the CPU now can spend more time on other tasks.

The DMA modules can be independently programmed to transfer data between different memory locations, move different data sizes and use a wide range of hardware triggers to initiate transfers. The DMA modules can even be programmed to work together to carry out more complex data transfers without CPU overhead.

For more details about the features of the PIC1827/47/57Q43 device family, refer to the PIC18F27/47/57Q43 Datasheet.

MCC is a free graphical programming environment that generates seamless, easy-to-understand C code that is inserted into your project. It enables and configures a rich set of CIPs and functions using an intuitive interface. It is integrated into MPLAB X IDE to provide a powerful and easy-to-use development platform.

This training uses two PIC18F57Q43 Curiosity Nano Evaluation Kits (DM164150) and two Curiosity Nano Adapter Boards (AC164162), which are available from Microchip Purchasing and Client Services.

The application is based on two sets of software. The first performs regular ADC conversions on the potentiometer every 50 ms. When the DMA determines the UART transmit buffer is empty, it loads the ADC result to send the information via the UART. The second set of software moves the data from its UART receiver buffer, when it is full, to the PWM duty cycle register to modify the LED brightness.


The potentiometer varies the input voltage to MCU1’s ADC input. The LED connected to MCU2’s digital output changes according to the potentiometer position.

This application utilizes:

  • Timer0 to regularly trigger ADC conversions
  • ADC to read the potentiometer voltage
  • UART to send/receive data between MCUs
  • PWM to control LED brightness
  • DMA to transfer data between CIPs
  • General Purpose I/O (GPIO) to drive the LED

Two Ways to Use This Tutorial

  • Create the project from scratch:
    • Follow the step-by-step instructions to create the required software
  • Use the solution project as an example:
    • Build the solution projects and program them to the PIC18F57Q43 Curiosity Boards to observe the expected behavior

Lab Objectives

  • Create an MPLAB X IDE MCC project for a PIC18F57Q43 microcontroller from scratch
  • Use MCC to configure and generate peripheral libraries (PLIB) code for the following CIPs:
    • Timer0
    • ADC
    • UART
    • PWM
    • DMA
    • GPIO


Tool About Purchase
PIC18F57Q43 Curiosity Nano
Evaluation Kit
Curiosity Nano Base for Click Boards™
Evaluation Kit

Note: The Curiosity series evaluation boards include an on-board, embedded debugger. No external tools are necessary to program or debug the PIC18F57Q43. For programming/debugging, the debugger connects to the host PC through the USB Micro-B connector on the PIC18F57Q43 Curiosity Board.

Hardware Connection Setup


Apart from the hardware tools listed above, the following items are required:

  • 2 USB Type-A male to Micro-B male cable for programming and debugging
  • Potentiometer
  • 3 jumper wires to connect the potentiometer
  • 1 jumper wire for UART communication
  • 4 28-pin 100 mil male header strips
  • Breadboard

Connection Diagram

The application has the potentiometer connected to the ADC, LED connected to GPIO, and the host UART connected to the client UART.


This project has been verified to work with the following versions of software tools:

Because we regularly update our tools, occasionally you may discover an issue while using the newer versions. If you suspect that to be the case, we recommend that you double-check and use the same versions that the project was tested with.

Lab Solutions

This ZIP file contains the completed solution projects for this lab. The contents of this ZIP file can be placed in a folder of your choice. Both files are stored in a single GitHub repository. You will need to create a free account to download the files.

Note: Because MCC generates source and header files and libraries under the project folder, the contents of this ZIP file can be placed in any folder of your choice.

Lab Files on GitHub


Lab Index

Note: Steps 1 - 7 must be completed before you are ready to build, download, and run the application.

Step 1: Connect Hardware

  • Step 1.1 – Attach PIC18F57Q43 Curiosity Nano Evaluation Boards
  • Step 1.2 – Connect Potentiometer to Curiosity Nano Adapter Board
  • Step 1.3 – Attach a Jumper Wire from MCU1 UART TX to MCU2 UART RX
  • Step 1.4 - Verify Jumper Connections

Step 2: Create and Setup MPLAB X IDE Project for MCU1

  • Step 2.1 – Connect PIC18F57Q43 Curiosity Nano Evaluation Board to Computer
  • Step 2.2 – Create Project
  • Step 2.3 – Install MCC

Step 3: Configure MCU1 Resources with MCC

  • Step 3.1 - Launch MCC
  • Step 3.2 – System Module
  • Step 3.3 – Timer0
  • Step 3.4 – ADC
  • Step 3.5 – UART
  • Step 3.6 – GPIO
  • Step 3.7 – DMA
  • Step 3.8 – Generate MCC Code

Step 4: Build and Program MCU1

  • Step 4.1 – Build Project
  • Step 4.2 – Program MCU

Step 5: Create and Setup MPLAB X IDE Project for MCU2

  • Step 5.1 – Connect USB from PIC18F57Q43 Curiosity Nano Evaluation Board to Computer
  • Step 5.2 – Create Project

Step 6: Configure MCU2 Resources with MCC

  • Step 6.1 – Launch MCC
  • Step 6.2 – System Module
  • Step 6.3 – PWM
  • Step 6.4 – UART
  • Step 6.5 – GPIO
  • Step 6.6 – DMA
  • Step 6.7 – Update PWM Settings
  • Step 6.8 – Generate MCC Code

Step 7: Build and Program MCU2

  • Step 7.1 – Build Project
  • Step 7.2 – Program MCU

Step 8: Test Application

  • Step 8.1 – Verify Correct Operation
  • Step 8.2 – Results
  • Step 8.3 – Analysis
  • Step 8.4 – Conclusions
© 2023 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.