Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

Ddr sdram

Hi,

Can someone tell me how to read and write data to specified memory address like 0x02000001 and so on.

I'm programming with Eclipse and I declare an array like:

unsigned char buff[256][512];

I wanna write data in this array and after that I want to take the values from memory, so I have to know memory range.

Can anyone help me with this?

Regards

Kycas

6 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can use pointers for that. You can assign an address to a pointer.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thank You for an answer

    Can you show an example how to do with pointers, I'm not very good at C and I dont know how to use these pointers :)

    Or maybe it will be Ok if I just use IOWR_8DIRECT() for example?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Something like this should work:

    char *mypointer = 0x02000001;
    *mypointer = ...;

    You can also use the IORD/IOWR macros. The main difference between pointers and the IORD/WR macros is that a pointer access can use the data cache, while the IO macros will always bypass it.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Great!

    One more thing, should I just put all array of data with one IOWR() function, or should I make a loop and write byte by byte to memory?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It depends on your needs. Doing a 32-bit operation with a IOWR() or an (unsigned) int pointer will give you better performance than writing byte per byte.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I think the same thing. I have char type data, so I'll use IOWR_8DIRECT() with a loop.

    Oh and one more thing, if I declare some variables with value for example:

    float c[3][3] = {{1,1,1},

    {1,1,1},

    {1,1,1}};

    I think that this "c" will be put in SDRAM and if I write date with IOWR() function from the beginning of memory lets say. Won't the data that I want to write overlap the declared data "c"?

    Its kind of confusing with this to me...