取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
12ff7a6
Visitor
Visitor
296 次查看
注册日期: ‎01-29-2021

AXI DMA 没有正确接收数据

大家好,我现在正在学习AXI DMA。我在PL端创建了一个计数器(两个二进制计数器组成,一个作为计数器,另一个作为tlast计数器),希望将数字通过AXI DMA存入DDR。然后在PS端读取数字。我的计数器的tlast设定为32,也就是DMA一次可以接收32*32bit的数字, 但是目前我只能在DDR中看到0到7,之后就都不行了。我的硬件设计和c代码如下。我看到有些设计范例中,数据发生器和DMA之间还会有一个fifo。请问这个fifo是必要的吗?

 

非常感谢

bd.png

/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc.  All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/

/*
 * helloworld.c: simple test application
 *
 * This application configures UART 16550 to baud rate 9600.
 * PS7 UART (Zynq) is not initialized by this application, since
 * bootrom/bsp configures it to baud rate 115200
 *
 * ------------------------------------------------
 * | UART TYPE   BAUD RATE                        |
 * ------------------------------------------------
 *   uartns550   9600
 *   uartlite    Configurable only in HW design
 *   ps7_uart    115200 (configured by bootrom/bsp)
 */

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "psu_init.h"
#include "xscugic.h"
#include "xparameters.h"
#include <xil_io.h>
#include "xgpio.h"
#include "xaxidma.h"
#include "xil_cache.h"

#ifndef DDR_BASE_ADDR
#warning CHECK FOR THE VALID DDR ADDRESS IN XPARAMETERS.H, \
		 DEFAULT SET TO 0x01000000
#define MEM_BASE_ADDR		0x01000000
#else
#define MEM_BASE_ADDR		(DDR_BASE_ADDR + 0x1000000)
#endif

#define RX_BUFFER_BASE		(MEM_BASE_ADDR + 0x00550000)

#define MAX_PKT_LEN		0x500

#define NUMBER_OF_TRANSFERS	1

XAxiDma AxiDma;



int main()
{
	XAxiDma_Config *CfgPtr;
	int Status;
	int Tries = NUMBER_OF_TRANSFERS;
	int Index;
	u32 *RxBufferPtr;
	u32 reg;

	RxBufferPtr = (u32 *)RX_BUFFER_BASE;

	init_platform();
	/* Initialize the XAxiDma device.
	 */
	CfgPtr = XAxiDma_LookupConfig(XPAR_AXI_DMA_0_DEVICE_ID);
	if (!CfgPtr) {
		xil_printf("No config found for %d\r\n", XPAR_AXI_DMA_0_DEVICE_ID);
		return XST_FAILURE;
	}
	xil_printf("config found for %d\r\n", XPAR_AXI_DMA_0_DEVICE_ID);

	Status = XAxiDma_CfgInitialize(&AxiDma, CfgPtr);
	if (Status != XST_SUCCESS) {
		xil_printf("Initialization failed %d\r\n", Status);
		return XST_FAILURE;
	}
	xil_printf("Initialization success %d\r\n", Status);

	if(XAxiDma_HasSg(&AxiDma)){
		xil_printf("Device configured as SG mode \r\n");
		return XST_FAILURE;
	}
	xil_printf("Device configured as simple mode \r\n");
	/* Disable interrupts, we use polling mode
	 */
	XAxiDma_IntrDisable(&AxiDma, XAXIDMA_IRQ_ALL_MASK,
						XAXIDMA_DEVICE_TO_DMA);
	xil_printf("interrupts disabled \r\n");
	XAxiDma_IntrDisable(&AxiDma, XAXIDMA_IRQ_ALL_MASK,
						XAXIDMA_DMA_TO_DEVICE);

	getchar();

	for(Index = 0; Index < Tries; Index ++) {

		/* Flush the buffers before the DMA transfer, in case the Data Cache
		 * is enabled
		 */
		Xil_DCacheFlushRange((UINTPTR)RxBufferPtr + Index*0x20, MAX_PKT_LEN);
		xil_printf("Tries: %d\r\n", Index);

		reg = Xil_In32(XPAR_AXI_DMA_0_BASEADDR + 0x34);
		xil_printf("S2MM Status register: %d\r\n", reg);

		Status = XAxiDma_SimpleTransfer(&AxiDma, (UINTPTR)RxBufferPtr + Index*0x20,
					MAX_PKT_LEN, XAXIDMA_DEVICE_TO_DMA);

		//enable counter
		Xil_Out32(XPAR_AXI_GPIO_2_BASEADDR, 1);

		if (Status != XST_SUCCESS) {
			return XST_FAILURE;
		}


		sleep(1);
		XAxiDma_Reset(&AxiDma);

	}


}

dram.png

0 项奖励
3 回复数
longley
Xilinx Employee
Xilinx Employee
229 次查看
注册日期: ‎04-15-2011

逻辑通过stream接口把数据给到DMA,可以不用FIFO。

调试AXI DMA, 可以先通过ILA确认数据是不是通过AXI stream口都给到DMA了,并且DMA把所有数据都通过AXI接口写到DDR里,还是只写了一部分就停止了。

你可以读取DMA的寄存器看看有没有状态异常值。

Thanks,

Longley


------------------------------------------------------------------------------------------------

Don’t forget to reply, kudo, and accept as solution.

If starting with Versal take a look at our Versal Design Process Hub and our
Versal Blogs

------------------------------------------------------------------------------------------------
0 项奖励
12ff7a6
Visitor
Visitor
213 次查看
注册日期: ‎01-29-2021

感谢回复,我想我找到了解决办法。我的dma之前的buffer宽度过低。设定为24比特之后可以正常接收数据。另外我想请教一下FIFO的使用场景。我的理解是FIFO在跨时钟频率中应用的比较普遍,例如计数器和dma不在同一个时钟频率,请问对吗?

longley
Xilinx Employee
Xilinx Employee
168 次查看
注册日期: ‎04-15-2011

你的理解是对的

Thanks,

Longley


------------------------------------------------------------------------------------------------

Don’t forget to reply, kudo, and accept as solution.

If starting with Versal take a look at our Versal Design Process Hub and our
Versal Blogs

------------------------------------------------------------------------------------------------
0 项奖励