Forum Discussion
Altera_Forum
Honored Contributor
11 years agoAssuming you have your base address correct, try the following code;
# include <stdio.h>
# include "system.h"
int main()
{
int *pmem;
int i=0;
printf("Start!\n");
pmem=(int *)(0x80000000|(ONCHIP_MEMORY2_0_BASE));
for (i=0; i<15; i++)
{
printf("%u\n", *pmem++);
}
return 0;
}
The statement *pmem++ operates as follows; *pmem points to the 32-bit int, so your print statement prints out the value of the integer, and then the ++ increments the pointer by the size of the pointer, i.e., 32-bits. Your original code added i to a# define, so that would have only moved the pointer by a single byte. Cheers, Dave