cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
habib81
Visitor
Visitor
171 Views
Registered: ‎05-19-2019

DMA interruption using microblaze

hello,

I want to use an interrupt signal from DMA to microblaze (nexys 4 ddr board) . Unfortunately, I can't turn it on. Please wheres is the problem. Here is the program I'm using:


#include "xaxidma.h"
#include "xparameters.h"
#include "xdebug.h"
#include "xil_io.h"
#include <stdio.h>
#include "platform.h"
#include "xintc.h"


#define DMA_DEV_ID XPAR_AXIDMA_0_DEVICE_ID
#define MEM_BASE_ADDR (XPAR_MIG7SERIES_0_BASEADDR +0x0000000)

#define RX_BUFFER_BASE (MEM_BASE_ADDR + 0x00200000)
#define TX_BUFFER_BASE (MEM_BASE_ADDR + 0x00300000)

#define MAX_PKT_LEN_WORDS 1000
#define MAX_PKT_LEN MAX_PKT_LEN_WORDS*4

#define RX_INTR_ID XPAR_INTC_0_AXIDMA_0_S2MM_INTROUT_VEC_ID
#define TX_INTR_ID XPAR_INTC_0_AXIDMA_0_MM2S_INTROUT_VEC_ID

#define INTC_DEVICE_ID XPAR_INTC_0_DEVICE_ID


#define RESET_TIMEOUT_COUNTER 10000

static XAxiDma AxiDma;
static XAxiDma_Config *CfgPtr;

static XIntc Intc;
static void RxIntrHandler(void *Callback);

volatile int TxDone;
volatile int RxDone;
volatile int Error;

volatile u32 *TxBufferPtr;
volatile u32 *RxBuffeuart;
volatile u32 Value;

int main()
{
int state = 0;


CfgPtr = XAxiDma_LookupConfig(XPAR_AXIDMA_0_DEVICE_ID);
XAxiDma_CfgInitialize(&AxiDma, CfgPtr);

/* Set up Interrupt system */

XAxiDma_IntrEnable(&AxiDma, XAXIDMA_IRQ_ALL_MASK,XAXIDMA_DEVICE_TO_DMA);

/* Initialize the interrupt controller and connect the ISRs */
XIntc_Initialize(&Intc, INTC_DEVICE_ID);

XIntc_Connect(&Intc, RX_INTR_ID, (XInterruptHandler)RxIntrHandler, (void *)0);
//XIntc_Enable(IntcInstancePtr, TxIntrId);
XIntc_Enable(&Intc,RX_INTR_ID);
/* Start the interrupt controller */
XIntc_Start(&Intc, XIN_REAL_MODE);

TxBufferPtr = (u32 *)RX_BUFFER_BASE;

for(u32 i = 1; i < MAX_PKT_LEN+1; i ++) {
TxBufferPtr [i-1]= i;

}


while (1) {
switch (state) {

case(0):
XAxiDma_SimpleTransfer(&AxiDma,(u32)TxBufferPtr, MAX_PKT_LEN, XAXIDMA_DEVICE_TO_DMA);

state = 1;
break;

case(1):

break;

}
}
}

static void RxIntrHandler(void *Callback)

{
u32 IrqStatus;
int TimeOut;
XAxiDma *AxiDmaInst = (XAxiDma *)Callback;

/* Read pending interrupts */
IrqStatus = XAxiDma_IntrGetIrq(AxiDmaInst, XAXIDMA_DEVICE_TO_DMA);

/* Acknowledge pending interrupts */
XAxiDma_IntrAckIrq(AxiDmaInst, IrqStatus, XAXIDMA_DEVICE_TO_DMA);

/*
* If no interrupt is asserted, we do not do anything
*/
if (!(IrqStatus & XAXIDMA_IRQ_ALL_MASK)) {
return;
}

/*
* If error interrupt is asserted, raise error flag, reset the
* hardware to recover from the error, and return with no further
* processing.
*/

if ((IrqStatus & XAXIDMA_IRQ_ERROR_MASK)) {
Error = 1;
/* Reset could fail and hang
* NEED a way to handle this or do not call it??
*/
XAxiDma_Reset(AxiDmaInst);

TimeOut = RESET_TIMEOUT_COUNTER;

while (TimeOut) {
if(XAxiDma_ResetIsDone(AxiDmaInst)) {
break;
}

TimeOut -= 1;
}

return;
}

/*
* If completion interrupt is asserted, then set RxDone flag
*/
if ((IrqStatus & XAXIDMA_IRQ_IOC_MASK)) {

for(u32 i = 1; i < MAX_PKT_LEN+1; i++) {

RxBuffeuart = TxBufferPtr + i - 1;
Value = Xil_In32((u32)RxBuffeuart);
xil_printf("%d\n",Value);
}

}
}

 

Tags (2)
0 Kudos
0 Replies