HI , I have written following code for writing and reading from DDR3 of zynq. It is not displaying any outputs. What's wrong with this:
1 | #include <stdio.h>
|
2 | #include "platform.h"
|
3 | #include "xil_printf.h"
|
4 | #include "xil_io.h"
|
5 | #include "xparameters.h"
|
6 | |
7 | #define DDR_BASEADDR 0x01000000
|
8 | //#define IN_BASEADDR DDR_BASEADDR + 0x1000000
|
9 | //#define TR_BASEADDR DDR_BASEADDR + 0x2000000
|
10 | //#define BIN_BASEADDR DDR_BASEADDR + 0x3000000
|
11 | |
12 | int main() |
13 | {
|
14 | init_platform(); |
15 | int i,j; |
16 | int val; |
17 | int img[5]={1,2,3,4,5}; |
18 | for (i = 0; i <5; i++) { |
19 | Xil_Out32(DDR_BASEADDR+(i), img[i]); |
20 | }
|
21 | for (j = 0; j <5; j++) { |
22 | val = Xil_In32(DDR_BASEADDR+(j)); |
23 | printf("val %d",val); |
24 | }
|
25 | cleanup_platform(); |
26 | return 0; |
27 | }
|
:
Edited by Moderator
Sai S. wrote: > It is not displaying any outputs. Maybe your monitor is broken? > It is not displaying any outputs. What happens instead? Where do you get "no output"? What do you expect to happen where? What do you get instead? Does a simple printf("Hello world!") show any output? BTW: Pls wrap your C code with the [c] tokens, as described in "Formatting options" a few lines above every text input box here.
:
Edited by Moderator
HI A simple "hello world" prints in console. The program i have posted prints nothing. But it compiles without any error.
Sai S. wrote: > But it compiles without any error Debug with single step or add some printf() to find out where your software stucks:
1 | int main() |
2 | {
|
3 | init_platform(); |
4 | printf("init done"); |
5 | int i,j; |
6 | int val; |
7 | int img[5]={1,2,3,4,5}; |
8 | for (i = 0; i <5; i++) { |
9 | Xil_Out32(DDR_BASEADDR+(i), img[i]); |
10 | }
|
11 | printf("memory written"); |
12 | for (j = 0; j <5; j++) { |
13 | val = Xil_In32(DDR_BASEADDR+(j)); |
14 | printf("val %d",val); |
15 | }
|
16 | printf("memory read"); |
17 | cleanup_platform(); |
18 | return 0; |
19 | }
|
BTW: where do you have the 0x01000000 from?
If your C library is buffering stdio(which I suppose it does), output will only arrive at the console if you initiate a buffer flush. Either provide at least a single "\n" to you output strings or do a fflush(stdoout).