【ZYNQ-7000开发之四】在PS端使用AXI DMA传输的步骤

21 篇文章 7 订阅
16 篇文章 0 订阅

本篇文章简要总结下AXI DMA在ZYNQ PS端的初始化方法。本文摘抄自xilinx SDK的API文档,更加详细的内容请参考官方文档,这里只提取了关键部分。

 AXI DMA有两种模式,Direct Register Mode(不支持Scatter Gather)和   Scatter Gather Mode。
 AXI DMA用于AXI4 memory mapped和AXI4-Stream之间的转换
 Scatter Gather Mode性能更好,更消耗逻辑资源,使用更复杂一些。
 Direct Register Mode则相反。


AXI DMA更加详细的介绍请参考:pg021_axi_dma.pdf


使用AXI DMA传输的步骤:

Scatter Gather mode 

To use the Simple mode DMA engine for transfers, the following setup is required:

  • DMA Initialization using XAxiDma_CfgInitialize() function. This step initializes a driver instance for the given DMA engine and resets the engine.
  • Enable interrupts if chosen to use interrupt mode. The application is responsible for setting up the interrupt system, which includes providing and connecting interrupt handlers and call back functions, before enabling the interrupts.
  • Set the buffer address and length field in respective channels to start the DMA transfer

使用Scatter Gather mode 

To use the SG mode DMA engine for transfers, the following setup are required:

  • DMA Initialization using XAxiDma_CfgInitialize() function. This step initializes a driver instance for the given DMA engine and resets the engine.
  • Enable interrupts if chose to use interrupt mode. The application is responsible for setting up the interrupt system, which includes providing and connecting interrupt handlers and call back functions, before enabling the interrupts.

How to start DMA transactions

The user application uses XAxiDma_BdRingToHw() to submit BDs to the hardware to start DMA transfers.

For both channels, if the DMA engine is currently stopped (using XAxiDma_Pause()), the newly added BDs will be accepted but not processed until the DMA engine is started, using XAxiDma_BdRingStart(), or resumed, using XAxiDma_Resume().

Post-Processing 这个不是很了解

Software Post-Processing on completed DMA transactions

If the interrupt system has been set up and the interrupts are enabled, a DMA channels notifies the software about the completion of a transfer through interrupts. Otherwise, the user application can poll for completions of the BDs, using XAxiDma_BdRingFromHw() or XAxiDma_BdHwCompleted().

  • Once BDs are finished by a channel, the application first needs to fetch them from the channel using XAxiDma_BdRingFromHw().
  • On the TX side, the application now could free the data buffers attached to those BDs as the data in the buffers has been transmitted.
  • On the RX side, the application now could use the received data in the buffers attached to those BDs.
  • For both channels, completed BDs need to be put back to the Free group using XAxiDma_BdRingFree(), so they can be used for future transactions.
  • On the RX side, it is the application's responsibility to have BDs ready to receive data at any time. Otherwise, the RX channel refuses to accept any data if it has no RX BDs.

更多关于zynq开发相关的文章和问题请点击:
http://www.osrc.cn/forum.php?mod=forumdisplay&fid=292
http://blog.csdn.net/rzjmpb

  • 3
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值