Jump to content
  • 0

C Code to read/write to DDR


dentiloque_roc

Question

Hello,

so I followed this axi-dma tutorial and everything looks pretty fine.

Now, this tutorial only goes to running a HelloWorld application inside de XSDK. I would like to know how t write something to DDR and how to read something back (specifying addresses e.g.)?

To be precise this is how the actual design looks like

I would really appreciate some sample C code of how to instantiate (?) the AXI Slave/Master ports to be able to read something from the DDR.

Thanks !!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Warning, I'm guessing here (don't even own a Zynq).
But since people run Linux on those things, I guess there is stdlib with dynamic memory. So I'd expect something like this:

#include <stdlib.h> // malloc/free
#include <stdio.h> // printf
int main(void){
	volatile int* myPtr = (int*)calloc(123, sizeof(int));
	*myPtr = 0xDEADBEEF;
  	printf("%08x\n", *myPtr);
	free(myPtr);
}

I'd expect the memcpy() function to use DMA, where appropriate.
And "volatile" is not needed if nothing (e.g. an interrupt handler) can change the memory behind my back. It may slow down the code dramatically.

In a bare-metal design I could simply assign the pointer, e.g. int* myPtr = 0x8000 and double-check that the address won't collide with the stack (if it's in DRAM).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...