UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Adam Taylor’s MicroZed Chronicles Part 68: AXI DMA Part 3, the Software

by Xilinx Employee on ‎02-09-2015 10:15 AM (73,354 Views)

By Adam Taylor

 

Having built and exported the hardware definition to SDK in last week’s blog post, see Adam Taylor’s MicroZed Chronicles Part 67: AXI DMA II, the next step in using the AXI DMA in the Zynq SoC is to write a simple program that streams data from the XADC. To do that, we need to configure the AXI DMA to perform a transfer.

 

AXI DMA can perform any of the following transfers, some of which are more complicated than others:

 

  • Simple DMA Polled
  • Simple DMA Interrupt Driven
  • Scatter-Gather Polled
  • Scatter-Gather Interrupt Driven

 

To use one of the scatter-gather options, we need to enable this ability within the AXI DMA component instantiation using Vivado. We’re not going to do that just yet. This example will use a simple polled DMA transfer to demonstrate the basic principles of DMA.

 

To get this up and running we need to do the following:

 

  • Initialize the XADC
  • Initialize the AXI DMA
  • Configure the XADC
    1. Set the Sequencer Mode to Safe
    2. Set / Disable the Alarms as required
    3. Set the Sequencer Channel enables
    4. Set the ADC clock divisor
    5. Set the Sequencer mode to the desired mode
  • Configure the XADC Adapter
  • Configure the AXI DMA
    1. Define the address within the memory map where the data received will be stored
    2. Reset the DMA and wait for this to be completed
    3. Disable the interrupts from the DMA
    4. Initiate the transfer. To do this we need:
      1. The instance of the AXDMA
      2. The address where data will be stored in memory
      3. The number of bytes to transfer
      4. The direction of the transfer
  • Wait until the DMA is no longer busy in the direction of the transfer
  • Check that the results are what was expected at the memory location

 

Although this process demonstrates use of the DMA, a polled approach is inefficient because the processor sits and waits until the DMA transfer completes. An interrupt-based system allows the processor to continue with its application while the DMA transfer completes. When it finishes the transfer, the DMA controller issues an interrupt to signal completion.

 

We have configured the XADC several times in past instalments of the MicroZed Chronicles using both XADCPS.h and SYSMON.h. However to get the AXI configured and running we will need to use the AXIDMA.h library. This library provides a number of useful functions. The configuration and initialisation of the AXIDMA is very similar to that used for all peripherals within the PS using the XXX_LookupConfig and XXXX_CfgInitialize functions. The driver files are available for inspection under the BSP->ps7_Cortex_a9_0->libsrc->axidma_v8_0->src:

 

 

Image1.jpg

 

 

The core function initiates the transfer using the simple transfer function below:

 

XAxiDma_SimpleTransfer(&AxiDma,(u32) RX_BUFFER_BASE,0x100, XAXIDMA_DEVICE_TO_DMA);

 

The code for the example is available on the github repository at:

https://github.com/ATaylorCEngFIET/MicroZed-Chronicles

 

In the next blog we will look at the constraints we can use in the build of a Zynq SoC system, what these constraints are, and why we need them.

 

Previous instalments of this series can be found at MicroZed Archive.

 

 

Please see the previous entries in this MicroZed Chronicles series by Adam Taylor:

 

Adam Taylor’s MicroZed Chronicles Part 67: AXI DMA II

 

Adam Taylor’s MicroZed Chronicles Part 66: AXI DMA

 

Adam Taylor’s MicroZed Chronicles Part 65: Profiling Zynq Applications II

 

Adam Taylor’s MicroZed Chronicles Part 64: Profiling Zynq Applications

 

Adam Taylor’s MicroZed Chronicles Part 63: Debugging Zynq Applications

 

Adam Taylor’s MicroZed Chronicles Part 62: Answers to a question on the Zynq XADC

 

Adam Taylor’s MicroZed Chronicles Part 61: PicoBlaze Part Six

 

