SFR_8BIT(CALDCO_16MHZ);
对使用宏定义的地方进行字符展开就是:extern volatile unsigned char CALDCO_16MHZ;
SFR_8BIT is a macro that defines a variable to be a volatile unsigned char located at a
详情回复
发表于 2012-12-20 23:36
SFR_8BIT is a macro that defines a variable to be a volatile unsigned char located at a certain address.
You quoted the macro definition.
However, somewhere else in a different header file, the macro is used in the form
SFR_8BIT(P1DIR = 0x22);
or
SFR_8BIT(0x22) P1DIR;
or something similar. I don't use IAR/CCS, so I don't know the exact syntax there, but on mspgcc it is similar:
#define sfrb(name, address) volatile unsigned char name asm(#address);
and used with
sfrb(P1DIR, 0x22);
throughout the different header files, which then expands to
volatile unsigned char P1DIR asm("0x22");
There are also sfrw and sfra macros which do the same for word or address-word (20bit) registers
The macro is usd in other header files which may be in a processor-specific subfolder or such. Perhaps it is even assembled by calling an include file with the name of the Port (P1) and the base address (0x20), so the same include file can be called for any number of ports, by addign port name and port register extension (P1 and OUT) and adding base address and register offset (0x20 and 2). It keeps maintenance low and allows reusing the header file for different MSPs with different module addresses but otherwise same module hardware.