Altera_Forum
Honored Contributor
13 years agoHow to fill SDRAM with dummy values
I am working with the Altera DE2 board and want to use the SDRAM to store pictures. I fill my SDRAM chip with a dummy value (all x00 or xFF) and when I see a value that is different I know that is where my picture starts.
I am using a book on how to perform rapid prototyping and there was example code on how to write and read from SDRAM but the code has me very confused as to how this is happening. 1.) When I highlight buffer it reads 0x800000, the base address of SDRAM. But buffer is declared as a pointer and assigned the defined value SDRAM_BASE which has been casted to be a integer pointer. Since buffer is a pointer shouldn't the value be the address of where SDRAM_BASE is located, which contains the actual value? Going through debug in nios, I could not see what the value of buffer was only that buffer was 80000.
2.) in the for loop it appears that buffer is assigning sequential addresses in SDRAM to some incremented value of 100000. But the buffer pointer has the address of SDRAM_BASE, wouldn't I be overwriting the address value with a aformentioned incremented value? I do not understand why buffer is treated as an array, or how buffer[0] could correspond to write data to address 0x800000. 3.) Not sure as to how many loops I would need to fill all 8 MB. The book example gave 1000000 loops. But if buffer[0] is address 0x800000 and I assign it 1000000 does this mean that memory address will have 16 bits equal 1000000? SDRAM is configured as 4,194,304 words x 16 bits. I wanted to make the loop 4194303 but that throw a bunch of errors in Nios. Is my thinking correct? This is for my senior design project and this hiccup has made my project a week behind schedule, but any help or advice would be greatly appreciated.
define SDRAM_BASE 0x800000
alt_u32 *buffer = (alt_u32 *)SDRAM_BASE;
/* Write data to SDRAM */
for( i = 0; i < SDRAM_MAX_WORDS; i++ ) {
buffer = i + 1000000;
temp = buffer;
}