This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems in using on-chip XRAM (P89C662 with 768 bytes of ERAM )

Problem:
--------
All I am doing here is that msg1 table is initialized and trying to print this info out to see if I am able to access ERAM properly. I am serring 'Use on-Chip ROM' and 'USE on-chip XRAM" (large model).
Also I am enabling the on-chip XRAM by clearing bit 1 in the AUXR SFR
(AUXR = 0x1).

I cannot see what I am doing wrong here. Any pointers on this will be highly appreciated.

Thanks, Venkat

Program:
--------

#include <REG66x.H> /* for the intended 8051 derivative */

#include <stdio.h> /* prototype declarations for I/O functions */
#include <stdlib.h>
#include <string.h>
#include <math.h>

sfr SBUF = 0x99;

char xdata helloMsg[] = "Hello World";
char xdata xdata_buffer[32];
int xdata num_data[32];

char xdata msg1[64] = {
0 , 0xfe, 0x10, 0x10, 0x10, 0xfe, 0,
0xfc, 0x12, 0x12, 0x12, 0xfc, 0,
0xfe, 0x08, 0x10, 0x20, 0xfe, 0,
0x02, 0x02, 0xfe, 0x02, 0x02, 0,
0xfe, 0x12, 0x32, 0x52, 0x8c, 0,
0x7c, 0x82, 0x82, 0x82, 0x7c, 0,
0xfe, 0x08, 0x10, 0x20, 0xfe, 0,
0x0 , 0x0 , 0x82, 0xfe, 0x82, 0,
0 , 0xc6, 0x28, 0x10, 0x28, 0xc6, 0,
0 , 0x38, 0x7c, 0xf8, 0x7c, 0x38, 0,
0
};

char myputchar (char c) {
while (!TI);
TI = 0;
return (SBUF = c);
}

void main (void)
{
int ix, j;
char c;

/* serial port properties */
RCLK = 1;
TCLK = 1;
S0CON = 0x50;

/* timer 2 properties */
RCAP2L = 0xF6;
RCAP2H = 0xFF;

TR2 =1;

/* Timer 0 & 1 properties */
TH0 = 0;
TL0 = 0;
TMOD = 1;

/* Enable interrupts */
ES0 = 1;
EA = 1;
TR0 = 1;

AUXR = 0x1;

TI = 1;

printf ("\n ...........\n");
printf ("....hm[%d]=%s....\n", strlen(helloMsg), helloMsg);

memcpy (xdata_buffer, "XDATA Buffer", sizeof (xdata_buffer));
printf("....Xdata[%d]=%s.... \n", strlen(xdata_buffer), xdata_buffer);

j = 0;
for (ix = 0; ix < 32; ix++)
{
printf ("%x ", msg1[ix]);
j++;
if ( j == 16 )
{
printf("\n");
j = 0;
}
}
while (1);
}

Output
------
The integer array output is garbage.
...........
....hm[11]=Hello World....
....Xdata[12]=XDATA Buffer....

730f 2e0f 2e0f 2e0f f 310f f 320f f 330f f 340f f 350f f 360f
f 370f f 380f f 390f f 3a0f f 3b0f f 3c0f f 3d0f f 3e0f

Parents
  • Jon,
    I truly appreciate your fast reponse.

    Yes, I verified that data reference is within 768 bytes of XDATA. I also tried to define 769 bytes and the complier complains it.

    Works fine with Simulator. I am hooking up
    emulator to see what is happening. I also casted the data via the following command
    printf ("%bd ", (char) msg1[ix]);

    No luck yet in resolving this problem.

    Thanks, Venkat

Reply
  • Jon,
    I truly appreciate your fast reponse.

    Yes, I verified that data reference is within 768 bytes of XDATA. I also tried to define 769 bytes and the complier complains it.

    Works fine with Simulator. I am hooking up
    emulator to see what is happening. I also casted the data via the following command
    printf ("%bd ", (char) msg1[ix]);

    No luck yet in resolving this problem.

    Thanks, Venkat

Children
No data