byte order microblaze

F

Frank

Guest
Hi,

I've a small program in bram which has a pointer to sdram.

static volatile BYTE * const p_sdram = (BYTE *) XPAR_SDRAM_CTRL_BASEADDR;

in my code I try to fill the sdram (by the way, it's 32-bits wide databus):

for (i = 0; i < 16; i++) {
*(p_sdram+i) = i;
}

Now comes the problem: when I read back the data, each 2 bytes are
exchanged. Reading back is done with the same byte pointer:

for (i = 1; i <= 16; i++) {
xil_printf("%02X ", (BYTE) *(p_sdram+i-1));
}

The output is:

01 00 03 02 05 04 07 06 09 08 0B 0A 0D 0C 0F 0E

What is wrong?! If I have a byte pointer, the big or little endian story
doesn't matter, does it? I'm posting this here, because I have the feeling
that it has to do with the opb sdram controller? Can somebody explain the
above?

Frank
 
I have this piece of code. I have just used char instead of BYTE. I get
the proper output. I do not see the interleaving that you specify.
If you can give more info about the design you are seeing this problem
with, we can take a look.


=====
int main()
{
static volatile char * const p_sdram = (char *) 0xe000000;
int i;

for (i = 0; i < 16; i++) {
*(p_sdram+i) = i;
}

for (i = 1; i <= 16; i++) {
xil_printf("%02X ", (char) *(p_sdram+i-1));
}

while (1);
}
======

Frank wrote:

Hi,

I've a small program in bram which has a pointer to sdram.

static volatile BYTE * const p_sdram = (BYTE *) XPAR_SDRAM_CTRL_BASEADDR;

in my code I try to fill the sdram (by the way, it's 32-bits wide databus):

for (i = 0; i < 16; i++) {
*(p_sdram+i) = i;
}

Now comes the problem: when I read back the data, each 2 bytes are
exchanged. Reading back is done with the same byte pointer:

for (i = 1; i <= 16; i++) {
xil_printf("%02X ", (BYTE) *(p_sdram+i-1));
}

The output is:

01 00 03 02 05 04 07 06 09 08 0B 0A 0D 0C 0F 0E

What is wrong?! If I have a byte pointer, the big or little endian story
doesn't matter, does it? I'm posting this here, because I have the feeling
that it has to do with the opb sdram controller? Can somebody explain the
above?

Frank
 
Frank,

I've also used char in my code when testing the OPB SDRAM controller and not
seen a problem.

There is a bit-ordering difference that is really only important in the address
bus simply because when setting the SDRAM mode register, the address bus
contains the data for that register.

So I reccommend checking the bit-ordering connections. There are some examples
in the design spec.

Thanks!
anita

Vasanth Asokan wrote:

I have this piece of code. I have just used char instead of BYTE. I get
the proper output. I do not see the interleaving that you specify.
If you can give more info about the design you are seeing this problem
with, we can take a look.

=====
int main()
{
static volatile char * const p_sdram = (char *) 0xe000000;
int i;

for (i = 0; i < 16; i++) {
*(p_sdram+i) = i;
}

for (i = 1; i <= 16; i++) {
xil_printf("%02X ", (char) *(p_sdram+i-1));
}

while (1);
}
======

Frank wrote:

Hi,

I've a small program in bram which has a pointer to sdram.

static volatile BYTE * const p_sdram = (BYTE *) XPAR_SDRAM_CTRL_BASEADDR;

in my code I try to fill the sdram (by the way, it's 32-bits wide databus):

for (i = 0; i < 16; i++) {
*(p_sdram+i) = i;
}

Now comes the problem: when I read back the data, each 2 bytes are
exchanged. Reading back is done with the same byte pointer:

for (i = 1; i <= 16; i++) {
xil_printf("%02X ", (BYTE) *(p_sdram+i-1));
}

The output is:

01 00 03 02 05 04 07 06 09 08 0B 0A 0D 0C 0F 0E

What is wrong?! If I have a byte pointer, the big or little endian story
doesn't matter, does it? I'm posting this here, because I have the feeling
that it has to do with the opb sdram controller? Can somebody explain the
above?

Frank
 
I also tested the same code with a pointer to bram, that was working good (I
got the expected output). I am using the Virtex II development board. I will
check the connections.

Thanks,
Frank

"Anita Schreiber" <anitas@xilinx.com> wrote in message
news:3FDA3B4A.E206AF06@xilinx.com...
Frank,

I've also used char in my code when testing the OPB SDRAM controller and
not
seen a problem.

There is a bit-ordering difference that is really only important in the
address
bus simply because when setting the SDRAM mode register, the address bus
contains the data for that register.

So I reccommend checking the bit-ordering connections. There are some
examples
in the design spec.

Thanks!
anita

Vasanth Asokan wrote:

I have this piece of code. I have just used char instead of BYTE. I get
the proper output. I do not see the interleaving that you specify.
If you can give more info about the design you are seeing this problem
with, we can take a look.

=====
int main()
{
static volatile char * const p_sdram = (char *) 0xe000000;
int i;

for (i = 0; i < 16; i++) {
*(p_sdram+i) = i;
}

for (i = 1; i <= 16; i++) {
xil_printf("%02X ", (char) *(p_sdram+i-1));
}

while (1);
}
======

Frank wrote:

Hi,

I've a small program in bram which has a pointer to sdram.

static volatile BYTE * const p_sdram = (BYTE *)
XPAR_SDRAM_CTRL_BASEADDR;

in my code I try to fill the sdram (by the way, it's 32-bits wide
databus):

for (i = 0; i < 16; i++) {
*(p_sdram+i) = i;
}

Now comes the problem: when I read back the data, each 2 bytes are
exchanged. Reading back is done with the same byte pointer:

for (i = 1; i <= 16; i++) {
xil_printf("%02X ", (BYTE) *(p_sdram+i-1));
}

The output is:

01 00 03 02 05 04 07 06 09 08 0B 0A 0D 0C 0F 0E

What is wrong?! If I have a byte pointer, the big or little endian
story
doesn't matter, does it? I'm posting this here, because I have the
feeling
that it has to do with the opb sdram controller? Can somebody explain
the
above?

Frank
 

Welcome to EDABoard.com

Sponsor

Back
Top