Code Examples

Code examples for configuring the DMA controller can be found in the examples referenced below. The examples show how to configure the DMA module to work with software/hardware triggers.

Example-1 shows the setup of the DMA module to transfer 512 bytes of data from the EEPROM to user RAM. This can be an application where a look-up table is stored in the EEPROM and can be made available in the RAM for faster access at run time.

Example-2 shows the setup of the DMA module to transfer 20 bytes of data between the user RAM and the UART transmit buffer. In this example, the UART transmit interrupt is used as a trigger for DMA operation.

Example-3 shows the setup of the DMA module to transfer data from the flash memory to PWM duty cycle registers, but an abort trigger is set up for an event on an I/O pin.

Note: These examples are written for the PIC18F47K42. Minor edits may be required to make them compatible for other devices that have the DMA module.
Tip: Refer to the examples on the MPLAB Xpress Code Examples webpage for a working application code.