• 0
Rickdegier

Axi DMA from all memory

Question

Hey guys I am

relatively new to working with Xilinx and zynq. Right now I can control an co-processor using the axi dma, but it works only for with defined addresses as seen below.

#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 TX_BUFFER_BASE		(MEM_BASE_ADDR + 0x00100000)
#define RX_BUFFER_BASE		(MEM_BASE_ADDR + 0x00300000)
#define RX_BUFFER_HIGH		(MEM_BASE_ADDR + 0x004FFFFF)

TxBufferPtr = (u8 *)TX_BUFFER_BASE;
RxBufferPtr = (u8 *)RX_BUFFER_BASE;
Status = XAxiDma_SimpleTransfer(&AxiDma,(UINTPTR) RxBufferPtr,
								MAX_PKT_LEN, XAXIDMA_DEVICE_TO_DMA);

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

Status = XAxiDma_SimpleTransfer(&AxiDma,(UINTPTR) TxBufferPtr,
								MAX_PKT_LEN, XAXIDMA_DMA_TO_DEVICE);

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

 

Is it possible to control the axi dma using normal array declerations as seen below, if so is it a setting in hardware design or in software?

float input_R_IM[N_samples*2];
float output_R_IM[N_samples*2];
int error=-1;
XAxiDma dma0_pointer;
XAxiDma_Config *dma0_Config;

/**********************DMA initialization***************************/

dma0_Config=XAxiDma_LookupConfig(XPAR_AXIDMA_0_DEVICE_ID);
error=XAxiDma_CfgInitialize(&dma0_pointer,dma0_Config);

float d = 2 * (float)M_PI / N_samples;
size_t i=NULL;

for (i = 0; i < N_samples; i++)
{
	input_R_IM[i*2]=sin(0 + d*i);
    input_R_IM[i*2+1]=0;
}

error=-1;
error = XAxiDma_SimpleTransfer(&dma0_pointer,(u32)input_R_IM,2*N_samples*sizeof(float),XAXIDMA_DMA_TO_DEVICE);

/***********************COPY BACK THE RESULTS************************/
//  error=-1;
error = XAxiDma_SimpleTransfer(&dma0_pointer,(u32)output_R_IM,2*N_samples*sizeof(float),XAXIDMA_DEVICE_TO_DMA);

for (i = 0; i < N_samples; i++)
{
	printf("i: %d real=> %f  --imag==> %f \n" ,i, output_R_IM[i*2], output_R_IM[i*2+1]);
}
return 0;
}

 

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
Posted (edited)

Hi @Rickdegier,

Welcome to the Digilent forums!

I am not the most confident on this topic, but I have used the DMA some. The most important facet here is to make sure that your buffer is actually contained in the DDR memory. Different parts of the program can be placed in different memories using the linker script in your application project's src folder (lscript.ld). You should check that file to make sure that your global arrays are placed in the DDR. Second, if the data cache is enabled (likely), you should make sure to flush and invalidate the buffer memory area around your SimpleTransfer calls (functions to do this are in xil_cache.h). Lastly, I personally have had more success using malloc to create my buffers than using global or local arrays - I'm not sure why this is, from a cursory google search, it looks like the DMA will allow transfers into program memory when you aren't careful. You may want to reach out to Xilinx on their forums.

Thanks,

Arthur

Edited by artvvb
correct potential misinformation

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now