| 2850 |
dpurdie |
1 |
/********************************************************************
|
|
|
2 |
*
|
|
|
3 |
* Standard register and bit definitions for the Texas Instruments
|
|
|
4 |
* MSP430 microcontroller.
|
|
|
5 |
*
|
|
|
6 |
* This file supports assembler and C development for
|
|
|
7 |
* MSP430G2221 devices.
|
|
|
8 |
*
|
|
|
9 |
* Texas Instruments, Version 1.0
|
|
|
10 |
*
|
|
|
11 |
* Rev. 1.0, Setup
|
|
|
12 |
*
|
|
|
13 |
********************************************************************/
|
|
|
14 |
|
|
|
15 |
#ifndef __MSP430G2221
|
|
|
16 |
#define __MSP430G2221
|
|
|
17 |
|
|
|
18 |
#ifdef __cplusplus
|
|
|
19 |
extern "C" {
|
|
|
20 |
#endif
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
/*----------------------------------------------------------------------------*/
|
|
|
24 |
/* PERIPHERAL FILE MAP */
|
|
|
25 |
/*----------------------------------------------------------------------------*/
|
|
|
26 |
|
|
|
27 |
/* External references resolved by a device-specific linker command file */
|
|
|
28 |
#define SFR_8BIT(address) extern volatile unsigned char address
|
|
|
29 |
#define SFR_16BIT(address) extern volatile unsigned int address
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
/************************************************************
|
|
|
33 |
* STANDARD BITS
|
|
|
34 |
************************************************************/
|
|
|
35 |
|
|
|
36 |
#define BIT0 (0x0001)
|
|
|
37 |
#define BIT1 (0x0002)
|
|
|
38 |
#define BIT2 (0x0004)
|
|
|
39 |
#define BIT3 (0x0008)
|
|
|
40 |
#define BIT4 (0x0010)
|
|
|
41 |
#define BIT5 (0x0020)
|
|
|
42 |
#define BIT6 (0x0040)
|
|
|
43 |
#define BIT7 (0x0080)
|
|
|
44 |
#define BIT8 (0x0100)
|
|
|
45 |
#define BIT9 (0x0200)
|
|
|
46 |
#define BITA (0x0400)
|
|
|
47 |
#define BITB (0x0800)
|
|
|
48 |
#define BITC (0x1000)
|
|
|
49 |
#define BITD (0x2000)
|
|
|
50 |
#define BITE (0x4000)
|
|
|
51 |
#define BITF (0x8000)
|
|
|
52 |
|
|
|
53 |
/************************************************************
|
|
|
54 |
* STATUS REGISTER BITS
|
|
|
55 |
************************************************************/
|
|
|
56 |
|
|
|
57 |
#define C (0x0001)
|
|
|
58 |
#define Z (0x0002)
|
|
|
59 |
#define N (0x0004)
|
|
|
60 |
#define V (0x0100)
|
|
|
61 |
#define GIE (0x0008)
|
|
|
62 |
#define CPUOFF (0x0010)
|
|
|
63 |
#define OSCOFF (0x0020)
|
|
|
64 |
#define SCG0 (0x0040)
|
|
|
65 |
#define SCG1 (0x0080)
|
|
|
66 |
|
|
|
67 |
/* Low Power Modes coded with Bits 4-7 in SR */
|
|
|
68 |
|
|
|
69 |
#ifdef __ASM_HEADER__ /* Begin #defines for assembler */
|
|
|
70 |
#define LPM0 (CPUOFF)
|
|
|
71 |
#define LPM1 (SCG0+CPUOFF)
|
|
|
72 |
#define LPM2 (SCG1+CPUOFF)
|
|
|
73 |
#define LPM3 (SCG1+SCG0+CPUOFF)
|
|
|
74 |
#define LPM4 (SCG1+SCG0+OSCOFF+CPUOFF)
|
|
|
75 |
/* End #defines for assembler */
|
|
|
76 |
|
|
|
77 |
#else /* Begin #defines for C */
|
|
|
78 |
#define LPM0_bits (CPUOFF)
|
|
|
79 |
#define LPM1_bits (SCG0+CPUOFF)
|
|
|
80 |
#define LPM2_bits (SCG1+CPUOFF)
|
|
|
81 |
#define LPM3_bits (SCG1+SCG0+CPUOFF)
|
|
|
82 |
#define LPM4_bits (SCG1+SCG0+OSCOFF+CPUOFF)
|
|
|
83 |
|
|
|
84 |
#include "in430.h"
|
|
|
85 |
|
|
|
86 |
#define LPM0 _bis_SR_register(LPM0_bits) /* Enter Low Power Mode 0 */
|
|
|
87 |
#define LPM0_EXIT _bic_SR_register_on_exit(LPM0_bits) /* Exit Low Power Mode 0 */
|
|
|
88 |
#define LPM1 _bis_SR_register(LPM1_bits) /* Enter Low Power Mode 1 */
|
|
|
89 |
#define LPM1_EXIT _bic_SR_register_on_exit(LPM1_bits) /* Exit Low Power Mode 1 */
|
|
|
90 |
#define LPM2 _bis_SR_register(LPM2_bits) /* Enter Low Power Mode 2 */
|
|
|
91 |
#define LPM2_EXIT _bic_SR_register_on_exit(LPM2_bits) /* Exit Low Power Mode 2 */
|
|
|
92 |
#define LPM3 _bis_SR_register(LPM3_bits) /* Enter Low Power Mode 3 */
|
|
|
93 |
#define LPM3_EXIT _bic_SR_register_on_exit(LPM3_bits) /* Exit Low Power Mode 3 */
|
|
|
94 |
#define LPM4 _bis_SR_register(LPM4_bits) /* Enter Low Power Mode 4 */
|
|
|
95 |
#define LPM4_EXIT _bic_SR_register_on_exit(LPM4_bits) /* Exit Low Power Mode 4 */
|
|
|
96 |
#endif /* End #defines for C */
|
|
|
97 |
|
|
|
98 |
/************************************************************
|
|
|
99 |
* PERIPHERAL FILE MAP
|
|
|
100 |
************************************************************/
|
|
|
101 |
|
|
|
102 |
/************************************************************
|
|
|
103 |
* SPECIAL FUNCTION REGISTER ADDRESSES + CONTROL BITS
|
|
|
104 |
************************************************************/
|
|
|
105 |
|
|
|
106 |
SFR_8BIT(IE1); /* Interrupt Enable 1 */
|
|
|
107 |
#define WDTIE (0x01) /* Watchdog Interrupt Enable */
|
|
|
108 |
#define OFIE (0x02) /* Osc. Fault Interrupt Enable */
|
|
|
109 |
#define NMIIE (0x10) /* NMI Interrupt Enable */
|
|
|
110 |
#define ACCVIE (0x20) /* Flash Access Violation Interrupt Enable */
|
|
|
111 |
|
|
|
112 |
SFR_8BIT(IFG1); /* Interrupt Flag 1 */
|
|
|
113 |
#define WDTIFG (0x01) /* Watchdog Interrupt Flag */
|
|
|
114 |
#define OFIFG (0x02) /* Osc. Fault Interrupt Flag */
|
|
|
115 |
#define PORIFG (0x04) /* Power On Interrupt Flag */
|
|
|
116 |
#define RSTIFG (0x08) /* Reset Interrupt Flag */
|
|
|
117 |
#define NMIIFG (0x10) /* NMI Interrupt Flag */
|
|
|
118 |
|
|
|
119 |
/************************************************************
|
|
|
120 |
* Basic Clock Module
|
|
|
121 |
************************************************************/
|
|
|
122 |
#define __MSP430_HAS_BC2__ /* Definition to show that Module is available */
|
|
|
123 |
|
|
|
124 |
SFR_8BIT(DCOCTL); /* DCO Clock Frequency Control */
|
|
|
125 |
SFR_8BIT(BCSCTL1); /* Basic Clock System Control 1 */
|
|
|
126 |
SFR_8BIT(BCSCTL2); /* Basic Clock System Control 2 */
|
|
|
127 |
SFR_8BIT(BCSCTL3); /* Basic Clock System Control 3 */
|
|
|
128 |
|
|
|
129 |
#define MOD0 (0x01) /* Modulation Bit 0 */
|
|
|
130 |
#define MOD1 (0x02) /* Modulation Bit 1 */
|
|
|
131 |
#define MOD2 (0x04) /* Modulation Bit 2 */
|
|
|
132 |
#define MOD3 (0x08) /* Modulation Bit 3 */
|
|
|
133 |
#define MOD4 (0x10) /* Modulation Bit 4 */
|
|
|
134 |
#define DCO0 (0x20) /* DCO Select Bit 0 */
|
|
|
135 |
#define DCO1 (0x40) /* DCO Select Bit 1 */
|
|
|
136 |
#define DCO2 (0x80) /* DCO Select Bit 2 */
|
|
|
137 |
|
|
|
138 |
#define RSEL0 (0x01) /* Range Select Bit 0 */
|
|
|
139 |
#define RSEL1 (0x02) /* Range Select Bit 1 */
|
|
|
140 |
#define RSEL2 (0x04) /* Range Select Bit 2 */
|
|
|
141 |
#define RSEL3 (0x08) /* Range Select Bit 3 */
|
|
|
142 |
#define DIVA0 (0x10) /* ACLK Divider 0 */
|
|
|
143 |
#define DIVA1 (0x20) /* ACLK Divider 1 */
|
|
|
144 |
#define XTS (0x40) /* LFXTCLK 0:Low Freq. / 1: High Freq. */
|
|
|
145 |
#define XT2OFF (0x80) /* Enable XT2CLK */
|
|
|
146 |
|
|
|
147 |
#define DIVA_0 (0x00) /* ACLK Divider 0: /1 */
|
|
|
148 |
#define DIVA_1 (0x10) /* ACLK Divider 1: /2 */
|
|
|
149 |
#define DIVA_2 (0x20) /* ACLK Divider 2: /4 */
|
|
|
150 |
#define DIVA_3 (0x30) /* ACLK Divider 3: /8 */
|
|
|
151 |
|
|
|
152 |
#define DIVS0 (0x02) /* SMCLK Divider 0 */
|
|
|
153 |
#define DIVS1 (0x04) /* SMCLK Divider 1 */
|
|
|
154 |
#define SELS (0x08) /* SMCLK Source Select 0:DCOCLK / 1:XT2CLK/LFXTCLK */
|
|
|
155 |
#define DIVM0 (0x10) /* MCLK Divider 0 */
|
|
|
156 |
#define DIVM1 (0x20) /* MCLK Divider 1 */
|
|
|
157 |
#define SELM0 (0x40) /* MCLK Source Select 0 */
|
|
|
158 |
#define SELM1 (0x80) /* MCLK Source Select 1 */
|
|
|
159 |
|
|
|
160 |
#define DIVS_0 (0x00) /* SMCLK Divider 0: /1 */
|
|
|
161 |
#define DIVS_1 (0x02) /* SMCLK Divider 1: /2 */
|
|
|
162 |
#define DIVS_2 (0x04) /* SMCLK Divider 2: /4 */
|
|
|
163 |
#define DIVS_3 (0x06) /* SMCLK Divider 3: /8 */
|
|
|
164 |
|
|
|
165 |
#define DIVM_0 (0x00) /* MCLK Divider 0: /1 */
|
|
|
166 |
#define DIVM_1 (0x10) /* MCLK Divider 1: /2 */
|
|
|
167 |
#define DIVM_2 (0x20) /* MCLK Divider 2: /4 */
|
|
|
168 |
#define DIVM_3 (0x30) /* MCLK Divider 3: /8 */
|
|
|
169 |
|
|
|
170 |
#define SELM_0 (0x00) /* MCLK Source Select 0: DCOCLK */
|
|
|
171 |
#define SELM_1 (0x40) /* MCLK Source Select 1: DCOCLK */
|
|
|
172 |
#define SELM_2 (0x80) /* MCLK Source Select 2: XT2CLK/LFXTCLK */
|
|
|
173 |
#define SELM_3 (0xC0) /* MCLK Source Select 3: LFXTCLK */
|
|
|
174 |
|
|
|
175 |
#define LFXT1OF (0x01) /* Low/high Frequency Oscillator Fault Flag */
|
|
|
176 |
#define XT2OF (0x02) /* High frequency oscillator 2 fault flag */
|
|
|
177 |
#define XCAP0 (0x04) /* XIN/XOUT Cap 0 */
|
|
|
178 |
#define XCAP1 (0x08) /* XIN/XOUT Cap 1 */
|
|
|
179 |
#define LFXT1S0 (0x10) /* Mode 0 for LFXT1 (XTS = 0) */
|
|
|
180 |
#define LFXT1S1 (0x20) /* Mode 1 for LFXT1 (XTS = 0) */
|
|
|
181 |
#define XT2S0 (0x40) /* Mode 0 for XT2 */
|
|
|
182 |
#define XT2S1 (0x80) /* Mode 1 for XT2 */
|
|
|
183 |
|
|
|
184 |
#define XCAP_0 (0x00) /* XIN/XOUT Cap : 0 pF */
|
|
|
185 |
#define XCAP_1 (0x04) /* XIN/XOUT Cap : 6 pF */
|
|
|
186 |
#define XCAP_2 (0x08) /* XIN/XOUT Cap : 10 pF */
|
|
|
187 |
#define XCAP_3 (0x0C) /* XIN/XOUT Cap : 12.5 pF */
|
|
|
188 |
|
|
|
189 |
#define LFXT1S_0 (0x00) /* Mode 0 for LFXT1 : Normal operation */
|
|
|
190 |
#define LFXT1S_1 (0x10) /* Mode 1 for LFXT1 : Reserved */
|
|
|
191 |
#define LFXT1S_2 (0x20) /* Mode 2 for LFXT1 : VLO */
|
|
|
192 |
#define LFXT1S_3 (0x30) /* Mode 3 for LFXT1 : Digital input signal */
|
|
|
193 |
|
|
|
194 |
#define XT2S_0 (0x00) /* Mode 0 for XT2 : 0.4 - 1 MHz */
|
|
|
195 |
#define XT2S_1 (0x40) /* Mode 1 for XT2 : 1 - 4 MHz */
|
|
|
196 |
#define XT2S_2 (0x80) /* Mode 2 for XT2 : 2 - 16 MHz */
|
|
|
197 |
#define XT2S_3 (0xC0) /* Mode 3 for XT2 : Digital input signal */
|
|
|
198 |
|
|
|
199 |
/*************************************************************
|
|
|
200 |
* Flash Memory
|
|
|
201 |
*************************************************************/
|
|
|
202 |
#define __MSP430_HAS_FLASH2__ /* Definition to show that Module is available */
|
|
|
203 |
|
|
|
204 |
SFR_16BIT(FCTL1); /* FLASH Control 1 */
|
|
|
205 |
SFR_16BIT(FCTL2); /* FLASH Control 2 */
|
|
|
206 |
SFR_16BIT(FCTL3); /* FLASH Control 3 */
|
|
|
207 |
|
|
|
208 |
#define FRKEY (0x9600) /* Flash key returned by read */
|
|
|
209 |
#define FWKEY (0xA500) /* Flash key for write */
|
|
|
210 |
#define FXKEY (0x3300) /* for use with XOR instruction */
|
|
|
211 |
|
|
|
212 |
#define ERASE (0x0002) /* Enable bit for Flash segment erase */
|
|
|
213 |
#define MERAS (0x0004) /* Enable bit for Flash mass erase */
|
|
|
214 |
#define WRT (0x0040) /* Enable bit for Flash write */
|
|
|
215 |
#define BLKWRT (0x0080) /* Enable bit for Flash segment write */
|
|
|
216 |
#define SEGWRT (0x0080) /* old definition */ /* Enable bit for Flash segment write */
|
|
|
217 |
|
|
|
218 |
#define FN0 (0x0001) /* Divide Flash clock by 1 to 64 using FN0 to FN5 according to: */
|
|
|
219 |
#define FN1 (0x0002) /* 32*FN5 + 16*FN4 + 8*FN3 + 4*FN2 + 2*FN1 + FN0 + 1 */
|
|
|
220 |
#ifndef FN2
|
|
|
221 |
#define FN2 (0x0004)
|
|
|
222 |
#endif
|
|
|
223 |
#ifndef FN3
|
|
|
224 |
#define FN3 (0x0008)
|
|
|
225 |
#endif
|
|
|
226 |
#ifndef FN4
|
|
|
227 |
#define FN4 (0x0010)
|
|
|
228 |
#endif
|
|
|
229 |
#define FN5 (0x0020)
|
|
|
230 |
#define FSSEL0 (0x0040) /* Flash clock select 0 */ /* to distinguish from USART SSELx */
|
|
|
231 |
#define FSSEL1 (0x0080) /* Flash clock select 1 */
|
|
|
232 |
|
|
|
233 |
#define FSSEL_0 (0x0000) /* Flash clock select: 0 - ACLK */
|
|
|
234 |
#define FSSEL_1 (0x0040) /* Flash clock select: 1 - MCLK */
|
|
|
235 |
#define FSSEL_2 (0x0080) /* Flash clock select: 2 - SMCLK */
|
|
|
236 |
#define FSSEL_3 (0x00C0) /* Flash clock select: 3 - SMCLK */
|
|
|
237 |
|
|
|
238 |
#define BUSY (0x0001) /* Flash busy: 1 */
|
|
|
239 |
#define KEYV (0x0002) /* Flash Key violation flag */
|
|
|
240 |
#define ACCVIFG (0x0004) /* Flash Access violation flag */
|
|
|
241 |
#define WAIT (0x0008) /* Wait flag for segment write */
|
|
|
242 |
#define LOCK (0x0010) /* Lock bit: 1 - Flash is locked (read only) */
|
|
|
243 |
#define EMEX (0x0020) /* Flash Emergency Exit */
|
|
|
244 |
#define LOCKA (0x0040) /* Segment A Lock bit: read = 1 - Segment is locked (read only) */
|
|
|
245 |
#define FAIL (0x0080) /* Last Program or Erase failed */
|
|
|
246 |
|
|
|
247 |
/************************************************************
|
|
|
248 |
* DIGITAL I/O Port1/2 Pull up / Pull down Resistors
|
|
|
249 |
************************************************************/
|
|
|
250 |
#define __MSP430_HAS_PORT1_R__ /* Definition to show that Module is available */
|
|
|
251 |
#define __MSP430_HAS_PORT2_R__ /* Definition to show that Module is available */
|
|
|
252 |
|
|
|
253 |
SFR_8BIT(P1IN); /* Port 1 Input */
|
|
|
254 |
SFR_8BIT(P1OUT); /* Port 1 Output */
|
|
|
255 |
SFR_8BIT(P1DIR); /* Port 1 Direction */
|
|
|
256 |
SFR_8BIT(P1IFG); /* Port 1 Interrupt Flag */
|
|
|
257 |
SFR_8BIT(P1IES); /* Port 1 Interrupt Edge Select */
|
|
|
258 |
SFR_8BIT(P1IE); /* Port 1 Interrupt Enable */
|
|
|
259 |
SFR_8BIT(P1SEL); /* Port 1 Selection */
|
|
|
260 |
SFR_8BIT(P1REN); /* Port 1 Resistor Enable */
|
|
|
261 |
|
|
|
262 |
SFR_8BIT(P2IN); /* Port 2 Input */
|
|
|
263 |
SFR_8BIT(P2OUT); /* Port 2 Output */
|
|
|
264 |
SFR_8BIT(P2DIR); /* Port 2 Direction */
|
|
|
265 |
SFR_8BIT(P2IFG); /* Port 2 Interrupt Flag */
|
|
|
266 |
SFR_8BIT(P2IES); /* Port 2 Interrupt Edge Select */
|
|
|
267 |
SFR_8BIT(P2IE); /* Port 2 Interrupt Enable */
|
|
|
268 |
SFR_8BIT(P2SEL); /* Port 2 Selection */
|
|
|
269 |
SFR_8BIT(P2REN); /* Port 2 Resistor Enable */
|
|
|
270 |
|
|
|
271 |
/************************************************************
|
|
|
272 |
* Timer A2
|
|
|
273 |
************************************************************/
|
|
|
274 |
#define __MSP430_HAS_TA2__ /* Definition to show that Module is available */
|
|
|
275 |
|
|
|
276 |
SFR_16BIT(TAIV); /* Timer A Interrupt Vector Word */
|
|
|
277 |
SFR_16BIT(TACTL); /* Timer A Control */
|
|
|
278 |
SFR_16BIT(TACCTL0); /* Timer A Capture/Compare Control 0 */
|
|
|
279 |
SFR_16BIT(TACCTL1); /* Timer A Capture/Compare Control 1 */
|
|
|
280 |
SFR_16BIT(TAR); /* Timer A Counter Register */
|
|
|
281 |
SFR_16BIT(TACCR0); /* Timer A Capture/Compare 0 */
|
|
|
282 |
SFR_16BIT(TACCR1); /* Timer A Capture/Compare 1 */
|
|
|
283 |
|
|
|
284 |
/* Alternate register names */
|
|
|
285 |
#define CCTL0 TACCTL0 /* Timer A Capture/Compare Control 0 */
|
|
|
286 |
#define CCTL1 TACCTL1 /* Timer A Capture/Compare Control 1 */
|
|
|
287 |
#define CCR0 TACCR0 /* Timer A Capture/Compare 0 */
|
|
|
288 |
#define CCR1 TACCR1 /* Timer A Capture/Compare 1 */
|
|
|
289 |
#define CCTL0_ TACCTL0_ /* Timer A Capture/Compare Control 0 */
|
|
|
290 |
#define CCTL1_ TACCTL1_ /* Timer A Capture/Compare Control 1 */
|
|
|
291 |
#define CCR0_ TACCR0_ /* Timer A Capture/Compare 0 */
|
|
|
292 |
#define CCR1_ TACCR1_ /* Timer A Capture/Compare 1 */
|
|
|
293 |
/* Alternate register names - 5xx style */
|
|
|
294 |
#define TA0IV TAIV /* Timer A Interrupt Vector Word */
|
|
|
295 |
#define TA0CTL TACTL /* Timer A Control */
|
|
|
296 |
#define TA0CCTL0 TACCTL0 /* Timer A Capture/Compare Control 0 */
|
|
|
297 |
#define TA0CCTL1 TACCTL1 /* Timer A Capture/Compare Control 1 */
|
|
|
298 |
#define TA0R TAR /* Timer A Counter Register */
|
|
|
299 |
#define TA0CCR0 TACCR0 /* Timer A Capture/Compare 0 */
|
|
|
300 |
#define TA0CCR1 TACCR1 /* Timer A Capture/Compare 1 */
|
|
|
301 |
#define TA0IV_ TAIV_ /* Timer A Interrupt Vector Word */
|
|
|
302 |
#define TA0CTL_ TACTL_ /* Timer A Control */
|
|
|
303 |
#define TA0CCTL0_ TACCTL0_ /* Timer A Capture/Compare Control 0 */
|
|
|
304 |
#define TA0CCTL1_ TACCTL1_ /* Timer A Capture/Compare Control 1 */
|
|
|
305 |
#define TA0R_ TAR_ /* Timer A Counter Register */
|
|
|
306 |
#define TA0CCR0_ TACCR0_ /* Timer A Capture/Compare 0 */
|
|
|
307 |
#define TA0CCR1_ TACCR1_ /* Timer A Capture/Compare 1 */
|
|
|
308 |
|
|
|
309 |
#define TASSEL1 (0x0200) /* Timer A clock source select 0 */
|
|
|
310 |
#define TASSEL0 (0x0100) /* Timer A clock source select 1 */
|
|
|
311 |
#define ID1 (0x0080) /* Timer A clock input divider 1 */
|
|
|
312 |
#define ID0 (0x0040) /* Timer A clock input divider 0 */
|
|
|
313 |
#define MC1 (0x0020) /* Timer A mode control 1 */
|
|
|
314 |
#define MC0 (0x0010) /* Timer A mode control 0 */
|
|
|
315 |
#define TACLR (0x0004) /* Timer A counter clear */
|
|
|
316 |
#define TAIE (0x0002) /* Timer A counter interrupt enable */
|
|
|
317 |
#define TAIFG (0x0001) /* Timer A counter interrupt flag */
|
|
|
318 |
|
|
|
319 |
#define MC_0 (0*0x10u) /* Timer A mode control: 0 - Stop */
|
|
|
320 |
#define MC_1 (1*0x10u) /* Timer A mode control: 1 - Up to CCR0 */
|
|
|
321 |
#define MC_2 (2*0x10u) /* Timer A mode control: 2 - Continous up */
|
|
|
322 |
#define MC_3 (3*0x10u) /* Timer A mode control: 3 - Up/Down */
|
|
|
323 |
#define ID_0 (0*0x40u) /* Timer A input divider: 0 - /1 */
|
|
|
324 |
#define ID_1 (1*0x40u) /* Timer A input divider: 1 - /2 */
|
|
|
325 |
#define ID_2 (2*0x40u) /* Timer A input divider: 2 - /4 */
|
|
|
326 |
#define ID_3 (3*0x40u) /* Timer A input divider: 3 - /8 */
|
|
|
327 |
#define TASSEL_0 (0*0x100u) /* Timer A clock source select: 0 - TACLK */
|
|
|
328 |
#define TASSEL_1 (1*0x100u) /* Timer A clock source select: 1 - ACLK */
|
|
|
329 |
#define TASSEL_2 (2*0x100u) /* Timer A clock source select: 2 - SMCLK */
|
|
|
330 |
#define TASSEL_3 (3*0x100u) /* Timer A clock source select: 3 - INCLK */
|
|
|
331 |
|
|
|
332 |
#define CM1 (0x8000) /* Capture mode 1 */
|
|
|
333 |
#define CM0 (0x4000) /* Capture mode 0 */
|
|
|
334 |
#define CCIS1 (0x2000) /* Capture input select 1 */
|
|
|
335 |
#define CCIS0 (0x1000) /* Capture input select 0 */
|
|
|
336 |
#define SCS (0x0800) /* Capture sychronize */
|
|
|
337 |
#define SCCI (0x0400) /* Latched capture signal (read) */
|
|
|
338 |
#define CAP (0x0100) /* Capture mode: 1 /Compare mode : 0 */
|
|
|
339 |
#define OUTMOD2 (0x0080) /* Output mode 2 */
|
|
|
340 |
#define OUTMOD1 (0x0040) /* Output mode 1 */
|
|
|
341 |
#define OUTMOD0 (0x0020) /* Output mode 0 */
|
|
|
342 |
#define CCIE (0x0010) /* Capture/compare interrupt enable */
|
|
|
343 |
#define CCI (0x0008) /* Capture input signal (read) */
|
|
|
344 |
#define OUT (0x0004) /* PWM Output signal if output mode 0 */
|
|
|
345 |
#define COV (0x0002) /* Capture/compare overflow flag */
|
|
|
346 |
#define CCIFG (0x0001) /* Capture/compare interrupt flag */
|
|
|
347 |
|
|
|
348 |
#define OUTMOD_0 (0*0x20u) /* PWM output mode: 0 - output only */
|
|
|
349 |
#define OUTMOD_1 (1*0x20u) /* PWM output mode: 1 - set */
|
|
|
350 |
#define OUTMOD_2 (2*0x20u) /* PWM output mode: 2 - PWM toggle/reset */
|
|
|
351 |
#define OUTMOD_3 (3*0x20u) /* PWM output mode: 3 - PWM set/reset */
|
|
|
352 |
#define OUTMOD_4 (4*0x20u) /* PWM output mode: 4 - toggle */
|
|
|
353 |
#define OUTMOD_5 (5*0x20u) /* PWM output mode: 5 - Reset */
|
|
|
354 |
#define OUTMOD_6 (6*0x20u) /* PWM output mode: 6 - PWM toggle/set */
|
|
|
355 |
#define OUTMOD_7 (7*0x20u) /* PWM output mode: 7 - PWM reset/set */
|
|
|
356 |
#define CCIS_0 (0*0x1000u) /* Capture input select: 0 - CCIxA */
|
|
|
357 |
#define CCIS_1 (1*0x1000u) /* Capture input select: 1 - CCIxB */
|
|
|
358 |
#define CCIS_2 (2*0x1000u) /* Capture input select: 2 - GND */
|
|
|
359 |
#define CCIS_3 (3*0x1000u) /* Capture input select: 3 - Vcc */
|
|
|
360 |
#define CM_0 (0*0x4000u) /* Capture mode: 0 - disabled */
|
|
|
361 |
#define CM_1 (1*0x4000u) /* Capture mode: 1 - pos. edge */
|
|
|
362 |
#define CM_2 (2*0x4000u) /* Capture mode: 1 - neg. edge */
|
|
|
363 |
#define CM_3 (3*0x4000u) /* Capture mode: 1 - both edges */
|
|
|
364 |
|
|
|
365 |
/* TA2IV Definitions */
|
|
|
366 |
#define TAIV_NONE (0x0000) /* No Interrupt pending */
|
|
|
367 |
#define TAIV_TACCR1 (0x0002) /* TACCR1_CCIFG */
|
|
|
368 |
#define TAIV_2 (0x0004) /* Reserved */
|
|
|
369 |
#define TAIV_6 (0x0006) /* Reserved */
|
|
|
370 |
#define TAIV_8 (0x0008) /* Reserved */
|
|
|
371 |
#define TAIV_TAIFG (0x000A) /* TAIFG */
|
|
|
372 |
|
|
|
373 |
/************************************************************
|
|
|
374 |
* USI
|
|
|
375 |
************************************************************/
|
|
|
376 |
#define __MSP430_HAS_USI__ /* Definition to show that Module is available */
|
|
|
377 |
|
|
|
378 |
SFR_8BIT(USICTL0); /* USI Control Register 0 */
|
|
|
379 |
SFR_8BIT(USICTL1); /* USI Control Register 1 */
|
|
|
380 |
SFR_8BIT(USICKCTL); /* USI Clock Control Register */
|
|
|
381 |
SFR_8BIT(USICNT); /* USI Bit Counter Register */
|
|
|
382 |
SFR_8BIT(USISRL); /* USI Low Byte Shift Register */
|
|
|
383 |
SFR_8BIT(USISRH); /* USI High Byte Shift Register */
|
|
|
384 |
SFR_16BIT(USICTL); /* USI Control Register */
|
|
|
385 |
SFR_16BIT(USICCTL); /* USI Clock and Counter Control Register */
|
|
|
386 |
SFR_16BIT(USISR); /* USI Shift Register */
|
|
|
387 |
|
|
|
388 |
#define USIPE7 (0x80) /* USI Port Enable Px.7 */
|
|
|
389 |
#define USIPE6 (0x40) /* USI Port Enable Px.6 */
|
|
|
390 |
#define USIPE5 (0x20) /* USI Port Enable Px.5 */
|
|
|
391 |
#define USILSB (0x10) /* USI LSB first 1:LSB / 0:MSB */
|
|
|
392 |
#define USIMST (0x08) /* USI Master Select 0:Slave / 1:Master */
|
|
|
393 |
#define USIGE (0x04) /* USI General Output Enable Latch */
|
|
|
394 |
#define USIOE (0x02) /* USI Output Enable */
|
|
|
395 |
#define USISWRST (0x01) /* USI Software Reset */
|
|
|
396 |
|
|
|
397 |
#define USICKPH (0x80) /* USI Sync. Mode: Clock Phase */
|
|
|
398 |
#define USII2C (0x40) /* USI I2C Mode */
|
|
|
399 |
#define USISTTIE (0x20) /* USI START Condition interrupt enable */
|
|
|
400 |
#define USIIE (0x10) /* USI Counter Interrupt enable */
|
|
|
401 |
#define USIAL (0x08) /* USI Arbitration Lost */
|
|
|
402 |
#define USISTP (0x04) /* USI STOP Condition received */
|
|
|
403 |
#define USISTTIFG (0x02) /* USI START Condition interrupt Flag */
|
|
|
404 |
#define USIIFG (0x01) /* USI Counter Interrupt Flag */
|
|
|
405 |
|
|
|
406 |
#define USIDIV2 (0x80) /* USI Clock Divider 2 */
|
|
|
407 |
#define USIDIV1 (0x40) /* USI Clock Divider 1 */
|
|
|
408 |
#define USIDIV0 (0x20) /* USI Clock Divider 0 */
|
|
|
409 |
#define USISSEL2 (0x10) /* USI Clock Source Select 2 */
|
|
|
410 |
#define USISSEL1 (0x08) /* USI Clock Source Select 1 */
|
|
|
411 |
#define USISSEL0 (0x04) /* USI Clock Source Select 0 */
|
|
|
412 |
#define USICKPL (0x02) /* USI Clock Polarity 0:Inactive=Low / 1:Inactive=High */
|
|
|
413 |
#define USISWCLK (0x01) /* USI Software Clock */
|
|
|
414 |
|
|
|
415 |
#define USIDIV_0 (0x00) /* USI Clock Divider: 0 */
|
|
|
416 |
#define USIDIV_1 (0x20) /* USI Clock Divider: 1 */
|
|
|
417 |
#define USIDIV_2 (0x40) /* USI Clock Divider: 2 */
|
|
|
418 |
#define USIDIV_3 (0x60) /* USI Clock Divider: 3 */
|
|
|
419 |
#define USIDIV_4 (0x80) /* USI Clock Divider: 4 */
|
|
|
420 |
#define USIDIV_5 (0xA0) /* USI Clock Divider: 5 */
|
|
|
421 |
#define USIDIV_6 (0xC0) /* USI Clock Divider: 6 */
|
|
|
422 |
#define USIDIV_7 (0xE0) /* USI Clock Divider: 7 */
|
|
|
423 |
|
|
|
424 |
#define USISSEL_0 (0x00) /* USI Clock Source: 0 */
|
|
|
425 |
#define USISSEL_1 (0x04) /* USI Clock Source: 1 */
|
|
|
426 |
#define USISSEL_2 (0x08) /* USI Clock Source: 2 */
|
|
|
427 |
#define USISSEL_3 (0x0C) /* USI Clock Source: 3 */
|
|
|
428 |
#define USISSEL_4 (0x10) /* USI Clock Source: 4 */
|
|
|
429 |
#define USISSEL_5 (0x14) /* USI Clock Source: 5 */
|
|
|
430 |
#define USISSEL_6 (0x18) /* USI Clock Source: 6 */
|
|
|
431 |
#define USISSEL_7 (0x1C) /* USI Clock Source: 7 */
|
|
|
432 |
|
|
|
433 |
#define USISCLREL (0x80) /* USI SCL Released */
|
|
|
434 |
#define USI16B (0x40) /* USI 16 Bit Shift Register Enable */
|
|
|
435 |
#define USIIFGCC (0x20) /* USI Interrupt Flag Clear Control */
|
|
|
436 |
#define USICNT4 (0x10) /* USI Bit Count 4 */
|
|
|
437 |
#define USICNT3 (0x08) /* USI Bit Count 3 */
|
|
|
438 |
#define USICNT2 (0x04) /* USI Bit Count 2 */
|
|
|
439 |
#define USICNT1 (0x02) /* USI Bit Count 1 */
|
|
|
440 |
#define USICNT0 (0x01) /* USI Bit Count 0 */
|
|
|
441 |
/************************************************************
|
|
|
442 |
* WATCHDOG TIMER
|
|
|
443 |
************************************************************/
|
|
|
444 |
#define __MSP430_HAS_WDT__ /* Definition to show that Module is available */
|
|
|
445 |
|
|
|
446 |
SFR_16BIT(WDTCTL); /* Watchdog Timer Control */
|
|
|
447 |
/* The bit names have been prefixed with "WDT" */
|
|
|
448 |
#define WDTIS0 (0x0001)
|
|
|
449 |
#define WDTIS1 (0x0002)
|
|
|
450 |
#define WDTSSEL (0x0004)
|
|
|
451 |
#define WDTCNTCL (0x0008)
|
|
|
452 |
#define WDTTMSEL (0x0010)
|
|
|
453 |
#define WDTNMI (0x0020)
|
|
|
454 |
#define WDTNMIES (0x0040)
|
|
|
455 |
#define WDTHOLD (0x0080)
|
|
|
456 |
|
|
|
457 |
#define WDTPW (0x5A00)
|
|
|
458 |
|
|
|
459 |
/* WDT-interval times [1ms] coded with Bits 0-2 */
|
|
|
460 |
/* WDT is clocked by fSMCLK (assumed 1MHz) */
|
|
|
461 |
#define WDT_MDLY_32 (WDTPW+WDTTMSEL+WDTCNTCL) /* 32ms interval (default) */
|
|
|
462 |
#define WDT_MDLY_8 (WDTPW+WDTTMSEL+WDTCNTCL+WDTIS0) /* 8ms " */
|
|
|
463 |
#define WDT_MDLY_0_5 (WDTPW+WDTTMSEL+WDTCNTCL+WDTIS1) /* 0.5ms " */
|
|
|
464 |
#define WDT_MDLY_0_064 (WDTPW+WDTTMSEL+WDTCNTCL+WDTIS1+WDTIS0) /* 0.064ms " */
|
|
|
465 |
/* WDT is clocked by fACLK (assumed 32KHz) */
|
|
|
466 |
#define WDT_ADLY_1000 (WDTPW+WDTTMSEL+WDTCNTCL+WDTSSEL) /* 1000ms " */
|
|
|
467 |
#define WDT_ADLY_250 (WDTPW+WDTTMSEL+WDTCNTCL+WDTSSEL+WDTIS0) /* 250ms " */
|
|
|
468 |
#define WDT_ADLY_16 (WDTPW+WDTTMSEL+WDTCNTCL+WDTSSEL+WDTIS1) /* 16ms " */
|
|
|
469 |
#define WDT_ADLY_1_9 (WDTPW+WDTTMSEL+WDTCNTCL+WDTSSEL+WDTIS1+WDTIS0) /* 1.9ms " */
|
|
|
470 |
/* Watchdog mode -> reset after expired time */
|
|
|
471 |
/* WDT is clocked by fSMCLK (assumed 1MHz) */
|
|
|
472 |
#define WDT_MRST_32 (WDTPW+WDTCNTCL) /* 32ms interval (default) */
|
|
|
473 |
#define WDT_MRST_8 (WDTPW+WDTCNTCL+WDTIS0) /* 8ms " */
|
|
|
474 |
#define WDT_MRST_0_5 (WDTPW+WDTCNTCL+WDTIS1) /* 0.5ms " */
|
|
|
475 |
#define WDT_MRST_0_064 (WDTPW+WDTCNTCL+WDTIS1+WDTIS0) /* 0.064ms " */
|
|
|
476 |
/* WDT is clocked by fACLK (assumed 32KHz) */
|
|
|
477 |
#define WDT_ARST_1000 (WDTPW+WDTCNTCL+WDTSSEL) /* 1000ms " */
|
|
|
478 |
#define WDT_ARST_250 (WDTPW+WDTCNTCL+WDTSSEL+WDTIS0) /* 250ms " */
|
|
|
479 |
#define WDT_ARST_16 (WDTPW+WDTCNTCL+WDTSSEL+WDTIS1) /* 16ms " */
|
|
|
480 |
#define WDT_ARST_1_9 (WDTPW+WDTCNTCL+WDTSSEL+WDTIS1+WDTIS0) /* 1.9ms " */
|
|
|
481 |
|
|
|
482 |
/* INTERRUPT CONTROL */
|
|
|
483 |
/* These two bits are defined in the Special Function Registers */
|
|
|
484 |
/* #define WDTIE 0x01 */
|
|
|
485 |
/* #define WDTIFG 0x01 */
|
|
|
486 |
|
|
|
487 |
/************************************************************
|
|
|
488 |
* Calibration Data in Info Mem
|
|
|
489 |
************************************************************/
|
|
|
490 |
|
|
|
491 |
#ifndef __DisableCalData
|
|
|
492 |
|
|
|
493 |
SFR_8BIT(CALDCO_1MHZ); /* DCOCTL Calibration Data for 1MHz */
|
|
|
494 |
SFR_8BIT(CALBC1_1MHZ); /* BCSCTL1 Calibration Data for 1MHz */
|
|
|
495 |
|
|
|
496 |
#endif /* #ifndef __DisableCalData */
|
|
|
497 |
|
|
|
498 |
/************************************************************
|
|
|
499 |
* Interrupt Vectors (offset from 0xFFE0)
|
|
|
500 |
************************************************************/
|
|
|
501 |
|
|
|
502 |
#define VECTOR_NAME(name) name##_ptr
|
|
|
503 |
#define EMIT_PRAGMA(x) _Pragma(#x)
|
|
|
504 |
#define CREATE_VECTOR(name) void (* const VECTOR_NAME(name))(void) = &name
|
|
|
505 |
#define PLACE_VECTOR(vector,section) EMIT_PRAGMA(DATA_SECTION(vector,section))
|
|
|
506 |
#define ISR_VECTOR(func,offset) CREATE_VECTOR(func); \
|
|
|
507 |
PLACE_VECTOR(VECTOR_NAME(func), offset)
|
|
|
508 |
|
|
|
509 |
#ifdef __ASM_HEADER__ /* Begin #defines for assembler */
|
|
|
510 |
#define PORT1_VECTOR ".int02" /* 0xFFE4 Port 1 */
|
|
|
511 |
#else
|
|
|
512 |
#define PORT1_VECTOR (2 * 1u) /* 0xFFE4 Port 1 */
|
|
|
513 |
/*#define PORT1_ISR(func) ISR_VECTOR(func, ".int02") */ /* 0xFFE4 Port 1 */ /* CCE V2 Style */
|
|
|
514 |
#endif
|
|
|
515 |
#ifdef __ASM_HEADER__ /* Begin #defines for assembler */
|
|
|
516 |
#define PORT2_VECTOR ".int03" /* 0xFFE6 Port 2 */
|
|
|
517 |
#else
|
|
|
518 |
#define PORT2_VECTOR (3 * 1u) /* 0xFFE6 Port 2 */
|
|
|
519 |
/*#define PORT2_ISR(func) ISR_VECTOR(func, ".int03") */ /* 0xFFE6 Port 2 */ /* CCE V2 Style */
|
|
|
520 |
#endif
|
|
|
521 |
#ifdef __ASM_HEADER__ /* Begin #defines for assembler */
|
|
|
522 |
#define USI_VECTOR ".int04" /* 0xFFE8 USI */
|
|
|
523 |
#else
|
|
|
524 |
#define USI_VECTOR (4 * 1u) /* 0xFFE8 USI */
|
|
|
525 |
/*#define USI_ISR(func) ISR_VECTOR(func, ".int04") */ /* 0xFFE8 USI */ /* CCE V2 Style */
|
|
|
526 |
#endif
|
|
|
527 |
#ifdef __ASM_HEADER__ /* Begin #defines for assembler */
|
|
|
528 |
#define TIMERA1_VECTOR ".int08" /* 0xFFF0 Timer A CC1, TA */
|
|
|
529 |
#else
|
|
|
530 |
#define TIMERA1_VECTOR (8 * 1u) /* 0xFFF0 Timer A CC1, TA */
|
|
|
531 |
/*#define TIMERA1_ISR(func) ISR_VECTOR(func, ".int08") */ /* 0xFFF0 Timer A CC1, TA */ /* CCE V2 Style */
|
|
|
532 |
#endif
|
|
|
533 |
#ifdef __ASM_HEADER__ /* Begin #defines for assembler */
|
|
|
534 |
#define TIMERA0_VECTOR ".int09" /* 0xFFF2 Timer A CC0 */
|
|
|
535 |
#else
|
|
|
536 |
#define TIMERA0_VECTOR (9 * 1u) /* 0xFFF2 Timer A CC0 */
|
|
|
537 |
/*#define TIMERA0_ISR(func) ISR_VECTOR(func, ".int09") */ /* 0xFFF2 Timer A CC0 */ /* CCE V2 Style */
|
|
|
538 |
#endif
|
|
|
539 |
#ifdef __ASM_HEADER__ /* Begin #defines for assembler */
|
|
|
540 |
#define WDT_VECTOR ".int10" /* 0xFFF4 Watchdog Timer */
|
|
|
541 |
#else
|
|
|
542 |
#define WDT_VECTOR (10 * 1u) /* 0xFFF4 Watchdog Timer */
|
|
|
543 |
/*#define WDT_ISR(func) ISR_VECTOR(func, ".int10") */ /* 0xFFF4 Watchdog Timer */ /* CCE V2 Style */
|
|
|
544 |
#endif
|
|
|
545 |
#ifdef __ASM_HEADER__ /* Begin #defines for assembler */
|
|
|
546 |
#define NMI_VECTOR ".int14" /* 0xFFFC Non-maskable */
|
|
|
547 |
#else
|
|
|
548 |
#define NMI_VECTOR (14 * 1u) /* 0xFFFC Non-maskable */
|
|
|
549 |
/*#define NMI_ISR(func) ISR_VECTOR(func, ".int14") */ /* 0xFFFC Non-maskable */ /* CCE V2 Style */
|
|
|
550 |
#endif
|
|
|
551 |
#ifdef __ASM_HEADER__ /* Begin #defines for assembler */
|
|
|
552 |
#define RESET_VECTOR ".reset" /* 0xFFFE Reset [Highest Priority] */
|
|
|
553 |
#else
|
|
|
554 |
#define RESET_VECTOR (15 * 1u) /* 0xFFFE Reset [Highest Priority] */
|
|
|
555 |
/*#define RESET_ISR(func) ISR_VECTOR(func, ".int15") */ /* 0xFFFE Reset [Highest Priority] */ /* CCE V2 Style */
|
|
|
556 |
#endif
|
|
|
557 |
|
|
|
558 |
/************************************************************
|
|
|
559 |
* End of Modules
|
|
|
560 |
************************************************************/
|
|
|
561 |
|
|
|
562 |
#ifdef __cplusplus
|
|
|
563 |
}
|
|
|
564 |
#endif /* extern "C" */
|
|
|
565 |
|
|
|
566 |
#endif /* #ifndef __MSP430G2221 */
|
|
|
567 |
|