Forum Discussion
Altera_Forum
Honored Contributor
13 years agoHi,
please can you tell me if my SW code is correct: in each on chip memory of NIOS I write the same code: # include <stdio.h> # include "system.h" # include <stdlib.h> # include "io.h" # define SHAREDMEM_BASE 0x00008000 int main() { int id,data; int i,j; int temp; id = ALT_CPU_CPU_ID_VALUE; printf("Hello from Nios II! %d \n",ALT_CPU_CPU_ID_VALUE); if (id==1) {IOWR(SHAREDMEM_BASE, 0, 0x9); data = IORD(SHAREDMEM_BASE, 0x0); printf("data read = %x \n",data); } else { for (i=0;i<5000000;i++) j++; //to assure that NIOS1 has written the data temp=IORD(SHAREDMEM_BASE, 0x0); printf("temp read = %d \n",temp); } return 0; } When executing this code I obtained : data=9 which is right temp=1734829426 which is false !!! What's wrong in this code??