cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
yeeyangtan
Observer
Observer
407 Views
Registered: ‎05-22-2021

AXI Stream DMA does not go into interrupt routine for receiving data

Jump to solution

My hardware connection is shown:

yeeyangtan_0-1622840345712.png

 

My program is written:

 

 

#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;
}

 

 

 However, I cannot go into the interrupt routine of the function "axidma_receive_interrupt_handler".

This is the result that I get:

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

I would like to make the program jump into the interrupt routine to read the data from dma, and this interrupt routine is triggered by the hardware (dma).

How can I solve this problem?

0 Kudos
1 Solution

Accepted Solutions
abommera
Xilinx Employee
Xilinx Employee
291 Views
Registered: ‎10-12-2018

Hi @yeeyangtan ,

Have you tried with Xilinx provided simple interrupt example?

https://github.com/Xilinx/embeddedsw/blob/master/XilinxProcessorIPLib/drivers/axidma/examples/xaxidma_example_simple_intr.c

Thanks & Regards
Anil B
-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------

View solution in original post

0 Kudos
1 Reply
abommera
Xilinx Employee
Xilinx Employee
292 Views
Registered: ‎10-12-2018

Hi @yeeyangtan ,

Have you tried with Xilinx provided simple interrupt example?

https://github.com/Xilinx/embeddedsw/blob/master/XilinxProcessorIPLib/drivers/axidma/examples/xaxidma_example_simple_intr.c

Thanks & Regards
Anil B
-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------

View solution in original post

0 Kudos