Keil™, An ARM® Company

C166 User's Guide

sfr Types

SFRs are declared in the same fashion as other C variables. The only difference is that the data type specified is sfr rather than char or int. For example:

sfr P0 = 0xFF00;    /* Port-0, address FF00h */
sfr P1 = 0xFF04;    /* Port-1, address FF04h */

Names for sfr types are defined using the same method as other C variables. In the above example, P0 and P1 are the SFR name declarations. Any symbolic name may be used in an sfr declaration.

The address specification after the equal sign ('=') must be a numeric constant. Expressions with operators are not allowed. This constant must lie in the SFR address range 0xFE00-0xFFDE or in the extended SFR address range 0xF000-0xF1DE (for C167 family devices).