在写launchpad430程序的时候,发现IAR下有两种可用的头文件
•#include "io430.h"
部分内容:
[cpp] view plaincopy
01.#elif defined (__MSP430G2553__)
02.#include "io430g2553.h"
03.
04.#elif defined (__MSP430G2203__)
05.#include "io430g2203.h"
06.
07.#elif defined (__MSP430G2303__)
08.#include "io430g2303.h"
09.
10.#elif defined (__MSP430G2403__)
11.#include "io430g2403.h"
12.
13.#elif defined (__MSP430G2233__)
14.#include "io430g2233.h"
可以看到,根据不同的处理器定义,可以包含不同的处理器的头文件,例如:io430g2553.h
[cpp] view plaincopy
01.__no_init volatile union
02.{
03. unsigned char DCOCTL; /* DCO Clock Frequency Control */
04.
05. struct
06. {
07. unsigned char MOD0 : 1; /* Modulation Bit 0 */
08. unsigned char MOD1 : 1; /* Modulation Bit 1 */
09. unsigned char MOD2 : 1; /* Modulation Bit 2 */
10. unsigned char MOD3 : 1; /* Modulation Bit 3 */
11. unsigned char MOD4 : 1; /* Modulation Bit 4 */
12. unsigned char DCO0 : 1; /* DCO Select Bit 0 */
13. unsigned char DCO1 : 1; /* DCO Select Bit 1 */
14. unsigned char DCO2 : 1; /* DCO Select Bit 2 */
15. }DCOCTL_bit;
16.} @0x0056;
17.
18.
19.enum {
20. MOD0 = 0x0001,
21. MOD1 = 0x0002,
22. MOD2 = 0x0004,
23. MOD3 = 0x0008,
24. MOD4 = 0x0010,
25. DCO0 = 0x0020,
26. DCO1 = 0x0040,
27. DCO2 = 0x0080
28.};
由以上代码可以看出,地址在0x0056的寄存器是DCOCTL、DCOCTL_bit。由于是联合体对DCOCTL、DCOCTL_bit的操作是相同的。
不同的是DCOCTL只能是按字节来操作,例如:DCOCTL = 0x00;而DCOCTL_bit是一个结构体,可以访问结构体的单元,例如:DCOCTL_bit.MOD0 = 0;
|