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

problem with reading from Xdata memory and send to UART

Hello everybody!
I'm quite new to programing with C for 8051, and have a question about writing to Xdata:
I'm to trying to store large amount of inforamtion. when I send to stored byte to SBUF to send to my PC usuing UART, I don't get the expected result. instead, the recieved character is the address in which the data is stored, and not the data itself. my code is:

#include <reg51.h>
#include <absacc.h>

void config (void);
void delay(unsigned int itime);
void serial_write(unsigned char t);

sbit LED=P3^4;
xdata unsigned char TEST='a' ;   // _at_ 0x00;

void main(void)
{
        unsigned char i=0;
        //TEST='a';
        config ();
        TR1 = '1';
        for (i=0;i<=25;i++)
         {
                serial_write(TEST);
         }
}

void config (void)
{
        TMOD=0x20; //settings for TIMER1
        TH1=0xEE;  //setting value for TIMER1 assuming SCON=0
        SCON=0x50; //settings for UART

        EA=1;
        EX0=1;
}

void delay(unsigned int itime)
{
        int i,j;
        for (i=0;i<itime;i++)
                for (j=0;j<1275;j++);
}

void serial_write(unsigned char t)
{
                SBUF=t;
                while(TI==0);
                TI=0;
                delay(1000);
                LED=!LED;
}

if I put the note: "// _at_ 0x00;" to be in the code, I get the address in which I saved the data on my PC in hyperterminal, instead of getting the saved data (i.e. 'a').

what is wrong?

another question: to save large amount of data, should I preffer saving in Xdata or in the Code section? does the data in Xdata deleted whenever there's a power off ?

my micro processor is ADUC841 with crystal of 11.0592 Mhz.
thanks for your help!

0