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

how to enable xdata in P87C51RD+

hi
to use on chip xram of my p87c51RD+. I have made following changes in my code which are recomended here.
http://www.keil.com/support/docs/1758.htm
but my code stuck on this loop.

IDATALOOP:	MOV	@R0,A
		DJNZ	R0,IDATALOOP
regards
Farhan
I have also posted this messege on
http://www.8052.com/forum/read.phtml?id=79977&top=79977

  • That is the loop in the startup code that clears memory. Are you sure the program is STUCK in this loop?

    IDATALOOP:	MOV	@R0,A
    		DJNZ	R0,IDATALOOP
    

    The DJNZ instruction is a decrement and jump it non-zero. So, if the program is actually STUCK in this look, it means that R0 never decrements down to 0.

    Jon

  • This bit of code may fail if the selected register bank is not zero. If, for example, register bank 1 is selected then when R0 is equall to 8 the instruction:

        MOV @R0,A
    
    Will clear R0. The following DJNZ instruction will set R0 to 0xFF and the code will loop forever.

  • But this code runs after Reset. Reset ensures that the register bank 0 is selected.

  • hi,

    Maybe you should use MOVX instead MOV and DPTR instead R0.
    http://www.8052.com/forum/read.phtml?id=80001


    Regards,
    Oleg

  • Hi Farhan,

    I am a little unclear as to what your problem(s) is/are.

    If you know that you are getting stuck on the loop to clear IDATA, I am suprised as this is tried and tested code and you will not get stuck in an infinite loop even if you start with R0 set to 00h, then why not just set :-
    IDATALEN EQU 00H
    so this code is not included so you can see if your code gets past this point?

    If you ar using the PHILIPS P87c51rd+ then I hope you have not copied verbatim what is shown in "1758.htm" as this quite clearly relates to a diffent chip, so for you chip you should have :-
    XDATASTART EQU 00000H
    XDATALEN EQU 0300H
    to clear the onchip EXTRAM which according to the data sheet is enabled by default. Also you should not include (if you have added it) this line :-
    ANL 0B1h, #01h
    show in the keil app note.
    Alternativly if you want to disable the internal EXTRAM then you should include the following line:-
    ORL 08Eh, #02h
    which will set the EXTRAM bit within the AUXR register.