ARM Technical Support Knowledge Articles

ARE 32-BIT SFRS SUPPORTED?

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

I'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?

ANSWER

There 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

Article last edited on: 2007-03-27 17:17:04

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential