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

Problems with XDATA

Hi,

I try to accces external Memory using XDATA.

I use the following code:

extern volatile unsigned char xdata interface_register _at_ 0x3;

This is the variable I want to acces, like this:

interface_register = 0x82;

Everything ok, so far.

But when I run the code in the simulator, it doesn't work. The compiler generated the following code(dissasembled):

40: interface_register = 0x82; // Interface konfigurieren: PA = Out, PB = IN, PC = OUT 41:
C:0x00FB 900000 MOV DPTR,#0x0000
C:0x00FE 7482 MOV A,#DPL(0x82)
C:0x0100 F0 MOVX @DPTR,A

So far as I can see, the Datapointer is not set correct. It should be set to 0x02. I can't find the problem.

The corresponding code from the listing is:

; SOURCE LINE # 27
0009 900000 MOV DPTR,#interface_register
000C 748B MOV A,#08BH
000E F0 MOVX @DPTR,A

The compiler used the # Operator to get the value of interface_register, to load it into DPTR. But why does the compiler use the # Operator? It should use the @ Operator to get the definend adress of interface_register (0x2).

Any suggestions? What did I do wrong?

Thanks

0