在写launchpad430程序的时候,发现IAR下有两种可用的头文件
部分内容:
[cpp] view plain copy
- #elif defined (__MSP430G2553__)
- #include "io430g2553.h"
-
- #elif defined (__MSP430G2203__)
- #include "io430g2203.h"
-
- #elif defined (__MSP430G2303__)
- #include "io430g2303.h"
-
- #elif defined (__MSP430G2403__)
- #include "io430g2403.h"
-
- #elif defined (__MSP430G2233__)
- #include "io430g2233.h"
可以看到,根据不同的处理器定义,可以包含不同的处理器的头文件,例如:io430g2553.h
[cpp] view plain copy
- __no_init volatile union
- {
- unsigned char DCOCTL; /* DCO Clock Frequency Control */
-
- struct
- {
- unsigned char MOD0 : 1; /* Modulation Bit 0 */
- unsigned char MOD1 : 1; /* Modulation Bit 1 */
- unsigned char MOD2 : 1; /* Modulation Bit 2 */
- unsigned char MOD3 : 1; /* Modulation Bit 3 */
- unsigned char MOD4 : 1; /* Modulation Bit 4 */
- unsigned char DCO0 : 1; /* DCO Select Bit 0 */
- unsigned char DCO1 : 1; /* DCO Select Bit 1 */
- unsigned char DCO2 : 1; /* DCO Select Bit 2 */
- }DCOCTL_bit;
- } @0x0056;
-
-
- enum {
- MOD0 = 0x0001,
- MOD1 = 0x0002,
- MOD2 = 0x0004,
- MOD3 = 0x0008,
- MOD4 = 0x0010,
- DCO0 = 0x0020,
- DCO1 = 0x0040,
- DCO2 = 0x0080
- };
由以上代码可以看出,地址在0x0056的寄存器是DCOCTL、DCOCTL_bit。由于是联合体对DCOCTL、DCOCTL_bit的操作是相同的。
不同的是DCOCTL只能是按字节来操作,例如:DCOCTL = 0x00;而DCOCTL_bit是一个结构体,可以访问结构体的单元,例如:DCOCTL_bit.MOD0 = 0; 最好头文件还定义了个枚举量,可以更加形象的操作,例如:将MOD0置1,即DCOCTL |= MOD0,MOD1置0,即DCOCTL &= ~MOD1。
[objc] view plain copy
- #elif defined (__MSP430G2153__)
- #include "msp430g2153.h"
-
- #elif defined (__MSP430G2253__)
- #include "msp430g2253.h"
-
- #elif defined (__MSP430G2353__)
- #include "msp430g2353.h"
-
- #elif defined (__MSP430G2453__)
- #include "msp430g2453.h"
-
- #elif defined (__MSP430G2553__)
- #include "msp430g2553.h"
可以看到,根据不同的处理器定义,可以包含不同的处理器的头文件,例如:msp430g2553.h
[objc] view plain copy
- #define DCOCTL_ (0x0056u) /* DCO Clock Frequency Control */
- DEFC( DCOCTL , DCOCTL_)
可以看出直接将DCOCTL定义在0x0056
|