Adam Taylor’s MicroZed Chronicles Part 60: The Zynq and the PicoBlaze Part 5—controlling a CCD

 

Adam Taylor’s MicroZed Chronicles Part 59: The Zynq and the PicoBlaze Part 4

 

Adam Taylor’s MicroZed Chronicles Part 58: The Zynq and the PicoBlaze Part 3

 

Adam Taylor’s MicroZed Chronicles Part 57: The Zynq and the PicoBlaze Part Two

 

Adam Taylor’s MicroZed Chronicles Part 56: The Zynq and the PicoBlaze

 

Adam Taylor’s MicroZed Chronicles Part 55: Linux on the Zynq SoC

 

Adam Taylor’s MicroZed Chronicles Part 54: Peta Linux SDK for the Zynq SoC

 

Adam Taylor’s MicroZed Chronicles Part 53: Linux and SMP

 

Adam Taylor’s MicroZed Chronicles Part 52: One year and 151,000 views later. Big, Big Bonus PDF!

 

Adam Taylor’s MicroZed Chronicles Part 51: Interrupts and AMP

 

Adam Taylor’s MicroZed Chronicles Part 50: AMP and the Zynq SoC’s OCM (On-Chip Memory)

 

Adam Taylor’s MicroZed Chronicles Part 49: Using the Zynq SoC’s On-Chip Memory for AMP Communications

 

Adam Taylor’s MicroZed Chronicles Part 48: Bare-Metal AMP (Asymmetric Multiprocessing)

 

Adam Taylor’s MicroZed Chronicles Part 47: AMP—Asymmetric Multiprocessing on the Zynq SoC

 

Adam Taylor’s MicroZed Chronicles Part 46: Using both of the Zynq SoC’s ARM Cortex-A9 Cores

 

Adam Taylor’s MicroZed Chronicles Part 44: MicroZed Operating Systems—FreeRTOS

 

Adam Taylor’s MicroZed Chronicles Part 43: XADC Alarms and Interrupts 

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 42: MicroZed Operating Systems Part 4

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 41: MicroZed Operating Systems Part 3

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 40: MicroZed Operating Systems Part Two

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 39: MicroZed Operating Systems Part One

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 38 – Answering a question on Interrupts

 

Adam Taylor’s MicroZed Chronicles Part 37: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 8

 

Adam Taylor’s MicroZed Chronicles Part 36: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 7

 

Adam Taylor’s MicroZed Chronicles Part 35: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 6

 

Adam Taylor’s MicroZed Chronicles Part 34: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 5

 

Adam Taylor’s MicroZed Chronicles Part 33: Driving Adafruit RGB NeoPixel LED arrays with the Zynq SoC

 

Adam Taylor’s MicroZed Chronicles Part 32: Driving Adafruit RGB NeoPixel LED arrays

 

Adam Taylor’s MicroZed Chronicles Part 31: Systems of Modules, Driving RGB NeoPixel LED arrays

 

 Adam Taylor’s MicroZed Chronicles Part 30: The MicroZed I/O Carrier Card

 

Zynq DMA Part Two – Adam Taylor’s MicroZed Chronicles Part 29

 

The Zynq PS/PL, Part Eight: Zynq DMA – Adam Taylor’s MicroZed Chronicles Part 28  

 

The Zynq PS/PL, Part Seven: Adam Taylor’s MicroZed Chronicles Part 27

 

The Zynq PS/PL, Part Six: Adam Taylor’s MicroZed Chronicles Part 26

 

The Zynq PS/PL, Part Five: Adam Taylor’s MicroZed Chronicles Part 25

 

The Zynq PS/PL, Part Four: Adam Taylor’s MicroZed Chronicles Part 24

 

The Zynq PS/PL, Part Three: Adam Taylor’s MicroZed Chronicles Part 23

 

The Zynq PS/PL, Part Two: Adam Taylor’s MicroZed Chronicles Part 22

 

The Zynq PS/PL, Part One: Adam Taylor’s MicroZed Chronicles Part 21

 

