EmbDev.net

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


Author: Sai S. (Company: sssihl) (shashidhar)
Posted on:

Rate this post
0 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:
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xil_io.h"
#include "xparameters.h"

#define DDR_BASEADDR 0x01000000
//#define IN_BASEADDR DDR_BASEADDR + 0x1000000
//#define TR_BASEADDR    DDR_BASEADDR + 0x2000000
//#define BIN_BASEADDR   DDR_BASEADDR + 0x3000000

int main()
{
   init_platform();
    int i,j;
    int val;
    int img[5]={1,2,3,4,5};
    for (i = 0; i <5; i++) {
      Xil_Out32(DDR_BASEADDR+(i), img[i]);
    }
    for (j = 0; j <5; j++) {
      val = Xil_In32(DDR_BASEADDR+(j));
      printf("val %d",val);
        }
    cleanup_platform();
    return 0;
}

: Edited by Moderator
Author: Lothar M. (lkmiller) (Moderator)
Posted on:

Rate this post
1 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
Author: Sai S. (Company: sssihl) (shashidhar)
Posted on:

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

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

Author: Lothar M. (lkmiller) (Moderator)
Posted on:

Rate this post
1 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:
int main()
{
   init_platform();
   printf("init done");
    int i,j;
    int val;
    int img[5]={1,2,3,4,5};
    for (i = 0; i <5; i++) {
      Xil_Out32(DDR_BASEADDR+(i), img[i]);
    }
    printf("memory written");
    for (j = 0; j <5; j++) {
      val = Xil_In32(DDR_BASEADDR+(j));
      printf("val %d",val);
    }
    printf("memory read");
    cleanup_platform();
    return 0;
}

BTW: where do you have the 0x01000000 from?

Author: Sai S. (Company: sssihl) (shashidhar)
Posted on:

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

Author: Markus F. (mfro)
Posted on:

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

Author: Sai S. (Company: sssihl) (shashidhar)
Posted on:

Rate this post
0 useful
not useful
thank you

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.