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 problem

Hopefully someone can Help,

I'm working on a project with the Atmel AT89C51ED2 processor. I have selected the AT89C51RD2 controller from the device database (If I'm not mistaken the only difference is the EEPROM which I'm not using..... Yet).
I have a project which works correctly (in the simulator) except when Xdata is used. I have gone through tens of threads and can not find the answer.
I have edited the Startup.A51 code which seems to work (clears 0x6FF bytes of data) cleared bit 1 of AUXR. All seems to be OK. I suspect the simulator, I have checked the memory mapping, and that also seems to be OK. Everything is working except Xdata.

Any thoughts of anything else I can try..??

Any suggestions appreciated.

Regards
John Garrelts

Parents
  • Got it... :)

    It was most probably optimised out, just as Stefan said. I used the following program to test it. I thought, no way this can be optimised out.... it won't fit anywhere else. Anyway worked first time running. At least I know xdata works... one worry less. Thanks to everyone for the support and help, much appreciated :)

    #include <89c51rd2.H>
    #include <stdio.h>
    
    
    xdata unsigned int temp[895];
    
    
    void main(void)
    	{
    		unsigned int i;
    			while(1)
    			{
    				for(i = 0; i<895; i++)
    					{
    					temp[i] = i;
    					}
    			}
    	}
    

    Again thanks
    Regards
    John

Reply
  • Got it... :)

    It was most probably optimised out, just as Stefan said. I used the following program to test it. I thought, no way this can be optimised out.... it won't fit anywhere else. Anyway worked first time running. At least I know xdata works... one worry less. Thanks to everyone for the support and help, much appreciated :)

    #include <89c51rd2.H>
    #include <stdio.h>
    
    
    xdata unsigned int temp[895];
    
    
    void main(void)
    	{
    		unsigned int i;
    			while(1)
    			{
    				for(i = 0; i<895; i++)
    					{
    					temp[i] = i;
    					}
    			}
    	}
    

    Again thanks
    Regards
    John

Children
  • It was most probably optimised out...

    Here's what I get for the compiler output. As you can see, the access to xdata was not "optimized out". Maybe there was another reason this didn't work.

    line level    source
    
       1
       2
       3          xdata unsigned char test;
       4
       5
       6          void main(void){
       7   1        test = 0xFF;
       8   1        }
    
    ASSEMBLY LISTING OF GENERATED OBJECT CODE
    
                 ; FUNCTION main (BEGIN)
                                               ; SOURCE LINE # 6
                                               ; SOURCE LINE # 7
    0000 900000      R     MOV     DPTR,#test
    0003 74FF              MOV     A,#0FFH
    0005 F0                MOVX    @DPTR,A
                                               ; SOURCE LINE # 8
    0006 22                RET
                 ; FUNCTION main (END)

    Jon

  • "As you can see, the access to xdata was not "optimized out". Maybe there was another reason this didn't work."

    Presumably test would have been optimised out had it been an automatic variable?