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
RichardT said:memcpy from SFR's in the C51?
memcpy from SFR's in the C51?
Why do you want to do that?
http://www.catb.org/esr/faqs/smart-questions.html#goal
RichardT said:it doesn't work
What, exactly, do you mean by that?
Do you get error messages - or what?
Are you aware of the different address spaces on an 8051 - in particular, how that impacts pointers in C51 ?
http://www.keil.com/support/man/docs/c51/c51_le_ptrs.htm
Andy Neil said: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
Andy Neil said: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
Andy Neil said: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
RichardT said:do not know how to create a pointer to the SFR address space
http://www.keil.com/support/man/docs/c51/c51_le_memspecificptrs.htm
Although, IIRC, SFR space is not indirectly addressable ... ?
RichardT said:My Canbus receive routine needs to copy the incoming CAN message from SFR registers
Doesn't the chip maker give examples of doing that?
Andy Neil said:IIRC, SFR space is not indirectly addressable
It's been a long time since I last used an 8051 - but that recollection is correct:
From the Philips Semiconductors 80C51 Family Architecture document - linked earlier
RichardT said:I am aware of the different address spaces but do not know how to create a pointer to the SFR address space
That statement is self-contradictory. Just about the single most important thing to learn about the different address spaces of an 8051 is that one cannot create a pointer to an SFR.