Forum Discussion

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

URGENT: IOWR problem

hello, i have a problem writing data into sdram on de2 board. when i generate 10 numbers (0-9) and write into sdram, it works fine. if i generate 100 numbers (0-99), it has a problem. here is my code:

# include <stdio.h># include <stdlib.h> # include <unistd.h># include "altera_avalon_pio_regs.h"# include "system.h"# include "alt_types.h"

int main()

{

int i, x;

printf("##### Performance Analysis# ####\n\n");

for(x = 0;x < 100; x++){

IOWR(SDRAM_BASE, x, x);

}

printf("Data in MEM1\n");

for(i = 0; i < 100; i++){

printf("%X\n",IORD(SDRAM_BASE, i));

}

return 0;

}

if i generate 100 numbers, at the console, it only prints out:

##### performance analysis# ####

then, after that all is blank.

it works fine if only 10 numbers are used.

please assist me! thanks!

7 Replies

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

    What memory is your code running from? If your code is also in SDRAM starting at address zero, then your test code would be overwriting itself. Testing from just 0 - 9 may still work as it might only be overwriting the reset vector location or some other small portion of memory no longer required by your code to continue proper execution.

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

    yes, my code is in SDRAM too... how do i know if my code is starting at address zero too? besides, how to fix it? how do i know my code ends at which address? sorry, i am new to this things. thanks!

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

    Why do you want to write to the SDRAM using IOWR macros, instead of using static variables or allocated memory?

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

    As Daixiwen said, there's normally no reason to use IOWR/IORD to access SDRAM. Anyway, if you really want to use IOWR you must be sure you are writing to a free ram area; you can do something like this:

    int sdram_array;
    for(x = 0;x < 100; x++){
       IOWR(SDRAM_BASE, &sdram_array, x);
       /* this is equivalent to   sdram_array = x  */
       }

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

    Daixiwen: Thanks for the info. I am new, so i am not sure there is some other ways to write to SDRAM? Can you please provide me with more info or maybe tutorials? thanks!

    Cris72: Thanks for the info! I plan to use flash memory but I dont know the setting in SOPC, not sure of the verilog code for the signal connection and i dont know how to access the flash memory? is it possible that you help me out with some basic info? thanks!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    I plan to use flash memory but I dont know the setting in SOPC, not sure of the verilog code for the signal connection and i dont know how to access the flash memory? is it possible that you help me out with some basic info? thanks!

    --- Quote End ---

    I can anwer you on specific issues but I can't write here all the information you require, since it seems you are starting from scratch.

    You'd better take a reference design using flash memory and learn from it, as anyone else here has probably done. On Altera website you'll find plenty of documentation and samples.

    You can also search the forum for useful hints.

    Regards