Introduction to the Zynq Triple Timer Counter Part Four: Adam Taylor’s MicroZed Chronicles Part 20

 

Introduction to the Zynq Triple Timer Counter Part Three: Adam Taylor’s MicroZed Chronicles Part 19

 

Introduction to the Zynq Triple Timer Counter Part Two: Adam Taylor’s MicroZed Chronicles Part 18

 

Introduction to the Zynq Triple Timer Counter Part One: Adam Taylor’s MicroZed Chronicles Part 17

 

The Zynq SoC’s Private Watchdog: Adam Taylor’s MicroZed Chronicles Part 16

 

Implementing the Zynq SoC’s Private Timer: Adam Taylor’s MicroZed Chronicles Part 15

 

MicroZed Timers, Clocks and Watchdogs: Adam Taylor’s MicroZed Chronicles Part 14

 

More About MicroZed Interrupts: Adam Taylor’s MicroZed Chronicles Part 13

 

MicroZed Interrupts: Adam Taylor’s MicroZed Chronicles Part 12

 

Using the MicroZed Button for Input: Adam Taylor’s MicroZed Chronicles Part 11

 

Driving the Zynq SoC's GPIO: Adam Taylor’s MicroZed Chronicles Part 10

 

Meet the Zynq MIO: Adam Taylor’s MicroZed Chronicles Part 9

 

MicroZed XADC Software: Adam Taylor’s MicroZed Chronicles Part 8

 

Getting the XADC Running on the MicroZed: Adam Taylor’s MicroZed Chronicles Part 7

 

A Boot Loader for MicroZed. Adam Taylor’s MicroZed Chronicles, Part 6 

 

Figuring out the MicroZed Boot Loader – Adam Taylor’s MicroZed Chronicles, Part 5

 

Running your programs on the MicroZed – Adam Taylor’s MicroZed Chronicles, Part 4

 

Zynq and MicroZed say “Hello World”-- Adam Taylor’s MicroZed Chronicles, Part 3

 

Adam Taylor’s MicroZed Chronicles: Setting the SW Scene

 

Bringing up the Avnet MicroZed with Vivado

 

 

 

 

Comments
by Visitor orenderj
on ‎02-17-2015 05:57 PM

The past couple examples on the DMA usage have been something I have been waiting for Adam to cover for a while. I'm not really sure that I have this example properly working and the level of detail isn't as deep as some of the previous posts, making debugging a little difficult. I am trying to use this as a base project to be able to gather large amounts of samples from a different ADC, but I dont think I have this code working yet. If I read back the DDR contents, it is basically garbage data right now. Also, the SDK complains about the fifo adapter device type. I think I fixed this by replacing it with a zero.

 

Anyway, has anyone successfully had this example working that could help me out?

 

I am using Vivado 2014.4

 

Thanks a bunch.

by Observer taylo_ap
on ‎03-02-2015 03:14 PM

orenderj

 

I did work when I tested it in vivado 2014.1 ( i am a little behind due to internet issues at home) Im about to travel for a few days but will try and look into it quickly for you 

 

Adam 

by Observer taylo_ap
on ‎03-02-2015 04:11 PM

orenderj

 

While I am traveling it might beworth you looking at the example which you can find under the MSS file. you will need to modify the hardware to soemthing that acts as a store a fifo etc 

 

Also checkout this thread 

 

Drop me an email if you want to chat more about it aptaylor@theiet.org

 

Regards

 

Adam

Labels
About the Author
  • Be sure to join the Xilinx LinkedIn group to get an update for every new Xcell Daily post! ******************** Steve Leibson is the Director of Strategic Marketing and Business Planning at Xilinx. He started as a system design engineer at HP in the early days of desktop computing, then switched to EDA at Cadnetix, and subsequently became a technical editor for EDN Magazine. He's served as Editor in Chief of EDN Magazine, Embedded Developers Journal, and Microprocessor Report. He has extensive experience in computing, microprocessors, microcontrollers, embedded systems design, design IP, EDA, and programmable logic.