The simple DMA is OK. The width of the data is set to be 16 bits. The
[simple-dma.git] / hello_world.c
blob12905d5bf983c21129e2d723e3b37f123b581852
1 /*
2 * "Hello World" example.
4 * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on
5 * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example
6 * designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT
7 * device in your system's hardware.
8 * The memory footprint of this hosted application is ~69 kbytes by default
9 * using the standard reference design.
11 * For a reduced footprint version of this template, and an explanation of how
12 * to reduce the memory footprint for a given application, see the
13 * "small_hello_world" template.
16 #include <stdio.h>
17 #include "sdram_master.h"
18 #include "system.h"
19 #include "io.h"
21 int main()
23 unsigned char i,j;
24 int temp;
25 for(i=0;i<100;i++)
26 IOWR_8DIRECT(SDRAM_U1_BASE,i,i);
28 IOWR(SDRAM_MASTER_INST_BASE,S_ADDR,SDRAM_U1_BASE);
29 IOWR(SDRAM_MASTER_INST_BASE,D_ADDR,SDRAM_U2_BASE);
30 IOWR(SDRAM_MASTER_INST_BASE,LONGTH,100);
31 IOWR(SDRAM_MASTER_INST_BASE,START_ADDR,1);
33 temp=IORD(SDRAM_MASTER_INST_BASE,S_ADDR);
34 printf("S_ADDR:w,r==%d,%d\n",SDRAM_U1_BASE,temp);
35 temp=IORD(SDRAM_MASTER_INST_BASE,D_ADDR);
36 printf("D_ADDR:w,r==%d,%d\n",SDRAM_U2_BASE,temp);
37 temp=IORD(SDRAM_MASTER_INST_BASE,LONGTH);
38 printf("LONGTH:w,r==%d,%d\n",100,temp);
40 while(IORD(SDRAM_MASTER_INST_BASE,STATUS_ADDR)!=1){
41 printf("waiting...!\n");
42 //break;
45 for(i=0;i<100;i++){
46 j=IORD_8DIRECT(SDRAM_U1_BASE,i);
47 printf("SDRAM_U1:i,j == %d, %d\n",i,j);
49 for(i=0;i<100;i++){
50 j=IORD_8DIRECT(SDRAM_U2_BASE,i);
51 printf("SDRAM_U2:i,j == %d, %d\n",i,j);
55 printf("Hello from Nios II!\n");
57 return 0;