C51 memcpy from SFR's

Good morning

Is there a way to memcpy from SFR's in the C51?

I have tried to memcpy((char*)&buffer, (char*)&CAN0IF2DA1L, 8); but it doesn't work

Other things i tried

memcpy((char*)&buffer,  CAN0IF2DA1L, 8);                                     //error C214: illegal pointer conversion

memcpy((char*)&buffer, (char*)&CAN0IF2DA1L, 8);                         //error C189: '&' on bit/sfr illegal

Any ideas?

Richard

Parents Reply
  • Why do you want to do that?

    My Canbus receive routine needs to copy the incoming CAN message from SFR registers, the length of the message changes depending on the message so i'd like to use a for loop with a pointer or a memcpy with the length

    What, exactly, do you mean by that?

    Do you get error messages - or what?

    The memcpy copies either the pointer address info or info from another address space but not the SFR data

    Are you aware of the different address spaces on an 8051 - in particular, how that impacts pointers in C51 ?

    I am aware of the different address spaces but do not know how to create a pointer to the SFR address space

Children
More questions in this forum