Skip to content

Infineon/mtb-hv-example-psoc4-dmac-1d-transfer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSoC™ 4: DMA 1D Transfer

This code example shows how to transfer data from source memory to destination memory using 1D transfer of the Direct Memory Access (DMA) function to implement.

Device

The device used in this code example (CE) is:

Board

The board used for testing is:

Scope of work

This example configures function to tarnsfer data from source memory to destination memory using 1D transfer function of the Direct Memory Access (DMA) function. Transfer result shows window for terminal software.

Introduction

The DMA controller provides DataWire (DW) and direct memory access (DMA) functionality. The DMA controller has the following features:

  • Supports up to four counter groups (device specific)
  • Supports eight DMA channels
  • Four levels of priority for each channel
  • Byte (8 bits), half-word (16 bits), and word (32 bits) transfers
  • Three modes of operation supported for each channel
  • Configurable interrupt generation
  • Output trigger on completion of transfer
  • Transfer sizes up to 65,536 data elements

The DMA controller supports three operation modes. These operational modes are different in how the DMA controller operates on a single trigger signal. These operating modes allow the user to implement different operation scenarios for the DMA. The operation modes are

  • Mode 0: Single data element per trigger
  • Mode 1: All data elements per trigger
  • Mode 2: All data elements per trigger and automatically trigger chained descriptor

The data transfer specifics, such as source and destination address locations and the size of the transfer, are specified by a descriptor structure. Each channel has an independent descriptor structure. The DMA controller provides active/sleep functionality and is not available in the DeepSleep power mode.

More details can be found in:

Hardware setup

This Code Example has been developed for:

Figure 1. KIT_PSoC4-HVMS-128K_LITE (Top View)

Implementation

The firmware is implemented in main.c and performs the following functions:

  1. Located transfer data (Source/Destination) in SRAM
  2. Initialize and enable GPIO interrupt
  3. Enable DMA Controller (DMAC) and initialize DMAC channel and descriptor configurations
  4. Enable using DMAC channel
  5. Set Trigger to initialize transfer
  6. Confirm results on the display of terminal software

ModusToolbox™ Device configurator

This code example project can be created or imported using ModusToolbox™ IDE. To configure the project in the Quick Panel, click on Device Configurator

Figure 2. Select Device Configurator

Figure 3. Select DMAC Channel 0

Figure 4. Parameter Settings for DMAC Channel 0

Figure 5. SCB-UART Settings

Figure 6. System Clock Settings

Figure 7. Peripheral Clock Settings

The basic idea is to display the results of a DMA transfer from source memory to destination memory in a Terminal window and visually compare the data on the source and destination sides.

Compiling and programming

Before testing this code example:

  • Power the board through the dedicated power connector
  • Connect the board to the PC through the USB interface
  • Build the project using the dedicated Build button

Figure 8. Build Project

or by right-clicking the project name and selecting "Build Project"

  • To program the board, in the Quick Panel, scroll down, and click [Project Name] Program (KitProg3_MiniProg4)

Run and Test

  • Open the terminal program (example download and install Tera term select the KitProg3 COM port. Set the serial port parameters to 8N1 and 115200 baud.

Figure 9. Terminal startup

In this example, the DMA 1D transfer was successful.

  • After programming, the code example will start automatically and display the transfer result.

Figure 10. Communication Results

  • You can debug the example to step through the code. In the IDE, use the [Project Name] Debug (KitProg3_MiniProg4) configuration in the Quick Panel. For details, see the "Program and debug" section in the Eclipse IDE for ModusToolbox™ software user guide.

Note: (Only while debugging) On the CM7 CPU, some code in main() may execute before the debugger halts at the beginning of main(). This means that some code executes twice: once before the debugger stops execution, and again after the debugger resets the program counter to the beginning of main(). See KBA231071 to learn about this and for the workaround.

References

Relevant Application notes are:

  • AN0034 - Getting started with PSOC™ 4 HV MS MCUs in ModusToolbox™

ModusToolbox™ is available online:

Associated PSoC™ 4 HVMS MCUs can be found on:

More code examples can be found on the GIT repository:

For additional trainings, visit our webpage:

For questions and support, use the PSoC™ 4 HVMS Forum: