Forum Discussion
Altera_Forum
Honored Contributor
15 years agoHere's an example of a function to test the off-chip mem. It won't completely test the memory, but I think it is sufficient for what you're doing. MEM_TEST_VAL is whatever you want it to be as long as it's not bigger than 32 bits. Have fun.
int ddr2_mem_test() { int i; int error_count; int readbyte; error_count = 0; // Write to the memory needed. for(i=0; i<(MEM_SPAN); i++) { IOWR_32DIRECT(DDR2_SDRAM_BASE, i, MEM_TEST_VAL); } // Read back and verify data. for(i=0; i<(MEM_SPAN); i++) { readbyte = IORD_32DIRECT(DDR2_SDRAM_BASE, i); if (readbyte != MEM_TEST_VAL) { error_count++; } } return error_count; }