I have the following function:
void usbReceive(PBYTE Buffer, BYTE size);
usbReceive(&P2, 1);
usbReceive(P2, 1);
If you think that PBYTE is a pointer to xdata then claryfy me, please, how does this work:
void send_buffer(PBYTE buf, BYTE size) { BYTE s; for (s = 0; s < size; s++) send_byte(*buf++); } WORD w = 11; send_buf(&w, 2);
"If you think that PBYTE is a pointer to xdata then claryfy me" To find the explanation, open the online Manual and search for PBYTE.
"I declare the 2-byte variable in internal memory (idata)." Depending on your (re)definition of PBYTE (which you didn't supply), it could well work. But now you've changed the question - you were asking about SFRs before! The reason why it can't ever work with an SFR (irrespective of any definition of PBYTE) has already been explained.
As Hans said, you can't have a pointer to an SFR. The 8051 has 256 internal memory locations. Addresses 0..7FH are the "data" space (along with the registers and bit-addressable data). Addresses 80H..FFH are either internal ram ("idata") OR SFRs. But how does the processor know the difference? Any instruction using direct memory addressing modes accesses the SFR space. Any instruction using indirect addressing modes (pointers) accesses the memory space instead.