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

XDATA not working in8051

I am using AT89C51. Due to memory overflow I decided to use XDATA variables. Compilation shows no errors, but when I put the HEX files to the controller it will not work. At the stage where the XDATA variables are used, the system collapses and the giving unexpected results. I am using DS1644 time keeping Ram for external storage and for XDATA. What is the problem with my system. Is it need any internal settings or my controller is not suited for this pupose? Please give me a clue. My code is given below:

char xdata sum[12];
char xdata rtc[21];

when sum or rtc are used the system will give unexpected reults. Please help me.

Parents
  • "That was a mistake when I retyped the code"

    No - the mistake was to re-type it at all!

    You should never retype code - you are (almost) bound to make some little typo - always use copy-and-paste.

    So, if you manually re-typed into that last post, please post again using copy-and-paste.

    Anyhow, you haven't shown how act2 gets updated...

Reply
  • "That was a mistake when I retyped the code"

    No - the mistake was to re-type it at all!

    You should never retype code - you are (almost) bound to make some little typo - always use copy-and-paste.

    So, if you manually re-typed into that last post, please post again using copy-and-paste.

    Anyhow, you haven't shown how act2 gets updated...

Children
  • void normalRunnig()
    {
            char volatile xdata user=0,key=0;
            char cat,ser;
    
    
        char curr;
        int up;
        store cat_rate;
    
    
            unsigned long int volatile xdata find_rate,find_total,find_t1,t2_find,intTax;
    
    
        int volatile xdata  k=0,item=0,catcount=1;
            bit once;
    
        user=mode();
        if(user==0x55)
                    {
                    item=0;
                    for(k=0;k<10;k++)
                            {
                             write(present[k],"0");
                            }
                    cat=0x00;
                    key=0x00;
                    while(!(user==0||key==0x64||key==0x33||key==0x32||key==0x31))
                            {
                                    key=keypress();
                                    user =mode();
                    if(user!=0x55){return;}
                                    delay(3000);
                                    now();
                                    display(rtc,4);
                                    cat=(key&0x0f)-0x01;
                                    if(!category[cat])
                                            {key=0x00;
                        continue;}
                            }
    
            clear();
    
                    display(category[cat],1);
                    once=1;
            find_rate=0;find_total=0;find_t1=0;t2_find=0;
                    while(key!=0x43)
                            {
                                    display("Select the category ",2);
                                    display("  to issue ticket   ",3);
                                    if(!once)
                                       {display("Total Rs:         ",4);
                                            cat_rate=read(sum_all);
                                            place(cat_rate.mem,0xdd);
                                       }
                key=0x00;
                    while(!((key&0xf0)==0x30||key==0x43))
                            {
                                    key=keypress();
                                    delay(300);
                                    ser=(key&0x0f)-0x01;
                                    if(!services[ser])
                                            {key=0x00;
                             continue;}
                            }
                                    cat_rate=read(present[ser]);
                                    if(atoi(cat_rate.mem)!=0&&key!=0x43)
                                            {
                                            clear();
                                            display("  Service Already",2);
                                            display("   Selected   ",3);
                                            delay(30000);delay(30000);
                                            clear();
                                            display(category[cat],1);
                                            display("Select the category ",2);
                                            display("  to issue ticket   ",3);
                                            if(!once)
                                                    {display("Total Rs:         ",4);
                                                     cat_rate=read(sum_all);
                                                     place(cat_rate.mem,0xdd);
                                                    }
                                       key=0x00;continue;
                                            }
    
                            if(key==0x43)
                                    continue;
                            key=0x00;
                            ask_rate(category[cat],services[ser],"No.of Tickets :");
                            write(present[ser],sav);
    
                            cat_rate=read(rate_mem[ser][cat]);
                            pntLesStr(cat_rate.mem);
                            find_rate=atol(cat_rate.mem);
    
                t2_find=find_rate*atol(sav);
    
                            find_total+=find_rate*atol(sav);
                            find_t1=find_total;
    
    
                            for (k=8;k>=0;k--)
                                    {
                                    show_total[k]=(find_t1%10)+0x30;
                                    find_t1=find_t1/10;
                                    }
                            for(k=0;k<=8;k++)
                                    {
                                    if(show_total[k]==0x30){show_total[k]=0x20;}
                                    else{break;}
                                    }
                            show_total[9]='\0';
                pointStr2(show_total);
                            write(sum_all,show_total);
    
                            for (k=8;k>=0;k--)
                                    {
                                    show_total[k]=(t2_find%10)+0x30;
                                    t2_find=t2_find/10;
                                    }
                            for(k=0;k<=8;k++)
                                    {
                                    if(show_total[k]==0x30){show_total[k]=0x20;}
                                    else{break;}
                                    }
                            show_total[9]='\0';
                pointStr2(show_total);
                            write(tot[ser],show_total);
    
    
                            display("Press PRINT to issue",2);
                            display(" Ticket or  OK      ",3);
                            display(" To continue        ",4);
                            key=0x00;
                            while(!(key==0x61||key==0x43||key==0x51))
                                    {
                                    key=keypress();
                                    delay(300);
                                    }
    
    
                     if(key==0x51)
                        {clear();
                find_total=0;
                cancel();}
                     else if(key==0x43)
                   continue;
                 else if(key==0x61)
                    {clear();
    
                            while(!(key==0x43||key==0x51||key==0x61))
                                    {
                                            display("PRINT: To Print TKT ",1);
                                            display("  OK : To Continue  ",2);
                                            display("   C : To CANCEL    ",3);
                                            key=keypress();
                                            delay(300);
                                    }
                            }
                             if(key==0x51)
                                {clear();
                    find_total=0;
                                    cancel();}
                            else if(key==0x43)
                                    continue;
                            else
                                    once=0;
             }
            }
      else return;
      }
    

    This is the complete function. Here the problem will come with the 'find_t1'. Its value is not cleared until power is off. Can I declare variables like this? or problem is in another part?(ie, concepts that unknown to me)