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

PBYTE to sfr?

I have the following function:

void usbReceive(PBYTE Buffer, BYTE size);

and I want to pass an sfr to it:

usbReceive(&P2, 1);

I'm getting illegal pointer conversion
Nevertheless,
usbReceive(P2, 1);
does not compile also. How can I read directly into P2 sfr?

Parents
  • 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.

Reply
  • 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.

Children
No data