取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
yeeyangtan
Observer
Observer
370 次查看
注册日期: ‎05-23-2021

axi dma rx 进入不了interrupt handler

这是我的硬件连接方式

yeeyangtan_0-1622894910994.png

然后我的程序是

#include "xparameters.h"
#include "xil_io.h"
#include "xil_exception.h"
#include "xaxidma.h"
#include "xscugic.h"

int flag = 1;

void axidma_receive_interrupt_handler(void *call_back_ref)
{
	int status;

	XAxiDma *inst_axidma = (XAxiDma*) call_back_ref;

	xil_printf("Receive interrupt\n");

	u32 *rx_buffer = malloc(sizeof(u32)*10);

	status = XAxiDma_SimpleTransfer(inst_axidma, rx_buffer, 10*4, XAXIDMA_DEVICE_TO_DMA);

	if (status == XST_SUCCESS)
		xil_printf("transfer success\n");
	else
		xil_printf("transfer fail\n");

	for(int i = 0; i < 10; i++)
		xil_printf("rx_buffer[%i]=%x\n",i, rx_buffer[i]);

	flag = 0;
}

void axidma_transfer_interrupt_handler(void *call_back_ref)
{
	XAxiDma *inst_axidma = (XAxiDma*) call_back_ref;

	xil_printf("Transfer interrupt\n");
}

int setup(XAxiDma *inst_dma, XScuGic *inst_gic)
{
	int status;

	XAxiDma_Config *cfg_dma = XAxiDma_LookupConfig(XPAR_AXIDMA_0_DEVICE_ID);
	status = XAxiDma_CfgInitialize(inst_dma, cfg_dma);
	if (status != XST_SUCCESS){
		xil_printf("Error: XAxiDma_CfgInitialize\n");
		return status;
	}

	XScuGic_Config *cfg_gic = XScuGic_LookupConfig(XPAR_SCUGIC_0_DEVICE_ID);
	status = XScuGic_CfgInitialize(inst_gic, cfg_gic, cfg_gic->CpuBaseAddress);
	if (status != XST_SUCCESS){
		xil_printf("Error: XScuGic_CfgInitialize\n");
		return status;
	}

	XScuGic_SetPriorityTriggerType(inst_gic, XPAR_FABRIC_AXI_DMA_0_MM2S_INTROUT_INTR, 0xA0, 0x3);
	XScuGic_SetPriorityTriggerType(inst_gic, XPAR_FABRIC_AXI_DMA_0_S2MM_INTROUT_INTR, 0xA0, 0x3);

	status = XScuGic_Connect(
			inst_gic,
			XPAR_FABRIC_AXI_DMA_0_MM2S_INTROUT_INTR,
			(Xil_ExceptionHandler)axidma_transfer_interrupt_handler,
			&inst_dma
	);
	if (status != XST_SUCCESS){
		xil_printf("Error: XScuGic_Connect - XPAR_FABRIC_AXI_DMA_0_MM2S_INTROUT_INTR\n");
		return status;
	}

	status = XScuGic_Connect(
			inst_gic,
			XPAR_FABRIC_AXI_DMA_0_S2MM_INTROUT_INTR,
			(Xil_ExceptionHandler)axidma_receive_interrupt_handler,
			&inst_dma
	);
	if (status != XST_SUCCESS){
		xil_printf("Error: XScuGic_Connect - XPAR_FABRIC_AXI_DMA_0_S2MM_INTROUT_INTR\n");
		return status;
	}

	XScuGic_Enable(inst_gic, XPAR_FABRIC_AXI_DMA_0_MM2S_INTROUT_INTR);
	XScuGic_Enable(inst_gic, XPAR_FABRIC_AXI_DMA_0_S2MM_INTROUT_INTR);

	Xil_ExceptionInit();
	Xil_ExceptionRegisterHandler(
			XIL_EXCEPTION_ID_INT,
			(Xil_ExceptionHandler)XScuGic_InterruptHandler,
			(void *)inst_gic);
	Xil_ExceptionEnable();

	return XST_SUCCESS;
}

int main()
{
	xil_printf("-----------------------\n");
	xil_printf("Start\n");
	xil_printf("-----------------------\n");

	int status;
	XAxiDma inst_dma;
	XScuGic inst_gic;

	status = setup(&inst_dma, &inst_gic);

	XAxiDma_IntrDisable(&inst_dma, XAXIDMA_IRQ_ALL_MASK,
						XAXIDMA_DMA_TO_DEVICE);
	XAxiDma_IntrDisable(&inst_dma, XAXIDMA_IRQ_ALL_MASK,
				XAXIDMA_DEVICE_TO_DMA);

//	XAxiDma_IntrEnable(&inst_dma, XAXIDMA_IRQ_ALL_MASK,
//							XAXIDMA_DMA_TO_DEVICE);
	XAxiDma_IntrEnable(&inst_dma, XAXIDMA_IRQ_ALL_MASK,
							XAXIDMA_DEVICE_TO_DMA);

	u32 *tx_buffer = malloc(sizeof(u32)*10);
	for(int i = 0; i < 10; i++)
		tx_buffer[i] = i;


	status = XAxiDma_SimpleTransfer(&inst_dma, tx_buffer, 10*4, XAXIDMA_DMA_TO_DEVICE);

	if (status == XST_SUCCESS)
		xil_printf("transfer success\n");
	else
		xil_printf("transfer fail\n");

	while(flag);

	xil_printf("-----------------------\n");
	xil_printf("End\n");
	xil_printf("-----------------------\n");
	return XST_SUCCESS;
}

可是我的程序一直卡在while循环里,程序只显示

-----------------------
Start
-----------------------
transfer success

想问真么才能让程序进入 axidma_receive_interrupt_handler 的interrupt routine,并且这个interrupt

 是由硬件发起的?

原英文原帖:https://forums.xilinx.com/t5/Embedded-Development-Tools/AXI-Stream-DMA-does-not-go-into-interrupt-routine-for-receiving/td-p/1250133 

 

标记 (3)
0 项奖励
1 回复
longley
Xilinx Employee
Xilinx Employee
290 次查看
注册日期: ‎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 项奖励