| |||||
Technical Support Support Resources
Product Information | C51: ARE 32-BIT SFRS SUPPORTED?Information in this article applies to:
QUESTIONI'm using a custom 8051 that has a floating-point coprocessor. I need to access 32-bit numbers stored in the SFR space of the 8051. Does the C51 compiler do this? ANSWERThere is no support in the C51 compiler for 32-bit objects stored in the SFR space of the 8051. There is support for 8-bit objects (use SFR) and 16-bit objects (use SFR16). To access a 32-bit object, you will have to use either 4 SFR accesses or 2 SFR16 accesses as shown below:
sfr OBJ_BYTE_1 = 0xF1;
sfr OBJ_BYTE_2 = 0xF2;
sfr OBJ_BYTE_3 = 0xF3;
sfr OBJ_BYTE_4 = 0xF4;
void write_obj (unsigned long value)
{
OBJ_BYTE_1 = value & 0xFF;
OBJ_BYTE_2 = (value >> 8) & 0xFF;
OBJ_BYTE_3 = (value >> 16) & 0xFF;
OBJ_BYTE_4 = (value >> 24) & 0xFF;
}
or
sfr16 OBJ_WORD_1 = 0xF1;
sfr16 OBJ_WORD_2 = 0xF3;
void write_obj (unsigned long value)
{
OBJ_WORD_1 = value & 0xFFFF;
OBJ_WORD_2 = (value >> 16) & 0xFFFF;
}
MORE INFORMATION
SEE ALSO
Last Reviewed: Tuesday, March 27, 2007 | ||||
| |||||