• 0

C Code to read/write to DDR



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 !!

Share this post

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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);

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).

Edited by xc6lx45

Share this post

Link to post
Share on other sites
  • 0

Well i guess i didn't explained myself quite right.

I meant some (C) code to access de DDR via de XSDK, i.e. using the desgined and exported hardware in Vivado write a program to use the implemented DMA to access(red/write) the DDR.

thanks @xc6lx45 either way

Edited by dentiloque_roc

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