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

DATA to XDATA issue

Hi people,

I've some troubles with some variables declaration.
I'm using the old Keil compîler C51 V5.50.

When writing :

U8 u8CommandIndex=0;
with U8 = unsigned char, it's ok.

Now I want to relocate the variable into the XDATA segment. The declaration becomes :
xdata U8 u8CommandIndex=0;
But in this case, my variable isn't initialized to 0. The value is the last one before the reset.

Why the initialization isn't done in this case ?

Regards
Stephane

Parents
  • yes, I've set the end of XDATA as follow :

    XDATALEN	EQU	0F00H	; the length of XDATA memory in bytes.
    				; 8Kb = 1F00H
    				; 4Kb = 0F00H

    I'm using p89c664 with 4K of internal RAM.

    I don't understand how it's possible to have some variable keeping their last value if the XDATA RAM is cleared by Startup.a51 code as follow :
    IF XDATALEN <> 0
    		MOV	DPTR,#XDATASTART
    		MOV	R7,#LOW (XDATALEN)
      IF (LOW (XDATALEN)) <> 0
    		MOV	R6,#(HIGH XDATALEN) +1
      ELSE
    		MOV	R6,#HIGH (XDATALEN)
      ENDIF
    		CLR	A
    XDATALOOP:	MOVX	@DPTR,A
    		INC	DPTR
    		DJNZ	R7,XDATALOOP
    		DJNZ	R6,XDATALOOP
    ENDIF

    Moreover, in my code, why it's not initialized in XDATA when writting what I've described in myprevious post.


    Stephane

Reply
  • yes, I've set the end of XDATA as follow :

    XDATALEN	EQU	0F00H	; the length of XDATA memory in bytes.
    				; 8Kb = 1F00H
    				; 4Kb = 0F00H

    I'm using p89c664 with 4K of internal RAM.

    I don't understand how it's possible to have some variable keeping their last value if the XDATA RAM is cleared by Startup.a51 code as follow :
    IF XDATALEN <> 0
    		MOV	DPTR,#XDATASTART
    		MOV	R7,#LOW (XDATALEN)
      IF (LOW (XDATALEN)) <> 0
    		MOV	R6,#(HIGH XDATALEN) +1
      ELSE
    		MOV	R6,#HIGH (XDATALEN)
      ENDIF
    		CLR	A
    XDATALOOP:	MOVX	@DPTR,A
    		INC	DPTR
    		DJNZ	R7,XDATALOOP
    		DJNZ	R6,XDATALOOP
    ENDIF

    Moreover, in my code, why it's not initialized in XDATA when writting what I've described in myprevious post.


    Stephane

Children