EmbDev.net

Forum: FPGA, VHDL & Verilog problem in writing and reading from DDR3 in zed board


von Sai S. (Company: sssihl) (shashidhar)


Rate this post
useful
not useful
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
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
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
von Sai S. (Company: sssihl) (shashidhar)


Rate this post
useful
not useful
HI
A simple "hello world" prints in console.

The program i have posted prints nothing. But it compiles without any 
error.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
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?

von Sai S. (Company: sssihl) (shashidhar)


Rate this post
useful
not useful
0x01000000 is my DDR3 address

von Markus F. (mfro)


Rate this post
useful
not useful
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).

von Sai S. (Company: sssihl) (shashidhar)


Rate this post
useful
not useful
thank you

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.