Texas Instruments MSP430x1xx manual

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432

Go to page of

A good user manual

The rules should oblige the seller to give the purchaser an operating instrucion of Texas Instruments MSP430x1xx, along with an item. The lack of an instruction or false information given to customer shall constitute grounds to apply for a complaint because of nonconformity of goods with the contract. In accordance with the law, a customer can receive an instruction in non-paper form; lately graphic and electronic forms of the manuals, as well as instructional videos have been majorly used. A necessary precondition for this is the unmistakable, legible character of an instruction.

What is an instruction?

The term originates from the Latin word „instructio”, which means organizing. Therefore, in an instruction of Texas Instruments MSP430x1xx one could find a process description. An instruction's purpose is to teach, to ease the start-up and an item's use or performance of certain activities. An instruction is a compilation of information about an item/a service, it is a clue.

Unfortunately, only a few customers devote their time to read an instruction of Texas Instruments MSP430x1xx. A good user manual introduces us to a number of additional functionalities of the purchased item, and also helps us to avoid the formation of most of the defects.

What should a perfect user manual contain?

First and foremost, an user manual of Texas Instruments MSP430x1xx should contain:
- informations concerning technical data of Texas Instruments MSP430x1xx
- name of the manufacturer and a year of construction of the Texas Instruments MSP430x1xx item
- rules of operation, control and maintenance of the Texas Instruments MSP430x1xx item
- safety signs and mark certificates which confirm compatibility with appropriate standards

Why don't we read the manuals?

Usually it results from the lack of time and certainty about functionalities of purchased items. Unfortunately, networking and start-up of Texas Instruments MSP430x1xx alone are not enough. An instruction contains a number of clues concerning respective functionalities, safety rules, maintenance methods (what means should be used), eventual defects of Texas Instruments MSP430x1xx, and methods of problem resolution. Eventually, when one still can't find the answer to his problems, he will be directed to the Texas Instruments service. Lately animated manuals and instructional videos are quite popular among customers. These kinds of user manuals are effective; they assure that a customer will familiarize himself with the whole material, and won't skip complicated, technical information of Texas Instruments MSP430x1xx.

Why one should read the manuals?

It is mostly in the manuals where we will find the details concerning construction and possibility of the Texas Instruments MSP430x1xx item, and its use of respective accessory, as well as information concerning all the functions and facilities.

After a successful purchase of an item one should find a moment and get to know with every part of an instruction. Currently the manuals are carefully prearranged and translated, so they could be fully understood by its users. The manuals will serve as an informational aid.

Table of contents for the manual

  • Page 1

      2005 Mixed Signal Products User ’ s G uide SLAU049E[...]

  • Page 2

    IMPORT ANT NOTICE T exas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements, and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should obtain the latest relevant information before placing orde[...]

  • Page 3

    Related Documentation From T exas Instruments iii Preface  About This Manual This manual discusses modules and peripherals of the MSP430x1xx family of devices. Each discussion presents the module or peripheral in a general sense. Not all features and functions of all modules or peripherals are present on[...]

  • Page 4

    Glossary iv Glossary ACLK Auxiliary Clock See Basic Clock Module ADC Analog-to-Digital Converter BOR Brown-Out Reset See System Resets, Interrupts, and Operating Modes BSL Bootstrap Loader See www .ti.com/msp430 for application reports CPU Central Processing Unit See RISC 16-Bit CPU DAC Digital-to-Analog Converter DCO Digitally Controlled Oscillato[...]

  • Page 5

    Register Bit Conventions v Register Bit Conventions Each register is shown with a key indicating the accessibility of the each individual bit, and the initial condition: Register Bit Accessibility and Initial Condition Key Bit Accessibility rw Read/write r Read only r0 Read as 0 r1 Read as 1 w W rite only w0 Write as 0 w1 Write as 1 (w) No register[...]

  • Page 6

    vi[...]

  • Page 7

    Contents vii  1 Introduction 1-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1 Architecture 1-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Fl[...]

  • Page 8

    Contents viii 3 RISC 16-Bit CPU 3-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1 CPU Introduction 3-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 CPU Registers 3-4 . . . . . . . . . .[...]

  • Page 9

    Contents ix 6 Supply V oltage Supervisor 6-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1 SVS Introduction 6-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2 SVS Operation 6-4 . . . . . . . . . . . . . . . [...]

  • Page 10

    Contents x 10 W atchdog Timer 10-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.1 W atchdog Timer Introduction 10-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.2 W atchdog Timer Operation 10-4 . . . . . . . . [...]

  • Page 11

    Contents xi 14 USART Peripheral Interface, SPI Mode 14-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14.1 USAR T Introduction: SPI Mode 14-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14.2 USAR T Operation: SPI Mode 14-4 . . . . . . . . . . . . . . . . . . . [...]

  • Page 12

    Contents xii 18 ADC10 18-1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.1 ADC10 Introduction 18-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.2 ADC10 Operation 18-4 . . . . . [...]

  • Page 13

    1-1 Introduction  This chapter describes the architecture of the MSP430. T opic Page 1.1 Architecture 1-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Flexible Clock System 1-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [...]

  • Page 14

    Architecture 1-2 Introduction 1.1 Architecture Th e MSP430 incorporates a 16-bit RISC CPU, peripherals, and a flexible clock system that interconnect using a von-Neumann common memory address bus (MAB) and memory data bus (MDB). Partnering a modern CPU with modular memory-mapped analog and digital peripherals, the MSP430 offers solutions for demand[...]

  • Page 15

    Embedded Emulation 1-3 Introduction Figure 1−1. MSP430 Architecture ACLK Bus Conv . Peripheral MAB 16-Bit MDB 16-Bit MCLK SMCLK Clock System Peripheral Peripheral Peripheral Peripheral Peripheral Peripheral W atchdog RAM Flash/ RISC CPU 16-Bit JT AG/Debug ACLK SMCLK ROM MDB 8-Bit JT AG 1.3 Embedded Emulation Dedicated embedded emulation logic res[...]

  • Page 16

    Address Space 1-4 Introduction 1.4 Address Space The MSP430 von-Neumann architecture has one address space shared with special function registers (SFRs), peripherals, RAM, and Flash/ROM memory as shown in Figure 1−2. See the device-specific data sheets for specific memory maps. Code access are always performed on even addresses. Data can be acces[...]

  • Page 17

    Address Space 1-5 Introduction 1.4.3 Peripheral Modules Peripheral modules are mapped into the address space. The address space from 0100 to 01FFh is reserved for 16-bit peripheral modules. These modules should be accessed with word instructions. If byte instructions are used, only even addresses are permissible, and the high byte of the result is [...]

  • Page 18

    1-6 Introduction[...]

  • Page 19

    2-1 System Resets, Interrupts, and Operating Modes   This chapter describes the MSP430x1xx system resets, interrupts, and operating modes. T opic Page 2.1 System Reset and Initialization 2-2 . . . . . . . . . . . . [...]

  • Page 20

    System Reset and Initialization 2-2 System Resets, Interrupts, and Operating Modes 2.1 System Reset and Initialization Th e system reset circuitry shown in Figure 2−1 sources both a power-on reset (POR) and a power-up clear (PUC) signal. Dif ferent eve nts trigger these reset signals and different initial conditions exist depending on which signa[...]

  • Page 21

    System Reset and Initialization 2-3 System Resets, Interrupts, and Operating Modes 2.1.1 Power-On Reset (POR) When the V CC rise time is slow , the POR detector holds the POR signal active until V CC has risen above the V POR level, as shown in Figure 2−2. When the V CC supply provides a fast rise time the POR delay , t (POR_DELA Y) , provides ac[...]

  • Page 22

    System Reset and Initialization 2-4 System Resets, Interrupts, and Operating Modes 2.1.2 Brownout Reset (BOR) Some devices have a brownout reset circuit (see device-specific datasheet) that replaces the POR detect and POR delay circuits. The brownout reset circuit detects low supply voltages such as when a supply voltage is applied to or removed fr[...]

  • Page 23

    System Reset and Initialization 2-5 System Resets, Interrupts, and Operating Modes 2.1.3 Device Initial Conditions After System Reset After a POR, the initial MSP430 conditions are: - The RST /NMI pin is configured in the reset mode. - I/ O pins are switched to input mode as described in the Digital I/O chapter . - Other peripheral modules and regi[...]

  • Page 24

    System Reset and Initialization 2-6 System Resets, Interrupts, and Operating Modes 2.2 Interrupts The interrupt priorities are fixed and defined by the arrangement of the modules in the connection chain as shown in Figure 2−4. The nearer a module is to the CPU/NMIRS, the higher the priority . Interrupt priorities determine what interrupt is taken[...]

  • Page 25

    System Reset and Initialization 2-7 System Resets, Interrupts, and Operating Modes 2.2.1 (Non)-Maskable Interrupts (NMI) (Non)-maskable NMI interrupts are not masked by the general interrupt enable bit (GIE), but are enabled by individual interrupt enable bits (NMIIE, ACCVIE, OFIE). When a NMI interrupt is accepted, all NMI interrupt enable bits ar[...]

  • Page 26

    System Reset and Initialization 2-8 System Resets, Interrupts, and Operating Modes Figure 2−5. Block Diagram of (Non)-Maskable Interrupt Sources Flash Module KEYV System Reset Generator V CC POR PUC WDTQn EQU PUC POR PUC POR NMIRS Clear S WDTIFG IRQ WDTIE Clear IE1.0 PUC POR IRQA WDTTMSEL Counter IFG1.0 WDTNMI WDTTMSEL WDTNMIES W atchdog Timer Mo[...]

  • Page 27

    System Reset and Initialization 2-9 System Resets, Interrupts, and Operating Modes Flash Access Violation Th e flash ACCVIFG flag is set when a flash access violation occurs. The flash access violation can be enabled to generate an NMI interrupt by setting the ACCVIE bit. The ACCVIFG flag can then be tested by NMI the interrupt service routine to d[...]

  • Page 28

    System Reset and Initialization 2-10 System Resets, Interrupts, and Operating Modes Example of an NMI Interrupt Handler Th e NMI interrupt is a multiple-source interrupt. An NMI interrupt automatically resets the NMIIE, OFIE and ACCVIE interrupt-enable bits. The user NMI service routine resets the interrupt flags and re-enables the interrupt-enable[...]

  • Page 29

    System Reset and Initialization 2-1 1 System Resets, Interrupts, and Operating Modes Each individual peripheral interrupt is discussed in the associated peripheral module chapter in this manual. 2.2.3 Interrupt Processing When an interrupt is requested from a peripheral and the peripheral interrupt enable bit and GIE bit are set, the interrupt serv[...]

  • Page 30

    System Reset and Initialization 2-12 System Resets, Interrupts, and Operating Modes Return From Interrupt The interrupt handling routine terminates with the instruction: RETI (return from an interrupt service routine) The return from the interrupt takes 5 cycles to execute the following actions and is illustrated in Figure 2−8. 1) The SR with all[...]

  • Page 31

    System Reset and Initialization 2-13 System Resets, Interrupts, and Operating Modes 2.2.4 Interrupt V ectors The interrupt vectors and the power-up starting address are located in the address range 0FFFFh − 0FFE0h as described in T able 2−1. A vector is programmed by the user with the 16-bit address of the corresponding interrupt service routin[...]

  • Page 32

    Operating Modes 2-14 System Resets, Interrupts, and Operating Modes 2.3 Operating Modes The MSP430 family is designed for ultralow-power applications and uses different operating modes shown in Figure 2−10. The operating modes take into account three different needs: - Ultralow-power - Speed and data throughput - Minimization of individual periph[...]

  • Page 33

    Operating Modes 2-15 System Resets, Interrupts, and Operating Modes Figure 2−10. MSP430x1xx Operating Modes For Basic Clock System Active Mode CPU Is Active Peripheral Modules Are Active LPM0 CPU Off, MCLK Of f, SMCLK On, ACLK On CPUOFF = 1 SCG0 = 0 SCG1 = 0 CPUOFF = 1 SCG0 = 1 SCG1 = 0 LPM2 CPU Off, MCLK Of f, SMCLK Off, DCO Of f, ACLK On CPUOFF[...]

  • Page 34

    Operating Modes 2-16 System Resets, Interrupts, and Operating Modes 2.3.1 Entering and Exiting Low-Power Modes An enabled interrupt event wakes the MSP430 from any of the low-power operating modes. The program flow is: - Enter interrupt service routine: J The PC and SR are stored on the stack J The CPUOFF , SCG1, and OSCOFF bits are automatically r[...]

  • Page 35

    Principles for Low - Power Applications 2-17 System Resets, Interrupts, and Operating Modes 2.4 Principles for Low - Power Applications Often, the most important factor for reducing power consumption is using the MSP430’ s clock system to maximize the time in LPM3. LPM3 power consumption is less than 2 µ A typical with both a real-time clock fun[...]

  • Page 36

    2-18 System Resets, Interrupts, and Operating Modes[...]

  • Page 37

    3-1 RISC 16-Bit CPU   ! This chapter describes the MSP430 CPU, addressing modes, and instruction set. T opic Page 3.1 CPU Introduction 3-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 CPU Registers 3-4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .[...]

  • Page 38

    CPU Introduction 3-2 RISC 16-Bit CPU 3.1 CPU Introduction The CPU incorporates features specifically designed for modern programming techniques such as calculated branching, table processing and t h e use of high-level languages such as C. The CPU can address the complete address range without paging. The CPU features include: - RISC architecture w[...]

  • Page 39

    CPU Introduction 3-3 RISC 16-Bit CPU Figure 3−1. CPU Block Diagram 0 15 MDB − Memory Data Bus Memory Address Bus − MAB 16 Zero, Z Carry , C Overflow , V Negative, N 16−bit ALU dst src R8 General Purpose R9 General Purpose R10 General Purpose R1 1 General Purpose R12 General Purpose R13 General Purpose R14 General Purpose R15 General Purpose[...]

  • Page 40

    CPU Registers 3-4 RISC 16-Bit CPU 3.2 CPU Registers The CPU incorporates sixteen 16-bit registers. R0, R1, R2 and R3 have dedicated functions. R4 to R15 are working registers for general use. 3.2.1 Program Counter (PC) The 16-bit program counter (PC/R0) points to the next instruction to be executed. Each instruction uses an even number of bytes (tw[...]

  • Page 41

    CPU Registers 3-5 RISC 16-Bit CPU 3.2.2 Stack Pointer (SP) The stack pointer (SP/R1) is used by the CPU to store the return addresses of subroutine calls and interrupts. It uses a predecrement, postincrement scheme. In addition, the SP can be used by software with all instructions and addressing modes. Figure 3−3 shows the SP . The SP is initiali[...]

  • Page 42

    CPU Registers 3-6 RISC 16-Bit CPU 3.2.3 Status Register (SR) The status register (SR/R2), used as a source or destination register , can be used in the register mode only addressed with word instructions. The remain- ing combinations of addressing modes are used to support the constant gen- erator . Figure 3−6 shows the SR bits. Figure 3−6. Sta[...]

  • Page 43

    CPU Registers 3-7 RISC 16-Bit CPU 3.2.4 Constant Generator Registers CG1 and CG2 Six commonly-used constants are generated with the constant generator registers R2 and R3, without requiring an additional 16-bit word of program code. The constants are selected with the source-register addressing modes (As), as described in T able 3−2. T able 3−2[...]

  • Page 44

    CPU Registers 3-8 RISC 16-Bit CPU 3.2.5 General−Purpose Registers R4 - R15 The twelve registers, R4−R15, are general-purpose registers. All of these registers can be used as data registers, address pointers, or index values a nd can be accessed with byte or word instructions as shown in Figure 3−7. Figure 3−7. Register -Byte/Byte-Register O[...]

  • Page 45

    Addressing Modes 3-9 RISC 16-Bit CPU 3.3 Addressing Modes Seven addressing modes for the source operand and four addressing modes for the destination operand can address the complete address space with no exceptions. The bit numbers in T able 3−3 describe the contents of the As (source) and Ad (destination) mode bits. T able 3−3. Source/Destina[...]

  • Page 46

    Addressing Modes 3-10 RISC 16-Bit CPU 3.3.1 Register Mode The register mode is described in T able 3−4. T able 3−4. Register Mode Description Assembler Code Content of ROM MOV R10,R11 MOV R10,R11 Length: One or two words Operation: Move the content of R10 to R1 1. R10 is not af fected. Comment: V alid for source and destination Example: MOV R10[...]

  • Page 47

    Addressing Modes 3-1 1 RISC 16-Bit CPU 3.3.2 Indexed Mode The indexed mode is described in T able 3−5. T able 3−5. Indexed Mode Description Assembler Code Content of ROM MOV 2(R5),6(R6) MOV X(R5),Y(R6) X = 2 Y = 6 Length: T wo or three words Operation: Move the contents of the source address (contents of R 5 + 2 ) to the destination address (co[...]

  • Page 48

    Addressing Modes 3-12 RISC 16-Bit CPU 3.3.3 Symbolic Mode The symbolic mode is described in T able 3−6. T able 3−6. Symbolic Mode Description Assembler Code Content of ROM MOV EDE,TONI MOV X(PC),Y(PC) X = EDE − PC Y = TONI − PC Length: T wo or three words Operation: Move the contents of the source address EDE (contents of PC + X) to the des[...]

  • Page 49

    Addressing Modes 3-13 RISC 16-Bit CPU 3.3.4 Absolute Mode The absolute mode is described in T able 3−7. T able 3−7. Absolute Mode Description Assembler Code Content of ROM MOV &EDE,&TONI MOV X(0),Y(0) X = EDE Y = TONI Length: T wo or three words Operation: Move the contents of the source address EDE to the destination address TONI. The [...]

  • Page 50

    Addressing Modes 3-14 RISC 16-Bit CPU 3.3.5 Indirect Register Mode The indirect register mode is described in T able 3−8. T able 3−8. Indirect Mode Description Assembler Code Content of ROM MOV @R10,0(R11) MOV @R10,0(R11) Length: One or two words Operation: Move the contents of the source address (contents of R10) to the destination address (co[...]

  • Page 51

    Addressing Modes 3-15 RISC 16-Bit CPU 3.3.6 Indirect Autoincrement Mode The indirect autoincrement mode is described in T able 3−9. T able 3−9. Indirect Autoincrement Mode Description Assembler Code Content of ROM MOV @R10+,0(R11) MOV @R10+,0(R11) Length: One or two words Operation: Move the contents of the source address (contents of R10) to t[...]

  • Page 52

    Addressing Modes 3-16 RISC 16-Bit CPU 3.3.7 Immediate Mode The immediate mode is described in T able 3−10. T able 3−10. Immediate Mode Description Assembler Code Content of ROM MOV #45h,TONI MOV @PC+,X(PC) 45 X = TONI − PC Length: T wo or three words It is one word less if a constant of CG1 or CG2 can be used. Operation: Move the immediate co[...]

  • Page 53

    Instruction Set 3-17 RISC 16-Bit CPU 3.4 Instruction Set The complete MSP430 instruction set consists of 27 core instructions and 24 emulated instructions. The core instructions are instructions that have unique op-codes decoded by the CPU. The emulated instructions are instructions that make code easier to write and read, but do not have op-codes [...]

  • Page 54

    Instruction Set 3-18 RISC 16-Bit CPU 3.4.1 Double-Operand (Format I) Instructions Figure 3−9 illustrates the double-operand instruction format. Figure 3−9. Double Operand Instruction Format B/W D-Reg 15 0 Op-code Ad S-Reg 87 14 13 12 1 1 10 9 6 5 4 3 2 1 As T able 3−1 1 lists and describes the double operand instructions. T able 3−1 1. Doub[...]

  • Page 55

    Instruction Set 3-19 RISC 16-Bit CPU 3.4.2 Single-Operand (Format II) Instructions Figure 3−10 illustrates the single-operand instruction format. Figure 3−10. Single Operand Instruction Format B/W D/S-Reg 15 0 Op-code 87 14 13 12 1 1 10 9 6 5 4 3 2 1 Ad T able 3−12 lists and describes the single operand instructions. T able 3−12. Single Ope[...]

  • Page 56

    Instruction Set 3-20 RISC 16-Bit CPU 3.4.3 Jumps Figure 3−1 1 shows the conditional-jump instruction format. Figure 3−1 1. Jump Instruction Format C 10-Bit PC Of fset 15 0 Op-code 87 14 13 12 1 1 10 9 6 5 4 3 2 1 T able 3−13 lists and describes the jump instructions. T able 3−13. Jump Instructions Mnemonic S-Reg, D-Reg Operation JEQ/JZ Labe[...]

  • Page 57

    Instruction Set 3-21 RISC 16−Bit CPU ADC[.W] Add carry to destination ADC.B Add carry to destination Syntax ADC dst or ADC.W dst ADC.B dst Operation dst + C −> dst Emulation ADDC #0,dst ADDC.B #0,dst Description The carry bit (C) is added to the destination operand. The previous contents of the destination are lost. Status Bits N: Set if res[...]

  • Page 58

    Instruction Set 3-22 RISC 16−Bit CPU ADD[.W] Add source to destination ADD.B Add source to destination Syntax ADD src,dst or ADD.W src,dst ADD.B src,dst Operation src + dst −> dst Description The source operand is added to the destination operand. The source operand is not affected. The previous contents of the destination are lost. Status B[...]

  • Page 59

    Instruction Set 3-23 RISC 16−Bit CPU ADDC[.W] Add source and carry to destination ADDC.B Add source and carry to destination Syntax ADDC src,dst or ADDC.W src,dst ADDC.B src,dst Operation src + dst + C −> dst Description Th e source operand and the carry bit (C) are added to the destination operand. The source operand is not affected. The pr[...]

  • Page 60

    Instruction Set 3-24 RISC 16−Bit CPU AND[.W] Source AND destination AND.B Source AND destination Syntax AND src,dst or AND.W src,dst AND.B src,dst Operation src .AND. dst −> dst Description The source operand and the destination operand are logically ANDed. The result is placed into the destination. Status Bits N: Set if result MSB is set, r[...]

  • Page 61

    Instruction Set 3-25 RISC 16−Bit CPU BIC[.W] Clear bits in destination BIC.B Clear bits in destination Syntax BIC src,dst or BIC.W src,dst BIC.B src,dst Operation .NOT .src .AND. dst −> dst Description The inverted source operand and the destination operand are logically ANDed. The result is placed into the destination. The source operand is[...]

  • Page 62

    Instruction Set 3-26 RISC 16−Bit CPU BIS[.W] Set bits in destination BIS.B Set bits in destination Syntax BIS src,dst or BIS.W src,dst BIS.B src,dst Operation src .OR. dst −> dst Description The source operand and the destination operand are logically ORed. The result is placed into the destination. The source operand is not affected. Status[...]

  • Page 63

    Instruction Set 3-27 RISC 16−Bit CPU BIT[.W] T est bits in destination BIT .B T est bits in destination Syntax BIT src,dst or BIT .W src,dst Operation src .AND. dst Description The source and destination operands are logically ANDed. The result affects only the status bits. The source and destination operands are not affected. Status Bits N: Set [...]

  • Page 64

    Instruction Set 3-28 RISC 16−Bit CPU * BR, BRANCH Branch to .......... destination Syntax BR dst Operation dst −> PC Emulation MOV dst,PC Description An unconditional branch is taken to an address anywhere in the 64K address space. All source addressing modes can be used. The branch instruction is a word instruction. Status Bits Status bits [...]

  • Page 65

    Instruction Set 3-29 RISC 16−Bit CPU CALL Subroutine Syntax CALL dst Operation dst −> tmp dst is evaluated and stored SP − 2 −> SP PC −> @SP PC updated to TOS tmp −> PC dst saved to PC Description A subroutine call is made to an address anywhere in the 64K address space. All addressing modes can be used. The return address ([...]

  • Page 66

    Instruction Set 3-30 RISC 16−Bit CPU * CLR[.W] Clear destination * CLR.B Clear destination Syntax CLR dst or CLR.W dst CLR.B dst Operation 0 −> dst Emulation MOV #0,dst MOV .B #0,dst Description The destination operand is cleared. Status Bits Status bits are not af fected. Example RAM word TONI is cleared. CLR TONI ; 0 −> T ONI Example [...]

  • Page 67

    Instruction Set 3-31 RISC 16−Bit CPU * CLRC Clear carry bit Syntax CLRC Operation 0 −> C Emulation BIC #1,SR Description The carry bit (C) is cleared. The clear carry instruction is a word instruction. Status Bits N: Not af fected Z: Not affected C: Cleared V : Not affected Mode Bits OSCOFF , CPUOFF , and GIE are not affected. Example The 16[...]

  • Page 68

    Instruction Set 3-32 RISC 16−Bit CPU * CLRN Clear negative bit Syntax CLRN Operation 0 → N or (.NOT .src .AND. dst −> dst) Emulation BIC #4,SR Description The constant 04h is inverted (0FFFBh) and is logically ANDed with the destination operand. The result is placed into the destination. The clear negative bit instruction is a word instruc[...]

  • Page 69

    Instruction Set 3-33 RISC 16−Bit CPU * CLRZ Clear zero bit Syntax CLRZ Operation 0 → Z or (.NOT .src .AND. dst −> dst) Emulation BIC #2,SR Description The constant 02h is inverted (0FFFDh) and logically ANDed with the destination operand. The result is placed into the destination. The clear zero bit instruction is a word instruction. Statu[...]

  • Page 70

    Instruction Set 3-34 RISC 16−Bit CPU CMP[.W] Compare source and destination CMP .B Compare source and destination Syntax CMP src,dst or CMP .W src,dst CMP .B src,dst Operation dst + .NOT .src + 1 or (dst − src) Description The source operand is subtracted from the destination operand. This is accomplished by adding the 1s complement of the sour[...]

  • Page 71

    Instruction Set 3-35 RISC 16−Bit CPU * DADC[.W] Add carry decimally to destination * DADC.B Add carry decimally to destination Syntax DADC dst or DADC.W src,dst DADC.B dst Operation dst + C −> dst (decimally) Emulation DADD #0,dst DADD.B #0,dst Description The carry bit (C) is added decimally to the destination. Status Bits N: Set if MSB is [...]

  • Page 72

    Instruction Set 3-36 RISC 16−Bit CPU DADD[.W] Source and carry added decimally to destination DADD.B Source and carry added decimally to destination Syntax DADD src,dst or DADD.W src,dst DADD.B src,dst Operation src + dst + C −> dst (decimally) Description The source operand and the destination operand are treated as four binary coded decima[...]

  • Page 73

    Instruction Set 3-37 RISC 16−Bit CPU * DEC[.W] Decrement destination * DEC.B Decrement destination Syntax DEC dst or DEC.W dst DEC.B dst Operation dst − 1 −> dst Emulation SUB #1,dst Emulation SUB.B #1,dst Description The destination operand is decremented by one. The original contents are lost. Status Bits N: Set if result is negative, re[...]

  • Page 74

    Instruction Set 3-38 RISC 16−Bit CPU * DECD[.W] Double-decrement destination * DECD.B Double-decrement destination Syntax DECD dst or DECD.W dst DECD.B dst Operation dst − 2 −> dst Emulation SUB #2,dst Emulation SUB.B #2,dst Description Th e destination operand is decremented by two. The original contents are lost. Status Bits N: Set if re[...]

  • Page 75

    Instruction Set 3-39 RISC 16−Bit CPU * DINT Disable (general) interrupts Syntax DINT Operation 0 → GIE or (0FFF7h .AND. SR → SR / .NOT .src .AND. dst −> dst) Emulation BIC #8,SR Description All interrupts are disabled. Th e constant 08h is inverted and logically ANDed with the status register (SR). The result is placed into the SR. Statu[...]

  • Page 76

    Instruction Set 3-40 RISC 16−Bit CPU * EINT Enable (general) interrupts Syntax EINT Operation 1 → GIE or (0008h .OR. SR −> SR / .src .OR. dst −> dst) Emulation BIS #8,SR Description All interrupts are enabled. The constant #08h and the status register SR are logically ORed. The result is placed into the SR. Status Bits Status bits are[...]

  • Page 77

    Instruction Set 3-41 RISC 16−Bit CPU * INC[.W ] Increment destination * INC.B Increment destination Syntax INC dst or INC.W dst INC.B dst Operation dst + 1 −> dst Emulation ADD #1,dst Description Th e destination operand is incremented by one. The original contents are lost. Status Bits N: Set if result is negative, reset if positive Z: Set [...]

  • Page 78

    Instruction Set 3-42 RISC 16−Bit CPU * INCD[.W] Double-increment destination * INCD.B Double-increment destination Syntax INCD dst or INCD.W dst INCD.B dst Operation dst + 2 −> dst Emulation ADD #2,dst Emulation ADD.B #2,dst Example The destination operand is incremented by two. The original contents are lost. Status Bits N: Set if result is[...]

  • Page 79

    Instruction Set 3-43 RISC 16−Bit CPU * INV[.W] Invert destination * INV .B Invert destination Syntax INV dst INV .B dst Operation .NOT .dst −> dst Emulation XOR #0FFFFh,dst Emulation XOR.B #0FFh,dst Description The destination operand is inverted. The original contents are lost. Status Bits N: Set if result is negative, reset if positive Z: [...]

  • Page 80

    Instruction Set 3-44 RISC 16−Bit CPU JC Jump if carry set JHS Jump if higher or same Syntax JC label JHS label Operation If C = 1: PC + 2 × offset −> PC If C = 0: execute following instruction Description The status register carry bit (C) is tested. If it is set, the 10-bit signed offset contained in the instruction LSBs is added to the pro[...]

  • Page 81

    Instruction Set 3-45 RISC 16−Bit CPU JEQ, JZ Jump if equal, jump if zero Syntax JEQ label, JZ label Operation If Z = 1: PC + 2 × offset −> PC If Z = 0: execute following instruction Description The status register zero bit (Z) is tested. If it is set, the 10-bit signed offset contained in the instruction LSBs is added to the program counter[...]

  • Page 82

    Instruction Set 3-46 RISC 16−Bit CPU JGE Jump if greater or equal Syntax JGE label Operation If (N .XOR. V) = 0 then jump to label: PC + 2 × offset −> PC If (N .XOR. V) = 1 then execute the following instruction Description The status register negative bit (N) and overflow bit (V) are tested. If both N a nd V are set or reset, the 10-bit si[...]

  • Page 83

    Instruction Set 3-47 RISC 16−Bit CPU JL Jump if less Syntax JL label Operation If (N .XOR. V) = 1 then jump to label: PC + 2 × offset −> PC If (N .XOR. V) = 0 then execute following instruction Description The status register negative bit (N) and overflow bit (V) are tested. If only one is set, the 10-bit signed of fset contained in the ins[...]

  • Page 84

    Instruction Set 3-48 RISC 16−Bit CPU JMP Jump unconditionally Syntax JMP label Operation PC + 2 × offset −> PC Description The 10-bit signed offset contained in the instruction LSBs is added to the program counter . Status Bits Status bits are not af fected. Hint : This one-word instruction replaces the BRANCH instruction in the range of ?[...]

  • Page 85

    Instruction Set 3-49 RISC 16−Bit CPU JN Jump if negative Syntax JN label Operation if N = 1: PC + 2 × offset −> PC if N = 0: execute following instruction Description Th e negative bit (N) of the status register is tested. If it is set, the 10-bit signed offset contained in the instruction LSBs is added to the program counter . If N is rese[...]

  • Page 86

    Instruction Set 3-50 RISC 16−Bit CPU JNC Jump if carry not set JLO Jump if lower Syntax JNC label JLO label Operation if C = 0: PC + 2 × offset −> PC if C = 1: execute following instruction Description The status register carry bit (C) is tested. If it is reset, the 10-bit signed offset contained in the instruction LSBs is added to the prog[...]

  • Page 87

    Instruction Set 3-51 RISC 16−Bit CPU JNE Jump if not equal JNZ Jump if not zero Syntax JNE label JNZ label Operation If Z = 0: PC + 2 × offset −> PC If Z = 1: execute following instruction Description The status register zero bit (Z) is tested. If it is reset, the 10-bit signed offset contained in the instruction LSBs is added to the progra[...]

  • Page 88

    Instruction Set 3-52 RISC 16−Bit CPU MOV[.W] Move source to destination MOV .B Move source to destination Syntax MOV src,dst or MOV .W src,dst MOV .B src,dst Operation src −> dst Description The source operand is moved to the destination. The source operand is not affected. The previous contents of the destination are lost. Status Bits Statu[...]

  • Page 89

    Instruction Set 3-53 RISC 16−Bit CPU * NOP No operation Syntax NOP Operation None Emulation MOV #0, R3 Description No operation is performed. The instruction may be used for the elimination of instructions during the software check or for defined waiting times. Status Bits Status bits are not af fected. The NOP instruction is mainly used for two [...]

  • Page 90

    Instruction Set 3-54 RISC 16−Bit CPU * POP[.W] Pop word from stack to destination * POP .B Pop byte from stack to destination Syntax POP dst POP .B dst Operation @SP −> temp SP + 2 −> SP temp −> dst Emulation MOV @SP+,dst or MOV .W @SP+,dst Emulation MOV .B @SP+,dst Description The stack location pointed to by the stack pointer (TO[...]

  • Page 91

    Instruction Set 3-55 RISC 16−Bit CPU PUSH[.W] Push word onto stack PUSH.B Push byte onto stack Syntax PUSH src or PUSH.W src PUSH.B src Operation SP − 2 → SP src → @SP Description The stack pointer is decremented by two, then the source operand is moved to the RAM word addressed by the stack pointer (TOS). Status Bits Status bits are not af[...]

  • Page 92

    Instruction Set 3-56 RISC 16−Bit CPU * RET Return from subroutine Syntax RET Operation @SP → PC SP + 2 → SP Emulation MOV @SP+,PC Description The return address pushed onto the stack by a CALL instruction is moved to th e program counter . The program continues at the code address following the subroutine call. Status Bits Status bits are not[...]

  • Page 93

    Instruction Set 3-57 RISC 16−Bit CPU RETI Return from interrupt Syntax RETI Operation TOS → SR SP + 2 → SP TOS → PC SP + 2 → SP Description The status register is restored to the value at the beginning of the interrupt service routine by replacing the present SR contents with the TOS contents. The stack pointer (SP) is incremented by two.[...]

  • Page 94

    Instruction Set 3-58 RISC 16−Bit CPU * RLA[.W] Rotate left arithmetically * RLA.B Rotate left arithmetically Syntax RLA dst or RLA.W dst RLA.B dst Operation C <− MSB <− MSB−1 .... LSB+1 <− LSB <− 0 Emulation ADD dst,dst ADD.B dst,dst Description The destination operand is shifted left one position as shown in Figure 3−14. [...]

  • Page 95

    Instruction Set 3-59 RISC 16−Bit CPU * RLC[.W] Rotate left through carry * RLC.B Rotate left through carry Syntax RLC dst or RLC.W dst RLC.B dst Operation C <− MSB <− MSB−1 .... LSB+1 <− LSB <− C Emulation ADDC dst,dst Description The destination operand is shifted left one position as shown in Figure 3−15. The carry bit ([...]

  • Page 96

    Instruction Set 3-60 RISC 16−Bit CPU RRA[.W] Rotate right arithmetically RRA.B Rotate right arithmetically Syntax RRA dst or RRA.W dst RRA.B dst Operation MSB −> MSB, MSB −> MSB−1, ... LSB+1 −> LSB, LSB −> C Description The destination operand is shifted right one positi on as shown in Figure 3−16. The MSB is shifted into [...]

  • Page 97

    Instruction Set 3-61 RISC 16−Bit CPU RRC[.W] Rotate right through carry RRC.B Rotate right through carry Syntax RRC dst or RRC.W dst RRC dst Operation C −> MSB −> MSB−1 .... LSB+1 −> LSB −> C Description The destination operand is shifted right one position as shown in Figure 3−17. Th e carry bit (C) is shifted into the MS[...]

  • Page 98

    Instruction Set 3-62 RISC 16−Bit CPU * SBC[.W] Subtract source and borrow/.NOT . carry from destination * SBC.B Subtract source and borrow/.NOT . carry from destination Syntax SBC dst or SBC.W dst SBC.B dst Operation dst + 0FFFFh + C −> dst dst + 0FFh + C −> dst Emulation SUBC #0,dst SUBC.B #0,dst Description Th e carry bit (C) is added[...]

  • Page 99

    Instruction Set 3-63 RISC 16−Bit CPU * SETC Set carry bit Syntax SETC Operation 1 −> C Emulation BIS #1,SR Description The carry bit (C) is set. Status Bits N: Not affected Z: Not affected C: Set V : Not affected Mode Bits OSCOFF , CPUOFF , and GIE are not affected. Example Emulation of the decimal subtraction: Subtract R5 from R6 decimally [...]

  • Page 100

    Instruction Set 3-64 RISC 16−Bit CPU * SETN Set negative bit Syntax SETN Operation 1 −> N Emulation BIS #4,SR Description The negative bit (N) is set. Status Bits N: Set Z: Not affected C: Not affected V: Not affected Mode Bits OSCOFF , CPUOFF , and GIE are not affected.[...]

  • Page 101

    Instruction Set 3-65 RISC 16−Bit CPU * SETZ Set zero bit Syntax SETZ Operation 1 −> Z Emulation BIS #2,SR Description The zero bit (Z) is set. Status Bits N: Not af fected Z: Set C: Not af fected V : Not affected Mode Bits OSCOFF , CPUOFF , and GIE are not affected.[...]

  • Page 102

    Instruction Set 3-66 RISC 16−Bit CPU SUB[.W] Subtract source from destination SUB.B Subtract source from destination Syntax SUB src,dst or SUB.W src,dst SUB.B src,dst Operation dst + .NOT .src + 1 −> dst or [(dst − src −> dst)] Description The source operand is subtracted from the destination operand by adding the source operand’s 1[...]

  • Page 103

    Instruction Set 3-67 RISC 16−Bit CPU SUBC[.W]SBB[.W] Subtract source and borrow/.NOT . carry from destination SUBC.B,SBB.B Subtract source and borrow/.NOT . carry from destination Syntax SUBC src,dst or SUBC.W src,dst or SBB src,dst or SBB.W src,dst SUBC.B src,dst or SBB.B src,dst Operation dst + .NOT .src + C −> dst or (dst − src − 1 + [...]

  • Page 104

    Instruction Set 3-68 RISC 16−Bit CPU SWPB Swap bytes Syntax SWPB dst Operation Bits 15 to 8 <−> bits 7 to 0 Description The destination operand high and low bytes are exchanged as shown in Figure 3−18. Status Bits Status bits are not af fected. Mode Bits OSCOFF , CPUOFF , and GIE are not affected. Figure 3−18. Destination Operand Byte[...]

  • Page 105

    Instruction Set 3-69 RISC 16−Bit CPU SXT Extend Sign Syntax SXT dst Operation Bit 7 −> Bit 8 ......... Bit 15 Description Th e sign of the low byte is extended into the high byte as shown in Figure 3−19. Status Bits N: Set if result is negative, reset if positive Z: Set if result is zero, reset otherwise C: Set if result is not zero, reset[...]

  • Page 106

    Instruction Set 3-70 RISC 16−Bit CPU * TST[.W] T est destination * TST .B T est destination Syntax TST dst or TST .W dst TST .B dst Operation dst + 0FFFFh + 1 dst + 0FFh + 1 Emulation CMP #0,dst CMP .B #0,dst Description Th e destination operand is compared with zero. The status bits are set accord- ing to the result. The destination is not affec[...]

  • Page 107

    Instruction Set 3-71 RISC 16−Bit CPU XOR[.W] Exclusive OR of source with destination XOR.B Exclusive OR of source with destination Syntax XOR src,dst or XOR.W src,dst XOR.B src,dst Operation src .XOR. dst −> dst Description Th e source and destination operands are exclusive ORed. The result is placed into the destination. The source operand [...]

  • Page 108

    Instruction Set 3-72 RISC 16−Bit CPU 3.4.4 Instruction Cycles and Lengths The number of CPU clock cycles required for an instruction depends on the instruction format and the addressing modes used - not the instruction itself. The number of clock cycles refers to the MCLK. Interrupt and Reset Cycles T able 3−14 lists the CPU cycles for interrup[...]

  • Page 109

    Instruction Set 3-73 RISC 16−Bit CPU Format-I (Double Operand) Instruction Cycles and Lengths T able 3−16 lists the length and CPU cycles for all addressing modes of format-I instructions. T able 3−16. Format 1 Instruction Cycles and Lengths Addressing Mode No. of Cycles Length of Instruction Src Dst No. of Cycles Length of Instruction Exampl[...]

  • Page 110

    Instruction Set 3-74 RISC 16−Bit CPU 3.4.5 Instruction Set Description The instruction map is shown in Figure 3−20 and the complete instruction set is summarized in T able 3−17. Figure 3−20. Core Instruction Map 0xxx 4xxx 8xxx Cxxx 1xxx 14xx 18xx 1Cxx 20xx 24xx 28xx 2Cxx 30xx 34xx 38xx 3Cxx 4xxx 5xxx 6xxx 7xxx 8xxx 9xxx Axxx Bxxx Cxxx Dxxx [...]

  • Page 111

    Instruction Set 3-75 RISC 16−Bit CPU T able 3−17. MSP430 Instruction Set Mnemonic Description V N Z C ADC(.B) † dst Add C to destination dst + C → dst * * * * ADD(.B) src,dst Add source to destination src + dst → dst * * * * ADDC(.B) src,dst Add source and C to destination src + dst + C → dst * * * * AND(.B) src,dst AND source and desti[...]

  • Page 112

    3-76[...]

  • Page 113

    4-1 Basic Clock Module  "# " The basic clock module provides the clocks for MSP430x1xx devices. This chapter describes the operation of the basic clock module. The basic clock module is implemented in all MSP430x1xx devices. T opic Page 4.1 Basic Clock Module Introduction 4−2 . . . . . . . . . . . [...]

  • Page 114

    Basic Clock Module Introduction 4-2 Basic Clock Module 4.1 Basic Clock Module Introduction The basic clock module supports low system cost and ultralow-power consumption. Using three internal clock signals, the user can select the best balance of performance and low power consumption. The basic clock module can be configured to operate without any [...]

  • Page 115

    Basic Clock Module Introduction 4-3 Basic Clock Module Figure 4−1. Basic Clock Block Diagram Divider /1/2/4/8 DIV Ax MCLK CPUOFF DCOCLK XIN XOUT DCOR P2.5/Rosc LFXT1 Oscillator XT2IN XT2OUT XT2OFF XT2 Oscillator Divider /1/2/4/8 DIVMx SMCLK SCG1 DIVSx ACLK VCC Main System Clock Auxillary Clock Sub System Clock DCO DCOx MODx DC Generator SCG0 RSEL[...]

  • Page 116

    Basic Clock Module Operation 4-4 Basic Clock Module 4.2 Basic Clock Module Operation After a PUC, MCLK and SMCLK are sourced from DCOCLK at ~800 kHz (see device-specific datasheet for parameters) and ACLK is sourced from LFXT1 in LF mode. Status register control bits SCG0, SCG1, OSCOFF , and CPUOFF configure th e MSP430 operating modes and enable o[...]

  • Page 117

    Basic Clock Module Operation 4-5 Basic Clock Module 4.2.2 LFXT1 Oscillator The LFXT1 oscillator supports ultralow-current consumption using a 32,768-Hz watch crystal in LF mode (XTS = 0). A watch crystal connects to XIN and XOUT without any other external components. Internal 12-pF load capacitors are provided for LFXT1 in LF mode. The capacitors a[...]

  • Page 118

    Basic Clock Module Operation 4-6 Basic Clock Module 4.2.3 XT2 Oscillator Some devices have a second crystal oscillator , XT2. XT2 sources XT2CLK and its characteristics are identical to LFXT1 in HF mode. The XT2OFF bit disables the XT2 oscillator if XT2CLK is not used for MCLK or SMCLK as shown in Figure 4−3. XT 2 may be used with external clock [...]

  • Page 119

    Basic Clock Module Operation 4-7 Basic Clock Module Adjusting the DCO frequency After a PUC, the internal resistor is selected for the DC generator , RSELx = 4, and DCOx = 3, allowing the DCO to start at a mid-range frequency . MCLK and SMCLK are sourced from DCOCLK. Because the CPU executes code from MCLK, which is sourced from the fast-starting D[...]

  • Page 120

    Basic Clock Module Operation 4-8 Basic Clock Module Using an External Resistor (R OSC ) for the DCO Th e DCO temperature coefficient can be reduced by using an external resistor R OSC tied to DV CC to source the current for the DC generator . Figure 4−6 shows the typical relationship of f DCO vs. temperature for both the internal an d external re[...]

  • Page 121

    Basic Clock Module Operation 4-9 Basic Clock Module 4.2.5 DCO Modulator The modulator mixes two DCO frequencies, f DCO and f DCO+1 to produce an intermediate effective frequency between f DCO and f DCO+1 and spread the clock energy , reducing electromagnetic interference (EMI) . The modulator mixes f DCO and f DCO+1 for 32 DCOCLK clock cycles and i[...]

  • Page 122

    Basic Clock Module Operation 4-10 Basic Clock Module 4.2.6 Basic Clock Module Fail-Safe Operation The basic clock module incorporates an oscillator-fault detection fail-safe feature. The oscillator fault detector is an analog circuit that monitors the LFXT1CLK (in HF mode) and the XT2CLK. An oscillator fault is detected when either clock signal is [...]

  • Page 123

    Basic Clock Module Operation 4-1 1 Basic Clock Module Oscillator Fault Detection Signal XT_OscFault triggers the OFIFG flag as shown in Figure 4−10. The LFXT1_OscFault signal is low when LFXT1 is in LF mode. On devices without XT2, the OFIFG flag cannot be cleared when LFXT1 is in LF mode. MCLK may be sourced by LFXT1CLK in LF mode by setting the[...]

  • Page 124

    Basic Clock Module Operation 4-12 Basic Clock Module Sourcing MCLK from a Crystal After a PUC, the basic clock module uses DCOCLK for MCLK. If required, MCLK may be sourced from LFXT1 or XT2. The sequence to switch the MCLK source from the DCO clock to the crystal clock (LFXT1CLK or XT2CLK) is: 1) Switch on the crystal oscillator 2) Clear the OFIFG[...]

  • Page 125

    Basic Clock Module Operation 4-13 Basic Clock Module 4.2.7 Synchronization of Clock Signals When switching MCLK or SMCLK from one clock source to the another , the switch is synchronized to avoid critical race conditions as shown in Figure 4−1 1: 1) The current clock cycle continues until the next rising edge. 2) The clock remains high until the [...]

  • Page 126

    Basic Clock Module Registers 4-14 Basic Clock Module 4.3 Basic Clock Module Registers The basic clock module registers are listed in T able 4−1: T able 4−1. Basic Clock Module Registers Register Short Form Register T ype Address Initial State DCO control register DCOCTL Read/write 056 h 060 h with PUC Basic clock system control 1 BCSCTL1 Read/w[...]

  • Page 127

    Basic Clock Module Registers 4-15 Basic Clock Module DCOCTL, DCO Control Register 76543 210 DCOx MODx rw−0 rw−1 rw−1 rw−0 rw−0 rw−0 rw−0 rw−0 DCOx Bits 7-5 DCO frequency select. These bits select which of the eight discrete DCO frequencies of the RSELx setting is selected. MODx Bits 4-0 Modulator selection. These bits define how oft[...]

  • Page 128

    Basic Clock Module Registers 4-16 Basic Clock Module BCSCTL2, Basic Clock System Control Register 2 76543 210 SELMx DIVMx SELS DIVSx DCOR rw−(0) rw−(0) rw−(0) rw−(0) rw−0 rw−0 rw−0 rw−0 SELMx Bits 7-6 Select MCLK. These bits select the MCLK source. 00 DCOCLK 01 DCOCLK 10 XT2CLK when XT2 oscillator present on-chip. LFXT1CLK when XT2 [...]

  • Page 129

    Basic Clock Module Registers 4-17 Basic Clock Module IE1, Interrupt Enable Register 1 76543 210 OFIE rw−0 Bits 7-2 These bits may be used by other modules. See device-specific datasheet. OFIE Bit 1 Oscillator fault interrupt enable. This bit enables the OFIFG interrupt. Because other bits in IE1 may be used for other modules, it is recommended to[...]

  • Page 130

    4-18 Basic Clock Module[...]

  • Page 131

    5-1 Flash Memory Controller "  "" This chapter describes the operation of the MSP430 flash memory controller . T opic Page 5.1 Flash Memory Introduction 5-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 Flash Memory Segmentation 5-3 . . . . . . . . . [...]

  • Page 132

    Flash Memory Introduction 5-2 Flash Memory Controller 5.1 Flash Memory Introduction The MSP430 flash memory is bit-, byte-, and word-addressable and programmable. The flash memory module has an integrated controller that controls programming and erase operations. The controller has three registers, a timing generator , and a voltage generator to su[...]

  • Page 133

    Flash Memory Segmentation 5-3 Flash Memory Controller 5.2 Flash Memory Segmentation MSP430 flash memory is partitioned into segments. Single bits, bytes, or words can be written to flash memory , but the segment is the smallest size of flash memory that can be erased. The flash memory is partitioned into main and information memory sections. There [...]

  • Page 134

    Flash Memory Operation 5-4 Flash Memory Controller 5.3 Flash Memory Operation The default mode of the flash memory is read mode. In read mode, the flash memory is not being erased or written, the flash timing generator and voltage generator are off, and the memory operates identically to ROM. MSP430 flash memory is in-system programmable (ISP) with[...]

  • Page 135

    Flash Memory Operation 5-5 Flash Memory Controller 5.3.2 Erasing Flash Memory Th e erased level of a flash memory bit is 1. Each bit can be programmed from 1 to 0 individually but to reprogram from 0 to 1 requires an erase cycle. The smallest amount of flash that can be erased is a segment. There are three erase modes selected with the ERASE and ME[...]

  • Page 136

    Flash Memory Operation 5-6 Flash Memory Controller Initiating an Erase from Within Flash Memory An y erase cycle can be initiated from within flash memory or from RAM. When a flash segment erase operation is initiated from within flash memory , all timing is controlled by the flash controller , and the CPU is held while the erase cycle completes. A[...]

  • Page 137

    Flash Memory Operation 5-7 Flash Memory Controller Initiating an Erase from RAM Any erase cycle may be initiated from RAM. In this case, the CPU is not held and can continue to execute code from RAM. The BUSY bit must be polled to determine the end of the erase cycle before the CPU can access any flash address again. If a flash access occurs while [...]

  • Page 138

    Flash Memory Operation 5-8 Flash Memory Controller 5.3.3 Writing Flash Memory The write modes, selected by the WRT and BLKWR T bits, are listed in T able 5−1. T able 5−2. Write Modes BLKWRT WRT Write Mode 0 1 Byte/word write 1 1 Block write Both write modes use a sequence of individual write instructions, but using the block write mode is appro[...]

  • Page 139

    Flash Memory Operation 5-9 Flash Memory Controller In byte/word mode, the internally-generated programming voltage is applied to the complete 64-byte block, each time a byte or word is written, for 32 of the 35 f FTG cycles. With each byte or word write, the amount of time the block is subjected to the programming voltage accumulates. The cumulativ[...]

  • Page 140

    Flash Memory Operation 5-10 Flash Memory Controller Initiating a Byte/Word Write from RAM The flow to initiate a byte/word write from RAM is shown in Figure 5−9. Figure 5−9. Initiating a Byte/Word Write from RAM yes BUSY = 1 yes BUSY = 1 Disable all interrupts and watchdog Setup flash controller and set WRT=1 Write byte or word Set WRT=0, LOCK [...]

  • Page 141

    Flash Memory Operation 5-1 1 Flash Memory Controller Block Write The block write can be used to accelerate the flash write process when many sequential bytes or words need to be programmed. The flash programming voltage remains on for the duration of writing the 64-byte block. The cumulative programming time t CPT must not be exceeded for any block[...]

  • Page 142

    Flash Memory Operation 5-12 Flash Memory Controller Block Write Flow and Example A block write flow is shown in Figure 5−8 and the following example. Figure 5−1 1. Block Write Flow yes BUSY = 1 Disable all interrupts and watchdog Setup flash controller Set BLKWRT=WR T=1 Write byte or word no Block Border? yes W AIT=0? yes BUSY = 1 Set BLKWRT=0 [...]

  • Page 143

    Flash Memory Operation 5-13 Flash Memory Controller ; Write one block starting at 0F000h. ; Must be executed from RAM, Assumes Flash is already erased. ; 514 kHz < SMCLK < 952 kHz ; Assumes ACCVIE = NMIIE = OFIE = 0. MOV #32,R5 ; Use as write counter MOV #0F000h,R6 ; Write pointer MOV #WDTPW+WDTHOLD,&WDTCTL ; Disable WDT DINT ; Disable in[...]

  • Page 144

    Flash Memory Operation 5-14 Flash Memory Controller 5.3.4 Flash Memory Access During Write or Erase When any write or any erase operation is initiated from RAM and while BUSY=1, the CPU may not read or write to or from any flash location. Otherwise, an access violation occurs, ACCVIFG is set, and the result is unpredictable. Also if a write to flas[...]

  • Page 145

    Flash Memory Operation 5-15 Flash Memory Controller 5.3.5 Stopping a Write or Erase Cycle Any write or erase operation can be stopped before its normal completion by setting the emergency exit bit EMEX. Setting the EMEX bit stops the active operation immediately and stops the flash controller . All flash operations cease, the flash returns to read [...]

  • Page 146

    Flash Memory Operation 5-16 Flash Memory Controller Programming Flash Memory via JT AG MSP430 devices can be programmed via the JT AG port. The JT AG interface requires four signals (5 signals on 20- and 28-pin devices), ground and optionally V CC and RST /NMI. The JT AG port is protected with a fuse. Blowing the fuse completely disables the JT AG [...]

  • Page 147

    Flash Memory Registers 5-17 Flash Memory Controller 5.4 Flash Memory Registers The flash memory registers are listed in T able 5−4. T able 5−4. Flash Memory Registers Register Short Form Register T ype Address Initial State Flash memory control register 1 FCTL1 Read/write 0128h 09600h with PUC Flash memory control register 2 FCTL2 Read/write 01[...]

  • Page 148

    Flash Memory Registers 5-18 Flash Memory Controller FCTL1, Flash Memory Control Register 15 14 13 12 1 1 10 9 8 FRKEY , Read as 096h FWKEY , Must be written as 0A5h 76543 210 BLKWRT WRT Reserved Reserved Reserved MERAS ERASE Reserved rw−0 rw−0 r0 r0 r0 rw−0 rw−0 r0 FRKEY/ FWKEY Bits 15-8 FCTLx password. Always read as 096h. Must be written [...]

  • Page 149

    Flash Memory Registers 5-19 Flash Memory Controller FCTL2, Flash Memory Control Register 15 14 13 12 1 1 10 9 8 FWKEYx, Read as 096h Must be written as 0A5h 76543 210 FSSELx FNx rw−0 rw−1 rw-0 rw-0 rw-0 rw−0 rw-1 rw−0 FWKEYx Bits 15-8 FCTLx password. Always read as 096h. Must be written as 0A5h or a PUC will be generated. FSSELx Bits 7−6 [...]

  • Page 150

    Flash Memory Registers 5-20 Flash Memory Controller FCTL3, Flash Memory Control Register FCTL3 15 14 13 12 1 1 10 9 8 FWKEYx, Read as 096h Must be written as 0A5h 76543 210 Reserved Reserved EMEX LOCK W AIT ACCVIFG KEYV BUSY r0 r0 rw-0 rw-1 r-1 rw−0 rw-(0) r(w)−0 FWKEYx Bits 15-8 FCTLx password. Always read as 096h. Must be written as 0A5h or a[...]

  • Page 151

    Flash Memory Registers 5-21 Flash Memory Controller IE1, Interrupt Enable Register 1 76543 210 ACCVIE rw−0 Bits 7-6, 4-0 These bits may be used by other modules. See device-specific datasheet. ACCVIE Bit 5 Flash memory access violation interrupt enable. This bit enables the ACCVIFG interrupt. Because other bits in IE1 may be used for other module[...]

  • Page 152

    5-22 Flash Memory Controller[...]

  • Page 153

    6-1 Supply V oltage Supervisor " $ " % This chapter describes the operation of the SVS. The SVS is implemented in MSP430x15x and MSP430x16x devices. T opic Page 6.1 SVS Introduction 6−2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2[...]

  • Page 154

    SVS Introduction 6-2 Supply V oltage Supervisor 6.1 SVS Introduction The supply voltage supervisor (SVS) is used to monitor the A V CC supply voltage or an external voltage. The SVS can be configured to set a flag or generate a POR reset when the supply voltage or external voltage drops below a user-selected threshold. The SVS features include: - A[...]

  • Page 155

    SVS Introduction 6-3 Supply V oltage Supervisor Figure 6−1. SVS Block Diagram + − 1.25V Brownout Reset VCC Set SVSFG t Reset ~ 50us Reset SVSCTL Bits 0001 0010 001 1 1111 1 101 1 100 G D S SVSOUT G D S VLD SVSON PORON SVSOP SVSFG ~ 50us SVS_POR SVSIN AV CC AV CC[...]

  • Page 156

    SVS Operation 6-4 Supply V oltage Supervisor 6.2 SVS Operation Th e SVS detects if the A V CC voltage drops below a selectable level. It can be configured t o provide a POR or set a flag, when a low-voltage condition occurs. The SVS is disabled after a brownout reset to conserve current consumption. 6.2.1 Configuring the SVS The VLDx bits are used [...]

  • Page 157

    SVS Operation 6-5 Supply V oltage Supervisor 6.2.3 Changing the VLDx Bits When the VLDx bits are changed, two settling delays are implemented to allows the SVS circuitry to settle. During each delay , the SVS will not set SVSFG. The delays, t d(SVSon) and t settle, are shown in Figure 6−2. The t d(SVSon) delay takes affect when VLDx is changed fr[...]

  • Page 158

    SVS Operation 6-6 Supply V oltage Supervisor 6.2.4 SVS Operating Range Each SVS level has hysteresis to reduce sensitivity to small supply voltage changes when A V CC is close to the threshold. The SVS operation and SVS/Brownout interoperation are shown in Figure 6−3 . Figure 6−3. Operating Levels for SVS and Brownout/Reset Circuit V CC(start) [...]

  • Page 159

    SVS Registers 6-7 Supply V oltage Supervisor 6.3 SVS Registers The SVS registers are listed in T able 6−1. T able 6−1. SVS Registers Register Short Form Register T ype Address Initial State SVS Control Register SVSCTL Read/write 055h Reset with BOR SVSCTL, SVS Control Register 76543 210 VLDx PORON SVSON SVSOP SVSFG rw−0 † rw−0 † rw−0 [...]

  • Page 160

    6-8 Supply V oltage Supervisor[...]

  • Page 161

    7-1 Hardware Multiplier &'"" This chapter describes the hardware multiplier . The hardware multiplier is implemented in MSP430x14x and MSP430x16x devices. T opic Page 7.1 Hardware Multiplier Introduction 7-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Hardware Mul[...]

  • Page 162

    Hardware Multiplier Introduction 7-2 Hardware Multiplier 7.1 Hardware Multiplier Introduction The hardware multiplier is a peripheral and is not part of the MSP430 CPU. This means, its activities do not interfere with the CPU activities. The multiplier registers are peripheral registers that are loaded and read with CPU instructions. The hardware m[...]

  • Page 163

    Hardware Multiplier Operation 7-3 Hardware Multiplier 7.2 Hardware Multiplier Operation The hardware multiplier supports unsigned multiply , signed multiply , unsigned multiply accumulate, and signed multiply accumulate operations. The type of operation is selected by the address the first operand is written to. The hardware multiplier has two 16-b[...]

  • Page 164

    Hardware Multiplier Operation 7-4 Hardware Multiplier 7.2.2 Result Registers Th e result low register RESLO holds the lower 16-bits of the calculation result. The result high register RESHI contents depend on the multiply operation and are listed in T able 7−2. T able 7−2. RESHI Contents Mode RESHI Contents MPY Upper 16-bits of the result MPYS [...]

  • Page 165

    Hardware Multiplier Operation 7-5 Hardware Multiplier 7.2.3 Software Examples Examples for all multiplier modes follow . All 8x8 modes use the absolute address for the registers because the assembler will not allow .B access to word registers when using the labels from the standard definitions file. ; 16x16 Unsigned Multiply MOV #01234h,&MPY ; [...]

  • Page 166

    Hardware Multiplier Operation 7-6 Hardware Multiplier 7.2.4 Indirect Addressing of RESLO When using indirect or indirect autoincrement addressing mode to access the result registers, At least one instruction is needed between loading the second operand and accessing one of the result registers: ; Access multiplier results with indirect addressing M[...]

  • Page 167

    Hardware Multiplier Registers 7-7 Hardware Multiplier 7.3 Hardware Multiplier Registers The hardware multiplier registers are listed in T able 7−4. T able 7−4. Hardware Multiplier Registers Register Short Form Register T ype Address Initial State Operand one - multiply MPY Read/write 0130h Unchanged Operand one - signed multiply MPYS Read/write[...]

  • Page 168

    7-8 Hardware Multiplier[...]

  • Page 169

    8-1 () "" The DMA controller module transfers data from one address to another without CPU intervention. This chapter describes the operation of the DMA controller. The DMA controller is implemented in MSP430x15x and MSP430x16x devices. T opic Page 8.1 DMA Introduction 8-2 . . . . . . . . . . . . . . . . . . . .[...]

  • Page 170

    8-2 8.1 DMA Introduction The direct memory access (DMA) controller transfers data from one address to another , without CPU intervention, across the entire address range. For example, the DMA controller can move data from the ADC12 conversion memory to RAM. Using the DMA controller can increase the throughput of peripheral modules. It can also redu[...]

  • Page 171

    8-3 Figure 8−1. DMA Controller Block Diagram DMA Priority And Control ENNMI DT DMA Channel 2 DMASRSBYTE DMA2SZ DMA2DA DMA2SA DMADSTBYTE DMASRCINCRx DMADSTINCRx 2 2 3 DMADTx DMAEN DT DMA Channel 1 DMASRSBYTE DMA1SZ DMA1DA DMA1SA DMADSTBYTE DMASRCINCRx DMADSTINCRx 2 2 3 DMADTx DMAEN DT DMA Channel 0 DMASRSBYTE DMA0SZ DMA0DA DMA0SA DMADSTBYTE DMASRC[...]

  • Page 172

    8-4 8.2 DMA Operation The DMA controller is configured with user software. The setup and operation of the DMA is discussed in the following sections. 8.2.1 DMA Addressing Modes The DMA controller has four addressing modes. The addressing mode for each DMA channel is independently configurable. For example, channel 0 ma y transfer between two fixed [...]

  • Page 173

    8-5 8.2.2 DMA T ransfer Modes The DMA controller has six transfer modes selected by the DMADTx bits as listed in T able 8−1. Each channel is individually configurable for its transfer mode. For example, channel 0 may be configured in single transfer mode, while channel 1 is configured for burst-block transfer mode, and channel 2 operates in repea[...]

  • Page 174

    8-6 Single T ransfer In single transfer mode, each byte/word transfer requires a separate trigger . The single transfer state diagram is shown in Figure 8−3. The DMAxSZ register is used to define the number of transfers to be made. The DMADSTINCRx and DMASRCINCRx bits select if the destination address and the source address are incremented or dec[...]

  • Page 175

    8-7 Figure 8−3. DMA Single T ransfer State Diagram Reset W ait for T rigger Idle Hold CPU, T ransfer one word/byte [+T rigger AND DMALEVEL = 0 ] OR [T rigger=1 AND DMALEVEL=1] DMAABORT=0 DMAABORT = 1 2 x MCLK DMAEN = 0 Modify T_SourceAdd Modify T_DestAdd Decrement DMAxSZ [ENNMI = 1 AND NMI event] OR [DMALEVEL = 1 AND T rigger = 0] [ DMADTx = 0 AN[...]

  • Page 176

    8-8 Block T ransfers In block transfer mode, a transfer of a complete block of data occurs after one trigger . When DMADTx = 1, the DMAEN bit is cleared after the completion of the block transfer and must be set again before another block transfer can be triggered. After a block transfer has been triggered, further trigger signals occurring during [...]

  • Page 177

    8-9 Figure 8−4. DMA Block T ransfer State Diagram Reset W ait for T rigger Idle Hold CPU, T ransfer one word/byte [+T rigger AND DMALEVEL = 0 ] OR [T rigger=1 AND DMALEVEL=1] DMAABORT=0 DMAABORT = 1 2 x MCLK DMAEN = 0 Modify T_SourceAdd Modify T_DestAdd Decrement DMAxSZ DMAxSZ > 0 [ENNMI = 1 AND NMI event] OR [DMALEVEL = 1 AND T rigger = 0] [D[...]

  • Page 178

    8-10 Burst-Block T ransfers In burst-block mode, transfers are block transfers with CPU activity interleaved. The CPU executes 2 MCLK cycles after every four byte/word transfers of the block resulting in 20% CPU execution capacity . After the burst-block, CPU execution resumes at 100% capacity and the DMAEN bit is cleared. DMAEN must be set again b[...]

  • Page 179

    8-1 1 Figure 8−5. DMA Burst-Block T ransfer State Diagram 2 x MCLK Reset W ait for T rigger Idle Hold CPU, T ransfer one word/byte Burst State (release CPU for 2xMCLK) [+T rigger AND DMALEVEL = 0 ] OR [T rigger=1 AND DMALEVEL=1] DMAABORT=0 DMAABORT = 1 2 x MCLK DMAEN = 0 Modify T_SourceAdd Modify T_DestAdd Decrement DMAxSZ [DMADTx = {6, 7} AND DM[...]

  • Page 180

    8-12 8.2.3 Initiating DMA T ransfers Each DMA channel is independently configured for its trigger source with the DMAxTSELx bits as described in T able 8−2.The DMAxTSELx bits should be modified only when the DMACTLx DMAEN bit is 0. Otherwise, unpredictable DMA triggers may occur . When selecting the trigger , the trigger must not have already occ[...]

  • Page 181

    8-13 T able 8−2. DMA T rigger Operation DMAxTSELx Operation 0000 A transfer is triggered when the DMAREQ bit is set. The DMAREQ bit is automatically reset when the transfer starts 0001 A transfer is triggered when the T ACCR2 CCIFG flag is set. The T ACCR2 CCIFG flag is automatically reset when the transfer starts. If the T ACCR2 CCIE bit is set,[...]

  • Page 182

    8-14 8.2.4 Stopping DMA T ransfers There are two ways to stop DMA transfers in progress: - A single, block, or burst-block transfer may be stopped with an NMI interrupt, if the ENNMI bit is set in register DMACTL1. - A burst-block transfer may be stopped by clearing the DMAEN bit. 8.2.5 DMA Channel Priorities The default DMA channel priorities are [...]

  • Page 183

    8-15 8.2.6 DMA T ransfer Cycle Time The DMA controller requires one or two MCLK clock cycles to synchronize before each single transfer or complete block or burst-block transfer . Each byte/word transfer requires two MCLK cycles after synchronization, and one cycle of wait time after the transfer . Because the DMA controller uses MCLK, the DMA cycl[...]

  • Page 184

    8-16 8.2.7 Using DMA with System Interrupts DMA transfers are not interruptible by system interrupts. System interrupts remain pending until the completion of the transfer . NMI interrupts can interrupt the DMA controller if the ENNMI bit is set. System interrupt service routines are interrupted by DMA transfers. If an interrupt service routine or [...]

  • Page 185

    8-17 8.2.9 Using the I 2 C Module with the DMA Controller The I 2 C module provides two trigger sources for the DMA controller . The I 2 C module can trigger a transfer when new I 2 C data is received and the when the transmit data is needed. The TXDMAEN and RXDMAEN bits enable or disable the use of the DMA controller with the I 2 C module. When RX[...]

  • Page 186

    8-18 8.3 DMA Registers The DMA registers are listed in T able 8−4: T able 8−4. DMA Registers Register Short Form Register T ype Address Initial State DMA control 0 DMACTL0 Read/write 0122h Reset with POR DMA control 1 DMACTL1 Read/write 0124h Reset with POR DMA channel 0 control DMA0CTL Read/write 01E0h Reset with POR DMA channel 0 source addre[...]

  • Page 187

    8-19 DMACTL0, DMA Control Register 0 15 14 13 12 1 1 10 9 8 Reserved DMA2TSELx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 DMA1TSELx DMA0TSELx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) Reserved Bits 15−12 Reserved DMA2 TSELx Bits 1 1−8 DMA trigger select. These bits select the [...]

  • Page 188

    8-20 DMACTL1, DMA Control Register 1 15 14 13 12 1 1 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 76543 210 0 0 0 0 0 DMA ONFETCH ROUND ROBIN ENNMI r0 r0 r0 r0 r0 rw−(0) rw−(0) rw−(0) Reserved Bits 15−3 Reserved. Read only . Always read as 0. DMA ONFETCH Bit 2 DMA on fetch 0 The DMA transfer occurs immediately 1 The DMA transfer occurs on[...]

  • Page 189

    8-21 DMAxCTL, DMA Channel x Control Register 15 14 13 12 1 1 10 9 8 Reserved DMADTx DMADSTINCRx DMASRCINCRx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 DMA DSTBYTE DMA SRCBYTE DMALEVEL DMAEN DMAIFG DMAIE DMA ABORT DMAREQ rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) Reserved Bit 15 Res[...]

  • Page 190

    8-22 DMA SRCBYTE Bit 6 DMA source byte. This bit selects the source as a byte or word. 0 Word 1 Byte DMA LEVEL Bit 5 DMA level. This bit selects between edge-sensitive and level-sensitive triggers. 0 Edge sensitive (rising edge) 1 Level sensitive (high level) DMAEN Bit 4 DMA enable 0 Disabled 1 Enabled DMAIFG Bit 3 DMA interrupt flag 0 No interrupt[...]

  • Page 191

    8-23 DMAxDA, DMA Destination Address Register 15 14 13 12 1 1 10 9 8 DMAxDAx rw rw rw rw rw rw rw rw 76543 210 DMAxDAx rw rw rw rw rw rw rw rw DMAxDAx Bits 15−0 DMA destination address. The destination address register points to the destination address for single transfers or the first address for block transfers. The DMAxDA register remains unch[...]

  • Page 192

    8-24[...]

  • Page 193

    9-1 Digital I/O ("* This chapter describes the operation of the digital I/O ports. Ports P1-P2 are implemented in MSP430x1 1xx devices. Ports P1-P3 are implemented in MSP430x12xx devices. Ports P1-P6 are implemented in MSP430x13x, MSP430x14x, MSP430x15x, and MSP430x16x devices. T opic Page 9.1 Digital I/O Introduction 9[...]

  • Page 194

    Digital I/O Introduction 9-2 Digital I/O 9.1 Digital I/O Introduction MSP430 devices have up to 6 digital I/O ports implemented, P1 - P6. Each port has eight I/O pins. Every I/O pin is individually configurable for input or output direction, and each I/O line can be individually read or written to. Ports P1 and P2 have interrupt capability . Each i[...]

  • Page 195

    Digital I/O Operation 9-3 Digital I/O 9.2 Digital I/O Operation Th e digital I/O is configured with user software. The setup and operation of the digital I/O is discussed in the following sections. 9.2.1 Input Register PxIN Each bit in each PxIN register reflects the value of the input signal at the corresponding I/O pin when the pin is configured [...]

  • Page 196

    Digital I/O Operation 9-4 Digital I/O 9.2.4 Function Select Registers PxSEL Port pins are often multiplexed with other peripheral module functions. See the device-specific data sheet to determine pin functions. Each PxSEL bit is used to select the pin function − I/O port or peripheral module function. Bit = 0: I/O Function is selected for the pin[...]

  • Page 197

    Digital I/O Operation 9-5 Digital I/O 9.2.5 P1 and P2 Interrupts Each pin in ports P1 and P2 have interrupt capability , configured with the PxIFG, PxIE, and PxIES registers. All P1 pins source a single interrupt vector , and all P2 pins source a different single interrupt vector . The PxIFG register can be tested to determine the source of a P1 or[...]

  • Page 198

    Digital I/O Operation 9-6 Digital I/O Interrupt Edge Select Registers P1IES, P2IES Each PxIES bit selects the interrupt edge for the corresponding I/O pin. Bit = 0: The PxIFGx flag is set with a low-to-high transition Bit = 1: The PxIFGx flag is set with a high-to-low transition Note: Writing to PxIESx Writing to P1IES, or P2IES can result in setti[...]

  • Page 199

    Digital I/O Registers 9-7 Digital I/O 9.3 Digital I/O Registers Seven registers are used to configure P1 and P2. Four registers are used to configure ports P3 - P6. The digital I/O registers are listed in T able 9−1. T able 9−1. Digital I/O Registers Port Register Short Form Address Register T ype Initial State P1 Input P1IN 020h Read only − [...]

  • Page 200

    9-8 Digital I/O[...]

  • Page 201

    10-1 Watchdog Timer +    The watchdog timer is a 16-bit timer that can be used as a watchdog or as an interval timer . This chapter describes the watchdog timer . The watchdog timer is implemented in all MSP430x1xx devices. T opic Page 10.1 Watchdog T imer Introduction 10-2 . . . . . . . . . . . . . . . . . . . .[...]

  • Page 202

    Watchdog Timer Introduction 10-2 Watchdog Timer 10.1 W atchdog Timer Introduction The primary function of the watchdog timer (WDT) module is to perform a controlled system restart after a software problem occurs. If the selected time interval expires, a system reset is generated. If the watchdog function is not needed in an application, the module [...]

  • Page 203

    Watchdog Timer Introduction 10-3 Watchdog Timer Figure 10−1. Watchdog T imer Block Diagram WDTQn Y 1 2 3 4 Q6 Q9 Q13 Q15 16−bit Counter CLK A B 1 1 AE N PUC SMCLK ACLK Clear Password Compare 0 0 0 0 1 1 1 1 WDTCNTCL WDTTMSEL WDTNMI WDTNMIES WDTIS1 WDTSSEL WDTIS0 WDTHOLD EQU EQU Write Enable Low Byte R / W MDB LSB MSB WDTCTL (Asyn) Int. Flag Pul[...]

  • Page 204

    Watchdog Timer Operation 10-4 Watchdog Timer 10.2 W atchdog Timer Operation Th e WDT module can be configured as either a watchdog or interval timer with the WDTCTL register . The WDTCTL register also contains control bits to configure the RST /NMI pin. WDTCTL is a 16-bit, password-protected, read/write register . Any read or write access must use [...]

  • Page 205

    Watchdog Timer Operation 10-5 Watchdog Timer 10.2.4 W atchdog Timer Interrupts The WDT uses two bits in the SFRs for interrupt control. - The WDT interrupt flag, WDTIFG, located in IFG1.0 - The WDT interrupt enable, WDTIE, located in IE1.0 When using the WDT in the watchdog mode, the WDTIFG flag sources a reset vector interrupt. The WDTIFG can be u[...]

  • Page 206

    Watchdog Timer Operation 10-6 Watchdog Timer 10.2.5 Operation in Low-Power Modes The MSP430 devices have several low-power modes. Different clock signals are available in different low-power modes. The requirements of the user’s application and the type of clocking used determine how the WDT should be configured. For example, the WDT should not b[...]

  • Page 207

    Watchdog T imer Registers 10-7 Watchdog Timer 10.3 W atchdog Timer Registers The watchdog timer module registers are listed in T able 10−1. T able 10−1. Watchdog Timer Registers Register Short Form Register T ype Address Initial State W atchdog timer control register WDTCTL Read/write 0120h 06900h with PUC SFR interrupt enable register 1 IE1 Re[...]

  • Page 208

    Watchdog T imer Registers 10-8 Watchdog Timer WDTCTL, W atchdog Timer Register 15 14 13 12 1 1 10 9 8 Read as 069h WDTPW , must be written as 05Ah 76543 210 WDTHOLD WDTNMIES WDTNMI WDTTMSEL WDTCNTCL WDTSSEL WDTISx rw−0 rw−0 rw−0 rw−0 r0(w) rw−0 rw−0 rw−0 WDTPW Bits 15-8 W atchdog timer password. Always read as 069h. Must be written as[...]

  • Page 209

    Watchdog T imer Registers 10-9 Watchdog Timer IE1, Interrupt Enable Register 1 76543 210 NMIIE WDTIE rw−0 rw−0 Bits 7-5 These bits may be used by other modules. See device-specific datasheet. NMIIE Bit 4 NMI interrupt enable. This bit enables the NMI interrupt. Because other bits in IE1 may be used for other modules, it is recommended to set or[...]

  • Page 210

    Watchdog T imer Registers 10-10 Watchdog Timer IFG1, Interrupt Flag Register 1 76543 210 NMIIFG WDTIFG rw−(0) rw−(0) Bits 7-5 These bits may be used by other modules. See device-specific datasheet. NMIIFG Bit 4 NMI interrupt flag. NMIIFG must be reset by software. Because other bits in IFG1 may be used for other modules, it is recommended to cl[...]

  • Page 211

    1 1-1 Timer_A  ,) T imer_A is a 16-bit timer/counter with three capture/compare registers. This chapter describes T imer_A. T imer_A is implemented in all MSP430x1xx devices. T opic Page 1 1.1 T imer_A Introduction 1 1-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 T imer_A Operation 1 1-4 .[...]

  • Page 212

    Timer_A Introduction 1 1-2 Timer_A 1 1.1 Timer_A Introduction T imer_A is a 16-bit timer/counter with three capture/compare registers. T imer_A can support multiple capture/compares, PWM outputs, and interval timing. T imer_A also has extensive interrupt capabilities. Interrupts may be generated from the counter on overflow conditions and from each[...]

  • Page 213

    Timer_A Introduction 1 1-3 Timer_A Figure 1 1−1. Timer_A Block Diagram Compararator 2 CCI 15 0 CCISx OUTMODx Capture Mode CMx Sync SCS COV logic Output Unit2 D Set Q EQU0 OUT OUT2 Signal Reset GND VCC CCI2A CCI2B EQU2 Divider 1/2/4/8 Count Mode 16−bit T imer TA R RC ACLK SMCLK T ACLK INCLK Set T AIFG 15 0 T ASSELx MCx IDx 00 01 10 11 Clear T im[...]

  • Page 214

    Timer_A Operation 1 1-4 Timer_A 1 1.2 Timer_A Operation The T imer_A module is configured with user software. The setup and operation of T imer_A is discussed in the following sections. 1 1.2.1 16-Bit Timer Counter The 16-bit timer/counter register , T AR, increments or decrements (depending on mode of operation) with each rising edge of the clock [...]

  • Page 215

    Timer_A Operation 1 1-5 Timer_A 1 1.2.2 Starting the Timer The timer may be started, or restarted in the following ways: - The timer counts when MCx > 0 and the clock source is active. - When the timer mode is either up or up/down, the timer may be stopped by writing 0 to T ACCR0. The timer may then be restarted by writing a nonzero value to T A[...]

  • Page 216

    Timer_A Operation 1 1-6 Timer_A Up Mode Th e up mode is used if the timer period must be dif ferent from 0FFFFh counts. The timer repeatedly counts up to the value of compare register T ACCR0, which defines the period, as shown in Figure 1 1−2. The number of timer counts in the period is T ACCR0+1. When the timer value equals T ACCR0 the timer re[...]

  • Page 217

    Timer_A Operation 1 1-7 Timer_A Continuous Mode In the continuous mode, the timer repeatedly counts up to 0FFFFh and restarts from zero as shown in Figure 1 1−4. The capture/compare register T ACCR0 works the same way as the other capture/compare registers. Figure 1 1−4. Continuous Mode 0h 0FFFFh The T AIFG interrupt flag is set when the timer [...]

  • Page 218

    Timer_A Operation 1 1-8 Timer_A Use of the Continuous Mode Th e continuous mode can be used to generate independent time intervals and output frequencies. Each time an interval is completed, an interrupt is generated. The next time interval is added to the T ACCRx register in the interrupt service routine. Figure 1 1−6 shows two separate time int[...]

  • Page 219

    Timer_A Operation 1 1-9 Timer_A Up/Down Mode The up/down mode is used if the timer period must be different from 0FFFFh counts, and if symmetrical pulse generation is needed. The timer repeatedly counts up to the value of compare register T ACCR0 and back down to zero, as shown in Figure 1 1−7. The period is twice the value in T ACCR0. Figure 1 1[...]

  • Page 220

    Timer_A Operation 1 1-10 Timer_A Changing the Period Register T ACCR0 When changing T ACCR0 while the timer is running, and counting in the down direction, the timer continues its descent until it reaches zero. The new period takes affect after the counter counts down to zero. When the timer is counting in the up direction, and the new period is gr[...]

  • Page 221

    Timer_A Operation 1 1-1 1 Timer_A 1 1.2.4 Capture/Compare Blocks Three identical capture/compare blocks, T ACCRx, are present in T imer_A. Any of the blocks may be used to capture the timer data, or to generate time intervals. Capture Mode Th e capture mode is selected when CAP = 1. Capture mode is used to record time events. It can be used for spe[...]

  • Page 222

    Timer_A Operation 1 1-12 Timer_A Figure 1 1−1 1. Capture Cycle Second Capture T aken COV = 1 Capture T aken No Capture T aken Read T aken Capture Clear Bit COV in Register T ACCTLx Idle Idle Capture Capture Read and No Capture Capture Capture Read Capture Capture Initiated by Software Captures can be initiated by software. The CMx bits can be set[...]

  • Page 223

    Timer_A Operation 1 1-13 Timer_A 1 1.2.5 Output Unit Each capture/compare block contains an output unit. The output unit is used to generate output signals such as PWM signals. Each output unit has eight operating modes that generate signals based on the EQU0 and EQUx signals. Output Modes The output modes are defined by the OUTMODx bits and are de[...]

  • Page 224

    Timer_A Operation 1 1-14 Timer_A Output Example — Timer in Up Mode The OUTx signal is changed when the timer counts up to the T ACCRx value, and rolls from T ACCR0 to zero, depending on the output mode. An example is shown in Figure 1 1−12 using T ACCR0 and T ACCR1. Figure 1 1−12. Output Example—Timer in Up Mode 0h 0FFFFh EQU0 T AIFG Output[...]

  • Page 225

    Timer_A Operation 1 1-15 Timer_A Output Example — Timer in Continuous Mode The OUTx signal is changed when the timer reaches the T ACCRx and T ACCR0 values, depending on the output mode. An example is shown in Figure 1 1−13 using T ACCR0 and T ACCR1. Figure 1 1−13. Output Example—Timer in Continuous Mode 0h 0FFFFh T AIFG Output Mode 1: Set [...]

  • Page 226

    Timer_A Operation 1 1-16 Timer_A Output Example — Timer in Up/Down Mode The OUTx signal changes when the timer equals T ACCRx in either count direction and when the timer equals T ACCR0, depending on the output mode. An example is shown in Figure 1 1−14 using T ACCR0 and T ACCR2. Figure 1 1−14. Output Example—Timer in Up/Down Mode 0h 0FFFFh[...]

  • Page 227

    Timer_A Operation 1 1-17 Timer_A 1 1.2.6 Timer_A Interrupts T wo interrupt vectors are associated with the 16-bit T imer_A module: - T ACCR0 interrupt vector for T ACCR0 CCIFG - T AIV interrupt vector for all other CCIFG flags and T AIFG In capture mode any CCIFG flag is set when a timer value is captured in the associated T ACCRx register . In com[...]

  • Page 228

    Timer_A Operation 1 1-18 Timer_A T AIV Software Example Th e following software example shows the recommended use of T AIV and the handling overhead. The T AIV value is added to the PC to automatically jump to the appropriate routine. The numbers at the right margin show the necessary CPU cycles for each instruction. The software overhead for diffe[...]

  • Page 229

    Timer_A Registers 1 1-19 Timer_A 1 1.3 Timer_A Registers The T imer_A registers are listed in T able 1 1−3: T able 1 1−3. Timer_A Registers Register Short Form Register T ype Address Initial State T imer_A control T ACTL Read/write 0160h Reset with POR T imer_A counter T AR Read/write 0170h Reset with POR T imer_A capture/compare control 0 T AC[...]

  • Page 230

    Timer_A Registers 1 1-20 Timer_A T ACTL, Timer_A Control Register 15 14 13 12 1 1 10 9 8 Unused T ASSELx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 IDx MCx Unused T ACLR T AIE T AIFG rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) w−(0) rw−(0) rw−(0) Unused Bits 15-10 Unused T ASSELx Bits 9-8 T imer_A clock[...]

  • Page 231

    Timer_A Registers 1 1-21 Timer_A T AR, Timer_A Register 15 14 13 12 1 1 10 9 8 T ARx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 T ARx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) T ARx Bits 15-0 T imer_A register . The T AR register is the count of T imer_A.[...]

  • Page 232

    Timer_A Registers 1 1-22 Timer_A T ACCTLx, Capture/Compare Control Register 15 14 13 12 1 1 10 9 8 CMx CCISx SCS SCCI Unused CAP rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) r−(0) r−(0) rw−(0) 76543 210 OUTMODx CCIE CCI OUT COV CCIFG rw−(0) rw−(0) rw−(0) rw−(0) r rw−(0) rw−(0) rw−(0) CMx Bit 15-14 Capture mode 00 No capture 01 C[...]

  • Page 233

    Timer_A Registers 1 1-23 Timer_A CCIE Bit 4 Capture/compare interrupt enable. This bit enables the interrupt request of the corresponding CCIFG flag. 0 Interrupt disabled 1 Interrupt enabled CCI Bit 3 Capture/compare input. The selected input signal can be read by this bit. OUT Bit 2 Output. For output mode 0, this bit directly controls the state o[...]

  • Page 234

    1 1-24 Timer_A[...]

  • Page 235

    12-1 Timer_B  , T imer_B i s a 16-bit timer/counter with multiple capture/compare registers. This chapter describes T imer_B. T imer_B3 (three capture/compare registers) is implemented in MSP430x13x and MSP430x15x devices. T imer_B7 (seven capture/compare registers) is implemented in MSP430x14x and MSP430x16x devices. T opic Page [...]

  • Page 236

    Timer_B Introduction 12-2 Timer_B 12.1 T imer_B Introduction T imer_B is a 16-bit timer/counter with three or seven capture/compare registers. T imer_B can support multiple capture/compares, PWM outputs, and interval timing. T imer_B also has extensive interrupt capabilities. Interrupts may be generated from the counter on overflow conditions and f[...]

  • Page 237

    Timer_B Introduction 12-3 Timer_B Figure 12−1. Timer_B Block Diagram CCR6 Compararator 6 CCI 15 0 OUTMODx Capture Mode CMx Sync COV logic Output Unit6 D Set Q EQU0 OUT OUT6 Signal Reset POR EQU6 Divider 1/2/4/8 Count Mode 16−bit T imer TBR Set TBIFG 15 0 MCx IDx Clear TBCLR T imer Clock CCR0 EQU0 T imer Clock T imer Clock VCC TBR=0 UP/DOWN EQU0[...]

  • Page 238

    Timer_B Operation 12-4 Timer_B 12.2 T imer_B Operation The T imer_B module is configured with user software. The setup and operation of T imer_B is discussed in the following sections. 12.2.1 16-Bit Timer Counter The 16-bit timer/counter register , TBR, increments or decrements (depending on mode of operation) with each rising edge of the clock sig[...]

  • Page 239

    Timer_B Operation 12-5 Timer_B 12.2.2 Starting the T imer The timer may be started or restarted in the following ways: - The timer counts when MCx > 0 and the clock source is active. - When the timer mode is either up or up/down, the timer may be stopped by loading 0 to TBCL0. The timer may then be restarted by loading a nonzero value to TBCL0. [...]

  • Page 240

    Timer_B Operation 12-6 Timer_B Up Mode T h e up mode is used if the timer period must be dif ferent from TBR (max) counts. The timer repeatedly counts up to the value of compare latch TBCL0, which defines the period, as shown in Figure 12−2. The number of timer counts in the period is TBCL0+1. When the timer value equals TBCL0 the timer restarts [...]

  • Page 241

    Timer_B Operation 12-7 Timer_B Continuous Mode In continuous mode the timer repeatedly counts up to TBR (max) and restarts from zero as shown in Figure 12−4. The compare latch TBCL0 works the same way as the other capture/compare registers. Figure 12−4. Continuous Mode 0h TBR (max) The TBIFG interrupt flag is set when the timer counts from TBR [...]

  • Page 242

    Timer_B Operation 12-8 Timer_B Use of the Continuous Mode Th e continuous mode can be used to generate independent time intervals and output frequencies. Each time an interval is completed, an interrupt is generated. The next time interval is added to the TBCLx latch in the interrupt service routine. Figure 12−6 shows two separate time intervals [...]

  • Page 243

    Timer_B Operation 12-9 Timer_B Up/Down Mode Th e up/down mode is used if the timer period must be dif ferent from TBR (max) counts, and if symmetrical pulse generation is needed. The timer repeatedly counts up to the value of compare latch TBCL0, and back down to zero, as shown in Figure 12−7. The period is twice the value in TBCL0. Note: TBCL0 &[...]

  • Page 244

    Timer_B Operation 12-10 Timer_B Changing the V alue of Period Register TBCL0 When changing TBCL0 while the timer is running, and counting in the down direction, and when the TBCL0 load mode is immediate , the timer continues its descent until it reaches zero. The new period takes effect after the counter counts down to zero. If the timer is countin[...]

  • Page 245

    Timer_B Operation 12-1 1 Timer_B 12.2.4 Capture/Compare Blocks Three or seven identical capture/compare blocks, TBCCRx, are present in T imer_B. Any of the blocks may be used to capture the timer data or to generate time intervals. Capture Mode Th e capture mode is selected when CAP = 1. Capture mode is used to record time events. It can be used fo[...]

  • Page 246

    Timer_B Operation 12-12 Timer_B Figure 12−1 1. Capture Cycle Second Capture T aken COV = 1 Capture T aken No Capture T aken Read T aken Capture Clear Bit COV in Register TBCCTLx Idle Idle Capture Capture Read and No Capture Capture Capture Read Capture Capture Initiated by Software Captures can be initiated by software. The CMx bits can be set fo[...]

  • Page 247

    Timer_B Operation 12-13 Timer_B Compare Latch TBCLx The TBCCRx compare latch, TBCLx, holds the data for the comparison to the timer value in compare mode. TBCLx is buffered by TBCCRx. The buf fered compare latch gives the user control over when a compare period updates. The user cannot directly access TBCLx. Compare data is written to each TBCCRx a[...]

  • Page 248

    Timer_B Operation 12-14 Timer_B 12.2.5 Output Unit Each capture/compare block contains an output unit. The output unit is used to generate output signals such as PWM signals. Each output unit has eight operating modes that generate signals based on the EQU0 and EQUx signals. The TBOUTH pin function can be used to put all T imer_B outputs into a hig[...]

  • Page 249

    Timer_B Operation 12-15 Timer_B Output Example—Timer in Up Mode Th e OUTx signal is changed when the timer counts up to the TBCLx value, and rolls from TBCL0 to zero, depending on the output mode. An example is shown in Figure 12−12 using TBCL0 and TBCL1. Figure 12−12. Output Example—Timer in Up Mode 0h TBR (max) EQU0 TBIFG Output Mode 1: S[...]

  • Page 250

    Timer_B Operation 12-16 Timer_B Output Example—Timer in Continuous Mode The OUTx signal is changed when the timer reaches the TBCLx and TBCL0 values, depending on the output mode, An example is shown in Figure 12−13 using TBCL0 and TBCL1. Figure 12−13. Output Example—Timer in Continuous Mode 0h TBR (max) TBIFG Output Mode 1: Set Output Mode[...]

  • Page 251

    Timer_B Operation 12-17 Timer_B Output Example − Timer in Up/Down Mode The OUTx signal changes when the timer equals TBCLx in either count direction and when the timer equals TBCL0, depending on the output mode. An example is shown in Figure 12−14 using TBCL0 and TBCL3. Figure 12−14. Output Example—Timer in Up/Down Mode 0h TBR (max) TBIFG O[...]

  • Page 252

    Timer_B Operation 12-18 Timer_B 12.2.6 Timer_B Interrupts T wo interrupt vectors are associated with the 16-bit T imer_B module: - TBCCR0 interrupt vector for TBCCR0 CCIFG - TBIV interrupt vector for all other CCIFG flags and TBIFG In capture mode, any CCIFG flag is set when a timer value is captured in the associated TBCCRx register . In compare m[...]

  • Page 253

    Timer_B Operation 12-19 Timer_B TBIV , Interrupt Handler Examples Th e following software example shows the recommended use of TBIV and the handling overhead. The TBIV value is added to the PC to automatically jump to the appropriate routine. The numbers at the right margin show the necessary CPU clock cycles for each instruction. The software over[...]

  • Page 254

    Timer_B Registers 12-20 Timer_B 12.3 T imer_B Registers The T imer_B registers are listed in T able 12−5: T able 12−5. Timer_B Registers Register Short Form Register T ype Address Initial State T imer_B control TBCTL Read/write 0180h Reset with POR T imer_B counter TBR Read/write 0190h Reset with POR T imer_B capture/compare control 0 TBCCTL0 R[...]

  • Page 255

    Timer_B Registers 12-21 Timer_B Timer_B Control Register TBCTL 15 14 13 12 1 1 10 9 8 Unused TBCLGRPx CNTLx Unused TBSSELx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 IDx MCx Unused TBCLR TBIE TBIFG rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) w−(0) rw−(0) rw−(0) Unused Bit 15 Unused TBCLGRP Bit 14-13 TBC[...]

  • Page 256

    Timer_B Registers 12-22 Timer_B Unused Bit 3 Unused TBCLR Bit 2 Timer_B clear . Setting this bit resets TBR, the TBCLK divider , and the count direction. The TBCLR bit is automatically reset and is always read as zero. TBIE Bit 1 Timer_B interrupt enable. This bit enables the TBIFG interrupt request. 0 Interrupt disabled 1 Interrupt enabled TBIFG B[...]

  • Page 257

    Timer_B Registers 12-23 Timer_B TBCCTLx, Capture/Compare Control Register 15 14 13 12 1 1 10 9 8 CMx CCISx SCS CLLDx CAP rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) r−(0) rw−(0) 76543 210 OUTMODx CCIE CCI OUT COV CCIFG rw−(0) rw−(0) rw−(0) rw−(0) r rw−(0) rw−(0) rw−(0) CMx Bit 15-14 Capture mode 00 No capture 01 Capture [...]

  • Page 258

    Timer_B Registers 12-24 Timer_B CCIE Bit 4 Capture/compare interrupt enable. This bit enables the interrupt request of the corresponding CCIFG flag. 0 Interrupt disabled 1 Interrupt enabled CCI Bit 3 Capture/compare input. The selected input signal can be read by this bit. OUT Bit 2 Output. For output mode 0, this bit directly controls the state of[...]

  • Page 259

    Timer_B Registers 12-25 Timer_B TBIV , Timer_B Interrupt V ector Register 15 14 13 12 1 1 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 76543 210 0 0 0 0 TBIVx 0 r0 r0 r0 r0 r−(0) r−(0) r−(0) r0 TBIVx Bits 15-0 T imer_B interrupt vector value TBIV Contents Interrupt Source Interrupt Flag Interrupt Priority 00h No interrupt pending − 02h Ca[...]

  • Page 260

    12-26 Timer_B[...]

  • Page 261

    13-1 USART Peripheral Interface, UAR T Mode !) " - !) The universal synchronous/asynchronous receive/transmit (USART) peripheral interface supports two serial modes with one hardware module. This chapter discusses the operation of the asynchronous UART mode. US[...]

  • Page 262

    USART Introduction: UAR T Mode 13-2 USART Peripheral Interface, UAR T Mode 13.1 USART Introduction: UART Mode In asynchronous mode, the USART connects the MSP430 to an external system via two external pins, URXD and UTXD. UAR T mode is selected when the SYNC bit is cleared. UART mode features include: - 7- or 8-bit data with odd, even, or non-parit[...]

  • Page 263

    USART Introduction: UAR T Mode 13-3 USART Peripheral Interface, UAR T Mode Figure 13−1. USART Block Diagram: UAR T Mode Receiver Shift Register T ransmit Shift Register Receiver Buffer UxRXBUF T ransmit Buffer UxTXBUF LISTEN MM UCLK Clock Phase and Polarity Receive Status SYNC CKPH CKPL SSEL1 SSEL0 UCLKI ACLK SMCLK SMCLK 00 01 10 11 OE PE BRK TXW[...]

  • Page 264

    USART Operation: UAR T Mode 13-4 USART Peripheral Interface, UAR T Mode 13.2 USART Operation: UART Mode In UART mode, the USAR T transmits and receives characters at a bit rate asynchronous to another device. T iming for each character is based on the selected baud rate of the USART . The transmit and receive functions use the same baud rate freque[...]

  • Page 265

    USART Operation: UAR T Mode 13-5 USART Peripheral Interface, UAR T Mode 13.2.3 Asynchronous Communication Formats When two devices communicate asynchronously , the idle-line format is used for the protocol. When three or more devices communicate, the USART supports the idle-line and address-bit multiprocessor communication formats. Idle-Line Multip[...]

  • Page 266

    USART Operation: UAR T Mode 13-6 USART Peripheral Interface, UAR T Mode The URXWIE bit is used to control data reception in the idle-line multiprocessor format. When the URXWIE bit is set, all non-address characters are assembled but not transferred into the UxRXBUF , and interrupts are not generated. When an address character is received, the rece[...]

  • Page 267

    USART Operation: UAR T Mode 13-7 USART Peripheral Interface, UAR T Mode Address - Bit Multiprocessor Format When MM = 1, the address-bit multiprocessor format is selected. Each processed character contains an extra bit used as an address indicator shown in Figure 13−4. The first character in a block of characters carries a set address bit which i[...]

  • Page 268

    USART Operation: UAR T Mode 13-8 USART Peripheral Interface, UAR T Mode Automatic Error Detection Glitch suppression prevents the USART from being accidentally started. Any low-level on URXDx shorter than the deglitch time t τ (approximately 300 ns) will be ignored. See the device-specific datasheet for parameters. When a low period on URXDx excee[...]

  • Page 269

    USART Operation: UAR T Mode 13-9 USART Peripheral Interface, UAR T Mode 13.2.4 USART Receive Enable Th e receive enable bit, URXEx, enables or disables data reception on URXDx as shown in Figure 13−5. Disabling the USART receiver stops the receive operation following completion of any character currently being received or immediately if no receiv[...]

  • Page 270

    USART Operation: UAR T Mode 13-10 USART Peripheral Interface, UAR T Mode 13.2.5 USART T ransmit Enable When UTXEx is set, the UAR T transmitter is enabled. T ransmission is initiated by writing data to UxTXBUF . The data is then moved to the transmit shift register on the next BITCLK after the TX shift register is empty , and transmission begins. T[...]

  • Page 271

    USART Operation: UAR T Mode 13-1 1 USART Peripheral Interface, UAR T Mode 13.2.6 UART Baud Rate Generation The USART baud rate generator is capable of producing standard baud rates from non-standard source frequencies. The baud rate generator uses one prescaler/divider and a modulator as shown in Figure 13−7. This combination supports fractional [...]

  • Page 272

    USART Operation: UAR T Mode 13-12 USART Peripheral Interface, UAR T Mode Baud Rate Bit Timing Th e first stage of the baud rate generator is the 16-bit counter and comparator . At the beginning of each bit transmitted or received, the counter is loaded with INT(N/2) where N is the value stored in the combination of UxBR0 and UxBR1. The counter relo[...]

  • Page 273

    USART Operation: UAR T Mode 13-13 USART Peripheral Interface, UAR T Mode T ransmit Bit Timing The timing for each character is the sum of the individual bit timings. By modulating each bit, the cumulative bit error is reduced. The individual bit error can be calculated by: Error [%] + NJ baud rate BRCLK ƪ ( j ) 1 ) UxBR ) S j i + 0 m i ƫ * ( j ) [...]

  • Page 274

    USART Operation: UAR T Mode 13-14 USART Peripheral Interface, UAR T Mode Receive Bit Timing Receive timing consists of two error sources. The first is the bit-to-bit timing error . The second is the error between a start edge occurring and the start edge being accepted by the USART . Figure 13−9 shows the asynchronous timing errors between data o[...]

  • Page 275

    USART Operation: UAR T Mode 13-15 USART Peripheral Interface, UAR T Mode For example, the receive errors for the following conditions are calculated: Baud rate = 2400 BRCLK = 32,768 Hz (ACLK) UxBR = 13, since the ideal division factor is 13.65 UxMCTL = 6B:m7 = 0, m6 = 1, m5 = 1, m4 = 0, m3 = 1, m2 = 0, m1 = 1 and m0 = 1 The LSB of UxMCTL is used fi[...]

  • Page 276

    USART Operation: UAR T Mode 13-16 USART Peripheral Interface, UAR T Mode T ypical Baud Rates and Errors Standard baud rate frequency data for UxBRx and UxMCTL are listed in T able 13−2 for a 32,768-Hz watch crystal (ACLK) and a typical 1,048,576-Hz SMCLK. Th e receive error is the accumulated time versus the ideal scanning time in the middle of e[...]

  • Page 277

    USART Operation: UAR T Mode 13-17 USART Peripheral Interface, UAR T Mode 13.2.7 USART Interrupts The USART has one interrupt vector for transmission and one interrupt vector for reception. USART T ransmit Interrupt Operation The UTXIFGx interrupt flag is set by the transmitter to indicate that UxTXBUF is ready to accept another character . An inter[...]

  • Page 278

    USART Operation: UAR T Mode 13-18 USART Peripheral Interface, UAR T Mode USART Receive Interrupt Operation Th e URXIFGx interrupt flag is set each time a character is received and loaded into UxRXBUF . An interrupt request is generated if URXIEx and GIE are also set. URXIFGx and URXIEx are reset by a system reset PUC signal or when SWRST = 1 . URXI[...]

  • Page 279

    USART Operation: UAR T Mode 13-19 USART Peripheral Interface, UAR T Mode Receive-Start Edge Detect Operation The URXSE bit enables the receive start-edge detection feature. The recommended usage of the receive-start edge feature is when BRCLK is sourced by the DCO and when the DCO is off because of low-power mode operation. The ultra-fast turn-on o[...]

  • Page 280

    USART Operation: UAR T Mode 13-20 USART Peripheral Interface, UAR T Mode Receive-Start Edge Detect Conditions When URXSE = 1, glitch suppression prevents the USART from being accidentally started. Any low-level on URXDx shorter than the deglitch time t τ (approximately 300 ns) will be ignored by the USAR T and no interrupt request will be generate[...]

  • Page 281

    USART Registers: UAR T Mode 13-21 USART Peripheral Interface, UAR T Mode 13.3 USART Registers: UART Mode T able 13−3 lists the registers for all devices implementing a USART module. T able 13−4 applies only to devices with a second USART module, USART1. T able 13−3. USART0 Control and Status Registers Register Short Form Register T ype Addres[...]

  • Page 282

    USART Registers: UAR T Mode 13-22 USART Peripheral Interface, UAR T Mode UxCTL, USART Control Register 76543 210 PENA PEV SPB CHAR LISTEN SYNC MM SWRST rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−1 PENA Bit 7 Parity enable 0 Parity disabled. 1 Parity enabled. Parity bit is generated (UTXDx) and expected (URXDx). In address-bit multiproces[...]

  • Page 283

    USART Registers: UAR T Mode 13-23 USART Peripheral Interface, UAR T Mode UxTCTL, USART T ransmit Control Register 76543 210 Unused CKPL SSELx URXSE TXW AKE Unused TXEPT rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−1 Unused Bit 7 Unused CKPL Bit 6 Clock polarity select 0 UCLKI = UCLK 1 UCLKI = inverted UCLK SSELx Bits 5-4 Source select. The[...]

  • Page 284

    USART Registers: UAR T Mode 13-24 USART Peripheral Interface, UAR T Mode UxRCTL, USART Receive Control Register 76543 210 FE PE OE BRK URXEIE URXWIE RXWAKE RXERR rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 FE Bit 7 Framing error flag 0 No error 1 Character received with low stop bit PE Bit 6 Parity error flag. When PENA = 0, PE is read [...]

  • Page 285

    USART Registers: UAR T Mode 13-25 USART Peripheral Interface, UAR T Mode UxBR0, USART Baud Rate Control Register 0 76543 210 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 rw rw rw rw rw rw rw rw UxBR1, USART Baud Rate Control Register 1 76543 210 2 15 2 14 2 13 2 12 2 11 2 10 2 9 2 8 rw rw rw rw rw rw rw rw UxBRx The valid baud-rate control range is 3 ≤ UxBR &[...]

  • Page 286

    USART Registers: UAR T Mode 13-26 USART Peripheral Interface, UAR T Mode UxRXBUF , USART Receive Buffer Register 76543 210 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 r r r r r r r r UxRXBUFx Bits 7−0 The receive-data buffer is user accessible and contains the last received character from the receive shift register . Reading UxRXBUF resets the receive-error [...]

  • Page 287

    USART Registers: UAR T Mode 13-27 USART Peripheral Interface, UAR T Mode ME1, Module Enable Register 1 76543 210 UTXE0 † URXE0 † rw−0 rw−0 UTXE0 † Bit 7 USART0 transmit enable. This bit enables the transmitter for USAR T0. 0 Module not enabled 1 Module enabled URXE0 † Bit 6 USART0 receive enable. This bit enables the receiver for USAR T[...]

  • Page 288

    USART Registers: UAR T Mode 13-28 USART Peripheral Interface, UAR T Mode IE1, Interrupt Enable Register 1 76543 210 UTXIE0 † URXIE0 † rw−0 rw−0 UTXIE0 † Bit 7 USART0 transmit interrupt enable. This bit enables the UTXIFG0 interrupt. 0 Interrupt not enabled 1 Interrupt enabled URXIE0 † Bit 6 USART0 receive interrupt enable. This bit enab[...]

  • Page 289

    USART Registers: UAR T Mode 13-29 USART Peripheral Interface, UAR T Mode IFG1, Interrupt Flag Register 1 76543 210 UTXIFG0 † URXIFG0 † rw−1 rw−0 UTXIFG0 † Bit 7 USART0 transmit interrupt flag. UTXIFG0 is set when U0TXBUF is empty . 0 No interrupt pending 1 Interrupt pending URXIFG0 † Bit 6 USART0 receive interrupt flag. URXIFG0 is set w[...]

  • Page 290

    USART Registers: UAR T Mode 13-30 USART Peripheral Interface, UAR T Mode UTXIFG0 ‡ Bit 1 USART0 transmit interrupt flag. UTXIFG0 is set when U0TXBUF is empty . 0 No interrupt pending 1 Interrupt pending URXIFG0 ‡ Bit 0 USART0 receive interrupt flag. URXIFG0 is set when U0RXBUF has received a complete character . 0 No interrupt pending 1 Interru[...]

  • Page 291

    13-31 USART Peripheral Interface, UAR T Mode[...]

  • Page 292

    14-1 USART Peripheral Interface, SPI Mode !)"- The universal synchronous/asynchronous receive/transmit (USART) peripheral interface supports two serial modes with one hardware module. This chapter discusses the operation of the synchronous periphera[...]

  • Page 293

    USART Introduction: SPI Mode 14-2 USART Peripheral Interface, SPI Mode 14.1 USART Introduction: SPI Mode In synchronous mode, the USART connects the MSP430 to an external system via three or four pins: SIMO, SOMI, UCLK, and STE. SPI mode is selected when the SYNC bit is set and the I2C bit is cleared. SPI mode features include: - 7- or 8-bit data l[...]

  • Page 294

    USART Introduction: SPI Mode 14-3 USART Peripheral Interface, SPI Mode Figure 14−1. USART Block Diagram: SPI Mode Receiver Shift Register T ransmit Shift Register Receiver Buffer UxRXBUF T ransmit Buffer UxTXBUF LISTEN MM UCLK Clock Phase and Polarity Receive Status SYNC CKPH CKPL SSEL1 SSEL0 UCLKI ACLK SMCLK SMCLK 00 01 10 11 OE PE BRK TXW AKE U[...]

  • Page 295

    USART Operation: SPI Mode 14-4 USART Peripheral Interface, SPI Mode 14.2 USART Operation: SPI Mode In SPI mode, serial data is transmitted and received by multiple devices using a shared clock provided by the master . An additional pin, STE, is provided as to enable a device to receive and transmit data and is controlled by the master . Three or fo[...]

  • Page 296

    USART Operation: SPI Mode 14-5 USART Peripheral Interface, SPI Mode 14.2.2 Master Mode Figure 14−2. USART Master and External Slave Receive Buffer UxRXBUF Receive Shift Register MSB LSB T ransmit Buffer UxTXBUF T ransmit Shift Register MSB LSB SPI Receive Buffer Data Shift Register (DSR) MSB LSB SOMI SOMI SIMO SIMO MASTER SLA VE Px.x STE STE SS P[...]

  • Page 297

    USART Operation: SPI Mode 14-6 USART Peripheral Interface, SPI Mode 14.2.3 Slave Mode Figure 14−3. USART Slave and External Master Receive Buffer UxRXBUF Receive Shift Register LSB MSB T ransmit Buffer UxTXBUF T ransmit Shift Register LSB MSB SPI Receive Buffer Data Shift Register DSR LSB MSB SOMI SOMI SIMO SIMO MASTER SLA VE Px.x STE STE SS Port[...]

  • Page 298

    USART Operation: SPI Mode 14-7 USART Peripheral Interface, SPI Mode 14.2.4 SPI Enable The SPI transmit/receive enable bit USPIEx enables or disables the USART in SPI mode. When USPIEx = 0, the USART stops operation after the current transfer completes, or immediately if no operation is active. A PUC or set SWRST bit disables the USAR T immediately [...]

  • Page 299

    USART Operation: SPI Mode 14-8 USART Peripheral Interface, SPI Mode Receive Enable The SPI receive enable state diagrams are shown in Figure 14−6 and Figure 14−7. When USPIEx = 0, UCLK is disabled from shifting data into the RX shift register . Figure 14−6. SPI Master Receive-Enable State Diagram Idle State (Receiver Enabled) Receive Disable [...]

  • Page 300

    USART Operation: SPI Mode 14-9 USART Peripheral Interface, SPI Mode 14.2.5 Serial Clock Control UCLK is provided by the master on the SPI bus. When MM = 1, BITCLK is provided by the USART baud rate generator on the UCLK pin as shown in Fig ur e 14− 8. When MM = 0, the USART clock is provided on the UCLK pin by the master and, the baud rate genera[...]

  • Page 301

    USART Operation: SPI Mode 14-10 USART Peripheral Interface, SPI Mode Serial Clock Polarity and Phase The polarity and phase of UCLK are independently configured via the CKPL and CKPH control bits of the USART . T iming for each case is shown in Figure 14−9. Figure 14−9. USART SPI T iming CKPH CKPL Cycle# UCLK UCLK UCLK UCLK SIMO/ SOMI SIMO/ SOM[...]

  • Page 302

    USART Operation: SPI Mode 14-1 1 USART Peripheral Interface, SPI Mode 14.2.6 SPI Interrupts The USART has one interrupt vector for transmission and one interrupt vector for reception. SPI T ransmit Interrupt Operation The UTXIFGx interrupt flag is set by the transmitter to indicate that UxTXBUF is ready to accept another character . An interrupt re[...]

  • Page 303

    USART Operation: SPI Mode 14-12 USART Peripheral Interface, SPI Mode SPI Receive Interrupt Operation Th e URXIFGx interrupt flag is set each time a character is received and loaded into UxRXBUF as shown in Figure 14−1 1 and Figure 14−12. An interrupt request is generated if URXIEx and GIE are also set. URXIFGx and URXIEx are reset by a system r[...]

  • Page 304

    USART Registers: SPI Mode 14-13 USART Peripheral Interface, SPI Mode 14.3 USART Registers: SPI Mode The USAR T registers, shown in T able 14−1 and T able 14−2, are byte structured and should be accessed using byte instructions. T able 14−1. USART0 Control and Status Registers Register Short Form Register T ype Address Initial State USART cont[...]

  • Page 305

    USART Registers: SPI Mode 14-14 USART Peripheral Interface, SPI Mode UxCTL, USART Control Register 76543 210 Unused Unused I2C † CHAR LISTEN SYNC MM SWRST rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−1 Unused Bits 7−6 Unused I2C † Bit 5 I2C mode enable. This bit selects I2C or SPI operation when SYNC = 1. 0 SPI mode 1I 2 C mode CHAR [...]

  • Page 306

    USART Registers: SPI Mode 14-15 USART Peripheral Interface, SPI Mode UxTCTL, USART T ransmit Control Register 76543 210 CKPH CKPL SSELx Unused Unused STC TXEPT rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−1 CKPH Bit 7 Clock phase select. Controls the phase of UCLK. 0 Normal UCLK clocking scheme 1 UCLK is delayed by one half cycle CKPL Bit [...]

  • Page 307

    USART Registers: SPI Mode 14-16 USART Peripheral Interface, SPI Mode UxRCTL, USART Receive Control Register 76543 210 FE Unused OE Unused Unused Unused Unused Unused rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 FE Bit 7 Framing error flag. This bit indicates a bus conflict when MM = 1 and STC = 0. FE is unused in slave mode. 0 No conflic[...]

  • Page 308

    USART Registers: SPI Mode 14-17 USART Peripheral Interface, SPI Mode UxBR0, USART Baud Rate Control Register 0 76543 210 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 rw rw rw rw rw rw rw rw UxBR1, USART Baud Rate Control Register 1 76543 210 2 15 2 14 2 13 2 12 2 11 2 10 2 9 2 8 rw rw rw rw rw rw rw rw UxBRx The baud-rate generator uses the content of {UxBR1+Ux[...]

  • Page 309

    USART Registers: SPI Mode 14-18 USART Peripheral Interface, SPI Mode UxRXBUF , USART Receive Buffer Register 76543 210 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 r r r r r r r r UxRXBUFx Bits 7−0 The receive-data buffer is user accessible and contains the last received character from the receive shift register . Reading UxRXBUF resets the OE bit and URXIFGx[...]

  • Page 310

    USART Registers: SPI Mode 14-19 USART Peripheral Interface, SPI Mode ME1, Module Enable Register 1 76543 210 USPIE0 † rw−0 Bit 7 This bit may be used by other modules. See device-specific datasheet. USPIE0 † Bit 6 USART0 SPI enable. This bit enables the SPI mode for USAR T0. 0 Module not enabled 1 Module enabled Bits 5-0 These bits may be use[...]

  • Page 311

    USART Registers: SPI Mode 14-20 USART Peripheral Interface, SPI Mode IE1, Interrupt Enable Register 1 76543 210 UTXIE0 † URXIE0 † rw−0 rw−0 UTXIE0 † Bit 7 USART0 transmit interrupt enable. This bit enables the UTXIFG0 interrupt. 0 Interrupt not enabled 1 Interrupt enabled URXIE0 † Bit 6 USART0 receive interrupt enable. This bit enables [...]

  • Page 312

    USART Registers: SPI Mode 14-21 USART Peripheral Interface, SPI Mode UTXIE0 ‡ Bit 1 USART0 transmit interrupt enable. This bit enables the UTXIFG0 interrupt. 0 Interrupt not enabled 1 Interrupt enabled URXIE0 ‡ Bit 0 USART0 receive interrupt enable. This bit enables the URXIFG0 interrupt for USAR T0. 0 Interrupt not enabled 1 Interrupt enabled [...]

  • Page 313

    USART Registers: SPI Mode 14-22 USART Peripheral Interface, SPI Mode IFG1, Interrupt Flag Register 1 76543 210 UTXIFG0 † URXIFG0 † rw−1 rw−0 UTXIFG0 † Bit 7 USART0 transmit interrupt flag. UTXIFG0 is set when U0TXBUF is empty . 0 No interrupt pending 1 Interrupt pending URXIFG0 † Bit 6 USART0 receive interrupt flag. URXIFG0 is set when [...]

  • Page 314

    14-23 USART Peripheral Interface, SPI Mode[...]

  • Page 315

    15-1 USART Peripheral Interface, I 2 C Mode !) " -  .   The universal synchronous/asynchronous receive/transmit (USART) peripheral interface supports I 2 C communication in USART0. This chapter describes the I 2 C mode. The I 2 C mode is implemented on the MSP430x[...]

  • Page 316

    I 2 C Module Introduction 15-2 USART Peripheral Interface, I 2 C Mode 15.1 I 2 C Module Introduction The inter-IC control (I 2 C) module provides an interface between the MSP430 and I 2 C-compatible devices connected by way of the two-wire I 2 C serial bus. External components attached to the I 2 C bus serially transmit and/or receive serial data t[...]

  • Page 317

    I 2 C Module Introduction 15-3 USART Peripheral Interface, I 2 C Mode Figure 15−1. USART Block Diagram: I 2 C Mode Receive Shift Register T ransmit Shift Register SDA I2C Clock Generator I2CEN SCL MST ACLK SMCLK SMCLK 0 1 00 01 10 11 0 1 LISTEN I2CSSELx 1 No clock I2CIN I2CCLK I2CDRW I2CSCLLOW I2CTXUDF I2CRXOVR I2CSBD I2CWORD I2COA I2CSA I2CPSC I[...]

  • Page 318

    I 2 C Module Operation 15-4 USART Peripheral Interface, I 2 C Mode 15.2 I 2 C Module Operation The I 2 C module supports any slave or master I 2 C-compatible device. Figure 15−2 shows an example of an I 2 C bus. Each I 2 C device is recognized by a unique address and can operate as either a transmitter or a receiver . A device connected to the I [...]

  • Page 319

    I 2 C Module Operation 15-5 USART Peripheral Interface, I 2 C Mode 15.2.1 I 2 C Module Initialization The I 2 C module is part of the USART peripheral. Individual bit definitions when using USAR T0 in I 2 C mode are dif ferent from that in SPI or UART mode. The default value for the U0CTL register is the UAR T mode. T o select I 2 C operation th e [...]

  • Page 320

    I 2 C Module Operation 15-6 USART Peripheral Interface, I 2 C Mode 15.2.2 I 2 C Serial Data One clock pulse is generated by the master device for each data bit transferred. The I 2 C module operates with byte data. Data is transferred most significant bit first as shown in Figure 15−3. Th e first byte after a ST ART condition consists of a 7-bit [...]

  • Page 321

    I 2 C Module Operation 15-7 USART Peripheral Interface, I 2 C Mode 15.2.3 I 2 C Addressing Modes The I 2 C module supports 7-bit and 10-bit addressing modes. 7-Bit Addressing In the 7-bit addressing format, shown in Figure 15−5, the first byte is the 7-bit slave address and the R/W bit. The ACK bit is sent from the receiver after each byte. Figur[...]

  • Page 322

    I 2 C Module Operation 15-8 USART Peripheral Interface, I 2 C Mode 15.2.4 I 2 C Module Operating Modes The I 2 C module operates in master transmitter , master receiver , slave transmitter , or slave receiver mode. Master Mode In master mode, transmit and receive operation is controlled with the I2CRM, I2CSTT , and I2CSTP bits as described in T abl[...]

  • Page 323

    I 2 C Module Operation 15-9 USART Peripheral Interface, I 2 C Mode Figure 15−8. Master T ransmitter Mode IDLE Generate ST ART I2CBUSY Is Set 4 x I2CPSC I2CBB Is Set I2CSTT Is Cleared 8 x I2CPSC Send Slave Address Bits 6−0 with R/W=0 8 x SCL 1 Send Slave Address Bits 9−8 Extended with R/W = 0 8 x SCL I2CDR Loaded?* STOP State? STOP State? I2CN[...]

  • Page 324

    I 2 C Module Operation 15-10 USART Peripheral Interface, I 2 C Mode Figure 15−9. Master Receiver Mode IDLE Generate ST ART 4 x I2CPSC I2CBB Is Set I2CSTT Is Cleared 8 x I2CPSC Send Slave Address Bits 6−0 with R/W = 1 8 x SCL Send Slave Address Bits 9−8 Extended With R/W = 0 8 x SCL STOP State? STOP State? I2CNDA T Number Of Bytes Received? Re[...]

  • Page 325

    I 2 C Module Operation 15-1 1 USART Peripheral Interface, I 2 C Mode Arbitration If two or more master transmitters simultaneously start a transmission on the bus, an arbitration procedure is invoked. Figure 15−10 illustrates the arbitration procedure between two devices. The arbitration procedure uses the data presented on SDA by the competing t[...]

  • Page 326

    I 2 C Module Operation 15-12 USART Peripheral Interface, I 2 C Mode Automatic Data Byte Counting Automatic data byte counting is supported in master mode with the I2CNDA T register . When I2CRM = 0, the number of bytes to be received or transmitted is written to I2CNDA T . A STOP condition is automatically generated after I2CNDA T number of bytes h[...]

  • Page 327

    I 2 C Module Operation 15-13 USART Peripheral Interface, I 2 C Mode Figure 15−1 1. Slave T ransmitter I2CBB Is Cleared Send Data Low Byte T o Master 2nd Start Detected? Send Data High Byte T o Master Ack Ack 8 x SCL 8 x SCL STTIFG Is Set I2CBUSY Is Set ST ART Detected? I2CBB Is Set Send Acknowledge 1 x SCL 4 x I2CPSC 8 x SCL IDLE Receive Slave Ad[...]

  • Page 328

    I 2 C Module Operation 15-14 USART Peripheral Interface, I 2 C Mode Figure 15−12. Slave Receiver IDLE I2CBB Is Cleared 4 x I2CPSC Ye s Receive Data Low Byte From Master REST ART Detected ? Send Acknowledge Receive Data High Byte From Master Send Acknowledge 1 x SCL 1 x SCL 8 x SCL 8 x SCL No I2CWORD=0 Byte Mode STTIFG Is Set I2CBUSY Is Set ST ART[...]

  • Page 329

    I 2 C Module Operation 15-15 USART Peripheral Interface, I 2 C Mode 15.2.5 The I 2 C Data Register I2CDR The I2CDR register can be accessed as an 8-bit or 16-bit register selected by the I2CWORD bit. The I2CDR register functions as described in T able 15−2. When I2CWORD = 1, any attempt to modify the register with a byte instruction will fail and[...]

  • Page 330

    I 2 C Module Operation 15-16 USART Peripheral Interface, I 2 C Mode 15.2.6 I 2 C Clock Generation and Synchronization The I 2 C module is operated with the clock source selected by the I2CSSELx bits. The prescaler , I2CPSC, and the I2CSCLH and I2CSCLL registers determine the frequency and duty cycle of the SCL clock signal for master mode as shown [...]

  • Page 331

    I 2 C Module Operation 15-17 USART Peripheral Interface, I 2 C Mode 15.2.7 Using the I 2 C Module with Low Power Modes The I 2 C module can be used with MSP430 low-power modes. When the internal clock source for the I 2 C module is present, the module operates normally regardless of the MSP430 operating mode. When the internal clock source for the [...]

  • Page 332

    I 2 C Module Operation 15-18 USART Peripheral Interface, I 2 C Mode 15.2.8 I 2 C Interrupts The I 2 C module has one interrupt vector for eight interrupt flags listed in T able 15−3. Each interrupt flag has its own interrupt enable bit. When an interrupt is enabled, and the GIE bit is set, the interrupt flag will generate an interrupt request. T [...]

  • Page 333

    I 2 C Module Operation 15-19 USART Peripheral Interface, I 2 C Mode I2CIV , Interrupt V ector Generator The I 2 C interrupt flags are prioritized and combined to source a single interrupt vector . The interrupt vector register I2CIV is used to determine which flag requested an interrupt. The highest priority enabled interrupt generates a number in [...]

  • Page 334

    I 2 C Module Registers 15-20 USART Peripheral Interface, I 2 C Mode 15.3 I 2 C Module Registers The I 2 C module registers are listed in T able 15−4. T able 15−4. I 2 C Registers Register Short Form Register T ype Address Initial State I 2 C interrupt enable I2CIE Read/write 050h Reset with PUC I 2 C interrupt flag I2CIFG Read/write 051h Reset [...]

  • Page 335

    I 2 C Module Registers 15-21 USART Peripheral Interface, I 2 C Mode U0CTL, USART0 Control Register-I 2 C Mode 76543 210 RXDMAEN TXDMAEN I2C XA LISTEN SYNC MST I2CEN rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−1 RXDMAEN Bit 7 Receive DMA enable. This bit enables the DMA controller to be used to transfer data from the I 2 C module after the[...]

  • Page 336

    I 2 C Module Registers 15-22 USART Peripheral Interface, I 2 C Mode I2CTCTL, I 2 C T ransmit Control Register 76543 210 I2CWORD I2CRM I2CSSELx I2CTRX I2CSTB I2CSTP I2CSTT rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 Modifiable only when I2CEN = 0 I2CWORD Bit 7 I 2 C word mode. Selects byte or word mode for the I 2 C data register . 0 Byt[...]

  • Page 337

    I 2 C Module Registers 15-23 USART Peripheral Interface, I 2 C Mode I2CDCTL, I 2 C Data Control Register 76543 210 Unused Unused I2CBUSY I2C SCLLOW I2CSBD I2CTXUDF I2CRXOVR I2CBB r0 r0 r−0 r−0 r−0 r−0 r−0 r−0 Unused Bits 7−6 Unused. Always read as 0. I2CBUSY Bit 5 I 2 C busy 0I 2 C module is idle 1I 2 C module is not idle I2C SCLLOW B[...]

  • Page 338

    I 2 C Module Registers 15-24 USART Peripheral Interface, I 2 C Mode I2CDRW , I2CDRB, I 2 C Data Register 15 14 13 12 1 1 10 9 8 I2CDRW High Byte rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 76543 210 I2CDRW Low Byte I2CDRB rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 I2CDRW/ I2CDRB Bits 15−8 I 2 C Data. When I2CWORD = 1, the[...]

  • Page 339

    I 2 C Module Registers 15-25 USART Peripheral Interface, I 2 C Mode I2CPSC, I 2 C Clock Prescaler Register 76543 210 I2CPSCx rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 Modifiable only when I2CEN = 0 I2CPSCx Bits 7−0 I 2 C clock prescaler . The I 2 C clock input I2CIN is divided by the I2CPSCx value to produce the internal I 2 C clock[...]

  • Page 340

    I 2 C Module Registers 15-26 USART Peripheral Interface, I 2 C Mode I2CSCLH, I 2 C Shift Clock High Register 76543 210 I2CSCLHx rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 Modifiable only when I2CEN = 0 I2CSCLHx Bits 7−0 I 2 C shift clock high. These bits define the high period of SCL when the I 2 C controller is i n master mode. The [...]

  • Page 341

    I 2 C Module Registers 15-27 USART Peripheral Interface, I 2 C Mode I2COA, I 2 C Own Address Register , 7-Bit Addressing Mode 15 14 13 12 1 1 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 76543 210 0 I2COAx r0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 Modifiable only when I2CEN = 0 I2COAx Bits 15-0 I 2 C own address. The I2COA register cont[...]

  • Page 342

    I 2 C Module Registers 15-28 USART Peripheral Interface, I 2 C Mode I2CSA, I 2 C Slave Address Register , 7-Bit Addressing Mode 15 14 13 12 1 1 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 76543 210 0 I2CSAx r0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 I2CSAx Bits 15-0 I 2 C slave address. The I2CSA register contains the slave address of t[...]

  • Page 343

    I 2 C Module Registers 15-29 USART Peripheral Interface, I 2 C Mode I2CIE, I 2 C Interrupt Enable Register 76543 210 STTIE GCIE TXRDYIE RXRDYIE ARDYIE OAIE NACKIE ALIE rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 STTIE Bit 7 ST ART detect interrupt enable 0 Interrupt disabled 1 Interrupt enabled GCIE Bit 6 General call interrupt enable 0[...]

  • Page 344

    I 2 C Module Registers 15-30 USART Peripheral Interface, I 2 C Mode I2CIFG, I 2 C Interrupt Flag Register 76543 210 STTIFG GCIFG TXRDYIFG RXRDYIFG ARDYIFG OAIFG NACKIFG ALIFG rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 STTIFG Bit 7 ST ART detect interrupt flag 0 No interrupt pending 1 Interrupt pending GCIFG Bit 6 General call interrupt[...]

  • Page 345

    I 2 C Module Registers 15-31 USART Peripheral Interface, I 2 C Mode I2CIV , I 2 C Interrupt V ector Register 15 14 13 12 1 1 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 76543 210 0 0 0 I2CIVx 0 r0 r0 r0 r−0 r−0 r−0 r−0 r0 I2CIVx Bits 15-0 I 2 C interrupt vector value I2CIV Contents Interrupt Source Interrupt Flag Interrupt Priority 000h [...]

  • Page 346

    15-32 USART Peripheral Interface, I 2 C Mode[...]

  • Page 347

    16-1 Comparator_A ,) Comparator_A is an analog voltage comparator . This chapter describes Comparator_A. Comparator_A is implemented in MSP430x1 1x1, MSP430x12x, MSP430x13x, MSP430x14x, MSP430x15x and MSP430x16x devices. T opic Page 16.1 Comparator_A Introduction 16-2 . . . . . . . . . . . . . . . . . . . . . . . . . .[...]

  • Page 348

    Comparator_A Introduction 16-2 Comparator_A 16.1 Comparator_A Introduction The comparator_A module supports precision slope analog-to-digital conversions, supply voltage supervision, and monitoring of external analog signals. Features of Comparator_A include: - Inverting and non-inverting terminal input multiplexer - Software selectable RC-filter f[...]

  • Page 349

    Comparator_A Introduction 16-3 Comparator_A Figure 16−1. Comparator_A Block Diagram CAOUT + − CAEX 0.5x 0.25x Set_CAIFG CA1 CCI1B + − 0V G D S P2CA0 P2CA1 CAF CARSEL CAON CAREFx 10 00 01 10 11 00 01 10 11 1 0 1 0 1 0 1 0 1 0 0V 10 V CAREF CA0 0 1 0 1 V CC V CC V CC T au ~ 2.0 m s[...]

  • Page 350

    Comparator_A Operation 16-4 Comparator_A 16.2 Comparator_A Operation The comparator_A module is configured with user software. The setup and operation of comparator_A is discussed in the following sections. 16.2.1 Comparator The comparator compares the analog voltages at the + and – input terminals. If the + terminal is more positive than the –[...]

  • Page 351

    Comparator_A Operation 16-5 Comparator_A 16.2.3 Output Filter The output of the comparator can be used with or without internal filtering. When control bit CAF is set, the output is filtered with an on-chip RC-filter . Any comparator output oscillates if the voltage difference across the input terminals is small. Internal and external parasitic ef [...]

  • Page 352

    Comparator_A Operation 16-6 Comparator_A 16.2.5 Comparator_A, Port Disable Register CAPD Th e comparator input and output functions are multiplexed with the associated I/O port pins, which are digital CMOS gates. When analog signals are applied to digital CMOS gates, parasitic current can flow from V CC to GND. This parasitic current occurs if the [...]

  • Page 353

    Comparator_A Operation 16-7 Comparator_A 16.2.7 Comparator_A Used to Measure Resistive Elements The Comparator_A can be optimized to precisely measure resistive elements using single slope analog-to-digital conversion. For example, temperature can be converted into digital data using a thermistor , b y comparing the thermistor’s capacitor dischar[...]

  • Page 354

    Comparator_A Operation 16-8 Comparator_A The thermistor measurement is based on a ratiometric conversion principle. The ratio of two capacitor discharge times is calculated as shown in Figure 16−6. Figure 16−6. Timing for T emperature Measurement Systems V C V CC 0.25 × V CC Phase I: Charge Phase II: Discharge Phase III: Charge t ref Phase IV [...]

  • Page 355

    Comparator_A Registers 16-9 Comparator_A 16.3 Comparator_A Registers The Comparator_A registers are listed in T able 16−1: T able 16−1. Comparator_A Registers Register Short Form Register T ype Address Initial State Comparator_A control register 1 CACTL1 Read/write 059h Reset with POR Comparator_A control register 2 CACTL2 Read/write 05Ah Reset[...]

  • Page 356

    Comparator_A Registers 16-10 Comparator_A CACTL1, Comparator_A Control Register 1 76543 210 CAEX CARSEL CAREFx CAON CAIES CAIE CAIFG rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) CAEX Bit 7 Comparator_A exchange. This bit exchanges the comparator inputs and inverts the comparator output. CARSEL Bit 6 Comparator_A reference[...]

  • Page 357

    Comparator_A Registers 16-1 1 Comparator_A CACTL2, Comparator_A, Control Register 76543 210 Unused P2CA1 P2CA0 CAF CAOUT rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) r−(0) Unused Bits 7-4 Unused. P2CA1 Bit 3 Pin to CA1. This bit selects the CA1 pin function. 0 The pin is not connected to CA1 1 The pin is connected to CA1 P2CA0 B[...]

  • Page 358

    16-12 Comparator_A[...]

  • Page 359

    17-1 ADC12 )(. The ADC12 module is a high-performance 12-bit analog-to-digital converter . This chapter describes the ADC12. The ADC12 is implemented in the MSP430x13x, MSP430x14x, MSP430x15x, and MSP430x16x devices. T opic Page 17.1 ADC12 Introduction 17-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17[...]

  • Page 360

    ADC12 Introduction 17-2 ADC12 17.1 ADC12 Introduction The ADC12 module supports fast, 12-bit analog-to-digital conversions. The module implements a 12-bit SAR core, sample select control, reference generator and a 16 word conversion-and-control buffer . The conversion-and-control b u f fer allows up to 16 independent ADC samples to be converted and[...]

  • Page 361

    ADC12 Introduction 17-3 ADC12 Figure 17−1. ADC12 Block Diagram Sample and Hold Ve REF+ 12−bit SAR V R− − 16 x 12 Memory Buffer − − 16 x 8 Memory Control − V R+ V REF+ Ve REF− V REF− / ADC12S C TA 1 TB1 TB0 Divider /1 .. /8 ADC12DIVx ADC12CLK ENC MSC SHP SHT0x SAMPCON SHI S/H Convert Sync Sample T imer /4 .. /1024 INCHx 4 A0 A1 A2 [...]

  • Page 362

    ADC12 Operation 17-4 ADC12 17.2 ADC12 Operation Th e ADC12 module is configured with user software. The setup and operation of the ADC12 is discussed in the following sections. 17.2.1 12-Bit ADC Core The ADC core converts an analog input to its 12-bit digital representation and stores the result in conversion memory . The core uses two programmable[...]

  • Page 363

    ADC12 Operation 17-5 ADC12 17.2.2 ADC12 Inputs and Multiplexer Th e eight external and four internal analog signals are selected as the channel for conversion by the analog input multiplexer . The input multiplexer is a break-before-make type to reduce input-to-input noise injection resulting from channel switching as shown in Figure 17−2. The in[...]

  • Page 364

    ADC12 Operation 17-6 ADC12 17.2.3 V oltage Reference Generator The ADC12 module contains a built-in voltage reference with two selectable voltage levels, 1.5 V and 2.5 V . Either of these reference voltages may be used internally and externally on pin V REF+ . Setting REFON=1 enables the internal reference. When REF2_5V = 1, the internal reference [...]

  • Page 365

    ADC12 Operation 17-7 ADC12 17.2.5 Sample and Conversion Timing An analog-to-digital conversion is initiated with a rising edge of the sample input signal SHI. The source for SHI is selected with the SHSx bits and includes the following: - The ADC12SC bit - The T imer_A Output Unit 1 - The T imer_B Output Unit 0 - The T imer_B Output Unit 1 The pola[...]

  • Page 366

    ADC12 Operation 17-8 ADC12 Pulse Sample Mode The pulse sample mode is selected when SHP = 1. The SHI signal is used to trigger the sampling timer . The SHT0x and SHT1x bits in ADC12CTL0 control the interval of the sampling timer that defines the SAMPCON sample period t sample. The sampling timer keeps SAMPCON high after synchronization with AD12CLK[...]

  • Page 367

    ADC12 Operation 17-9 ADC12 Sample Timing Considerations When SAMPCON = 0 all Ax inputs are high impedance. When SAMPCON = 1, the selected Ax input can be modeled as an RC low-pass filter during the sampling time t sample , as shown below in Figure 17−5. An internal MUX-on input resistance R I (max. 2 k Ω ) in series with capacitor C I (max. 40 [...]

  • Page 368

    ADC12 Operation 17-10 ADC12 17.2.6 Conversion Memory There are 16 ADC12MEMx conversion memory registers to store conversion results. Each ADC12MEMx is configured with an associated ADC12MCTLx control register . The SREFx bits define the voltage reference and the INCHx bits select the input channel. The EOS bit defines the end of sequence when a seq[...]

  • Page 369

    ADC12 Operation 17-1 1 ADC12 Single-Channel Single-Conversion Mode A single channel is sampled and converted once. The ADC result is written to the ADC12MEMx defined by the CST AR T ADDx bits. Figure 17−6 shows the flow of the Single-Channel, Single-Conversion mode. When ADC12SC triggers a conversion, successive conversions can be triggered by th[...]

  • Page 370

    ADC12 Operation 17-12 ADC12 Sequence-of-Channels Mode A sequence of channels is sampled and converted once. The ADC results are written to the conversion memories starting with the ADCMEMx defined by the CST ART ADDx bits. The sequence stops after the measurement of the channel with a set EOS bit. Figure 17−7 shows the sequence-of-channels mode. [...]

  • Page 371

    ADC12 Operation 17-13 ADC12 Repeat-Single-Channel Mode A single channel is sampled and converted continuously . The ADC results are written to the ADC12MEMx defined by the CST ART ADDx bits. It is necessary to read the result after the completed conversion because only one ADC12MEMx memory is used and is overwritten by the next conversion. Figure 1[...]

  • Page 372

    ADC12 Operation 17-14 ADC12 Repeat-Sequence-of-Channels Mode A sequence of channels is sampled and converted repeatedly . The ADC results are written to the conversion memories starting with the ADC12MEMx defined b y the CST A RT ADDx bits. The sequence ends after the measurement of the channel with a set EOS bit and the next trigger signal re-star[...]

  • Page 373

    ADC12 Operation 17-15 ADC12 Using the Multiple Sample and Convert (MSC) Bit T o configure the converter to perform successive conversions automatically an d as quickly as possible, a multiple sample and convert function is available. When MSC = 1, CONSEQx > 0, and the sample timer is used, the first rising edge of the SHI signal triggers the fir[...]

  • Page 374

    ADC12 Operation 17-16 ADC12 17.2.8 Using the Integrated T emperature Sensor T o use the on-chip temperature sensor , the user selects the analog input channel INCHx = 1010. Any other configuration is done as if an external channel was selected, including reference selection, conversion-memory selection, etc. The typical temperature sensor transfer [...]

  • Page 375

    ADC12 Operation 17-17 ADC12 17.2.9 ADC12 Grounding and Noise Considerations As with any high-resolution ADC, appropriate printed-circuit-board layout and grounding techniques should be followed to eliminate ground loops, unwanted parasitic effects, and noise. Ground loops are formed when return current from the A/D flows through paths that are comm[...]

  • Page 376

    ADC12 Operation 17-18 ADC12 17.2.10 ADC12 Interrupts The ADC12 has 18 interrupt sources: - ADC12IFG0-ADC12IFG15 - ADC12OV , ADC12MEMx overflow - ADC12TOV , ADC12 conversion time overflow The ADC12IFGx bits are set when their corresponding ADC12MEMx memory register is loaded with a conversion result. An interrupt request is generated if the correspo[...]

  • Page 377

    ADC12 Operation 17-19 ADC12 ADC12 Interrupt Handling Software Example The following software example shows the recommended use of ADC12IV and the handling overhead. The ADC12IV value is added to the PC to automatically jump to the appropriate routine. The numbers at the right margin show the necessary CPU cycles for each instruction. The software o[...]

  • Page 378

    ADC12 Registers 17-20 ADC12 17.3 ADC12 Registers The ADC12 registers are listed in T able 17−2: T able 17−2. ADC12 Registers Register Short Form Register T ype Address Initial State ADC12 control register 0 ADC12CTL0 Read/write 01A0h Reset with POR ADC12 control register 1 ADC12CTL1 Read/write 01A2h Reset with POR ADC12 interrupt flag register [...]

  • Page 379

    ADC12 Registers 17-21 ADC12 ADC12CTL0, ADC12 Control Register 0 15 14 13 12 1 1 10 9 8 SHT1x SHT0x rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 MSC REF2_5V REFON ADC12ON ADC12OVIE ADC12 TOVIE ENC ADC12SC rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) Modifiable only when ENC = 0 SHT1x Bi[...]

  • Page 380

    ADC12 Registers 17-22 ADC12 MSC Bit 7 Multiple sample and conversion. V alid only for sequence or repeated modes. 0 The sampling timer requires a rising edge of the SHI signal to trigger each sample-and-conversion. 1 The first rising edge of the SHI signal triggers the sampling timer , but further sample-and-conversions are performed automatically [...]

  • Page 381

    ADC12 Registers 17-23 ADC12 ADC12CTL1, ADC12 Control Register 1 15 14 13 12 1 1 10 9 8 CST ART ADDx SHSx SHP ISSH rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 ADC12DIVx ADC12SSELx CONSEQx ADC12 BUSY rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) r−(0) Modifiable only when ENC = 0 CST ART ADDx B[...]

  • Page 382

    ADC12 Registers 17-24 ADC12 ADC12 SSELx Bits 4-3 ADC12 clock source select 00 ADC12OSC 01 ACLK 10 MCLK 1 1 SMCLK CONSEQx Bits 2-1 Conversion sequence mode select 00 Single-channel, single-conversion 01 Sequence-of-channels 10 Repeat-single-channel 1 1 Repeat-sequence-of-channels ADC12 BUSY Bit 0 ADC12 busy . This bit indicates an active sample or c[...]

  • Page 383

    ADC12 Registers 17-25 ADC12 ADC12MCTLx, ADC12 Conversion Memory Control Registers 76543 210 EOS SREFx INCHx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) Modifiable only when ENC = 0 EOS Bit 7 End of sequence. Indicates the last conversion in a sequence. 0 Not end of sequence 1 End of sequence SREFx Bits 6-4 Select referen[...]

  • Page 384

    ADC12 Registers 17-26 ADC12 ADC12IE, ADC12 Interrupt Enable Register 15 14 13 12 1 1 10 9 8 ADC12IE15 ADC12IE14 ADC12IE13 ADC12IE12 ADC12IE1 1 ADC12IE10 ADC12IE9 ADC12IE8 rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 ADC12IE7 ADC12IE6 ADC12IE5 ADC12IE4 ADC12IE3 ADC12IE2 ADC12IE1 ADC12IE0 rw−(0) rw−(0) rw−(0[...]

  • Page 385

    ADC12 Registers 17-27 ADC12 ADC12IV , ADC12 Interrupt V ector Register 15 14 13 12 1 1 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 76543 210 0 0 ADC12IVx 0 r0 r0 r−(0) r−(0) r−(0) r−(0) r−(0) r0 ADC12IVx Bits 15-0 ADC12 interrupt vector value ADC12IV Contents Interrupt Source Interrupt Flag Interrupt Priority 000h No interrupt pending [...]

  • Page 386

    17-28 ADC12[...]

  • Page 387

    18-1 ADC10 )(/ The ADC10 module is a high-performance 10-bit analog-to-digital converter . This chapter describes the ADC10. The ADC10 is implemented in the MSP430x1 1x2, MSP430x12x2 devices. T opic Page 18.1 ADC10 Introduction 18-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18.2 ADC10 Operation 18-4 .[...]

  • Page 388

    ADC10 Introduction 18-2 ADC10 18.1 ADC10 Introduction The ADC10 module supports fast, 10-bit analog-to-digital conversions. The module implements a 10-bit SAR core, sample select control, reference generator , and data transfer controller (DTC). The DTC allows ADC10 samples to be converted and stored anywhere in memory without CPU intervention. The[...]

  • Page 389

    ADC10 Introduction 18-3 ADC10 Figure 18−1. ADC10 Block Diagram 1001 1000 0010 0001 001 1 0100 0101 01 10 01 1 1 Sample and Hold 10−bit SAR Divider /1 .. /8 ACLK MCLK SMCLK ADC10SC TA 1 TA 2 TA 0 Data T ransfer Controller RAM, Flash, Peripherials V R− V R+ Ve REF+ V REF+ Ve REF− V REF− / ADC10ON INCHx REFBURST ADC10SSELx ADC10DIVx SHSx ADC[...]

  • Page 390

    ADC10 Operation 18-4 ADC10 18.2 ADC10 Operation Th e ADC10 module is configured with user software. The setup and operation of the ADC10 is discussed in the following sections. 18.2.1 10-Bit ADC Core The ADC core converts an analog input to its 10-bit digital representation and stores the result in the ADC10MEM register . The core uses two programm[...]

  • Page 391

    ADC10 Operation 18-5 ADC10 18.2.2 ADC10 Inputs and Multiplexer Th e eight external and four internal analog signals are selected as the channel for conversion by the analog input multiplexer . The input multiplexer is a break-before-make type to reduce input-to-input noise injection resulting from channel switching as shown in Figure 18−2. The in[...]

  • Page 392

    ADC10 Operation 18-6 ADC10 18.2.3 V oltage Reference Generator The ADC10 module contains a built-in voltage reference with two selectable voltage levels. Setting REFON = 1 enables the internal reference. When REF2_5V = 1, the internal reference is 2.5 V . When REF2_5V = 0, the reference is 1.5 V . The internal reference voltage may be used internal[...]

  • Page 393

    ADC10 Operation 18-7 ADC10 18.2.5 Sample and Conversion Timing An analog-to-digital conversion is initiated with a rising edge of sample input signal SHI. The source for SHI is selected with the SHSx bits and includes the following: - The ADC10SC bit - The T imer_A Output Unit 1 - The T imer_A Output Unit 0 - The T imer_A Output Unit 2 The polarity[...]

  • Page 394

    ADC10 Operation 18-8 ADC10 Sample Timing Considerations When SAMPCON = 0 all Ax inputs are high impedance. When SAMPCON = 1, the selected Ax input can be modeled as an RC low-pass filter during the sampling time t sample , as shown below in Figure 18−4. An internal MUX-on input resistance R I (max. 2 k Ω ) in series with capacitor C I (max. 20 [...]

  • Page 395

    ADC10 Operation 18-9 ADC10 18.2.6 Conversion Modes The ADC10 has four operating modes selected by the CONSEQx bits as discussed in T able 18−1. T able 18−1. Conversion Mode Summary CONSEQx Mode Operation 00 Single channel single-conversion A single channel is converted once. 01 Sequence-of- channels A sequence of channels is converted once. 10 [...]

  • Page 396

    ADC10 Operation 18-10 ADC10 Single-Channel Single-Conversion Mode A single channel selected by INCHx is sampled and converted once. The ADC result is written to ADC10MEM. Figure 18−5 shows the flow of the single-channel, single-conversion mode. When ADC10SC triggers a conversion, successive conversions can be triggered by the ADC10SC bit. When an[...]

  • Page 397

    ADC10 Operation 18-1 1 ADC10 Sequence-of-Channels Mode A sequence of channels is sampled and converted once. The sequence begins with the channel selected by INCHx and decrements to channel A0. Each ADC result is written to ADC10MEM. The sequence stops after conversion of channel A0. Figure 18−6 shows the sequence-of-channels mode. When ADC10SC t[...]

  • Page 398

    ADC10 Operation 18-12 ADC10 Repeat-Single-Channel Mode A single channel selected by INCHx is sampled and converted continuously . Each ADC result is written to ADC10MEM. Figure 18−7 shows the repeat-single-channel mode. Figure 18−7. Repeat-Single-Channel Mode ADC10 Off x = INCHx W ait for Enable ENC = W ait for T rigger ENC = ENC = SHS = 0 and [...]

  • Page 399

    ADC10 Operation 18-13 ADC10 Repeat-Sequence-of-Channels Mode A sequence of channels is sampled and converted repeatedly . The sequence begins with the channel selected by INCHx and decrements to channel A0. Each ADC result is written to ADC10MEM. The sequence ends after conversion of channel A0, and the next trigger signal re-starts the sequence. F[...]

  • Page 400

    ADC10 Operation 18-14 ADC10 Using the MSC Bit T o configure the converter to perform successive conversions automatically an d as quickly as possible, a multiple sample and convert function is available. When MSC = 1 and CONSEQx > 0 the first rising edge of the SHI signal triggers the first conversion. Successive conversions are triggered automa[...]

  • Page 401

    ADC10 Operation 18-15 ADC10 18.2.7 ADC10 Data T ransfer Controller The ADC10 includes a data transfer controller (DTC) to automatically transfer conversion results from ADC10MEM to other on-chip memory locations. The DTC is enabled by setting the ADC10DTC1 register to a nonzero value. When the DTC is enabled, each time the ADC10 completes a convers[...]

  • Page 402

    ADC10 Operation 18-16 ADC10 One-Block T ransfer Mode The one-block mode is selected if the ADC10TB is reset. The value n in ADC10DTC1 defines the total number of transfers for a block. The block start address is defined anywhere in the MSP430 address range using the 16-bit register ADC10SA. The block ends at ADC10SA+2n–2. The one-block transfer m[...]

  • Page 403

    ADC10 Operation 18-17 ADC10 Figure 18−10. State Diagram for Data T ransfer Control in One-Block T ransfer Mode DTC idle DTC reset n=0 (ADC10DTC1) Initialize Start Address in ADC10SA W ait until ADC10MEM is written W ait for CPU ready Write to ADC10MEM completed T ransfer data to Address AD AD = AD + 2 x = x − 1 Synchronize with MCLK 1 x MCLK cy[...]

  • Page 404

    ADC10 Operation 18-18 ADC10 T wo-Block T ransfer Mode The two-block mode is selected if the ADC10TB bit is set. The value n in ADC10DTC1 defines the number of transfers for one block. The address range of the first block is defined anywhere in the MSP430 address range with the 16-bit register ADC10SA. The first block ends at ADC10SA+2n–2. The add[...]

  • Page 405

    ADC10 Operation 18-19 ADC10 Figure 18−12. State Diagram for Data T ransfer Control in T wo-Block T ransfer Mode DTC idle DTC reset ADC10B1 = 0 ADC10TB = 1 n=0 (ADC10DTC1) Initialize Start Address in ADC10SA W ait until ADC10MEM is written W ait for CPU ready Write to ADC10MEM completed T ransfer data to Address AD AD = AD + 2 x = x − 1 Synchron[...]

  • Page 406

    ADC10 Operation 18-20 ADC10 Continuous T ransfer A continuous transfer is selected if ADC10CT bit is set. The DTC will not stop after block one in (one-block mode) or block two (two-block mode) has been transferred. The internal address pointer and transfer counter are set equal to ADC10SA and n respectively . T ransfers continue starting in block [...]

  • Page 407

    ADC10 Operation 18-21 ADC10 18.2.8 Using the Integrated T emperature Sensor T o use the on-chip temperature sensor , the user selects the analog input channel INCHx = 1010. Any other configuration is done as if an external channel was selected, including reference selection, conversion-memory selection, etc. The typical temperature sensor transfer [...]

  • Page 408

    ADC10 Operation 18-22 ADC10 18.2.9 ADC10 Grounding and Noise Considerations As with any high-resolution ADC, appropriate printed-circuit-board layout and grounding techniques should be followed to eliminate ground loops, unwanted parasitic effects, and noise. Ground loops are formed when return current from the A/D flows through paths that are comm[...]

  • Page 409

    ADC10 Operation 18-23 ADC10 18.2.10 ADC10 Interrupts One interrupt and one interrupt vector are associated with the ADC10 as shown in Figure 18−17. When the DTC is not used (ADC10DTC1 = 0) ADC10IFG is set when conversion results are loaded into ADC10MEM. When DTC is used (ADC10DTC1 > 0) ADC10IFG is set when a block transfer completes and the i[...]

  • Page 410

    ADC10 Registers 18-24 ADC10 18.3 ADC10 Registers The ADC10 registers are listed in T able 18−3. T able 18−3. ADC10 Registers Register Short Form Register T ype Address Initial State ADC10 Input enable register ADC10AE Read/write 04Ah Reset with POR ADC10 control register 0 ADC10CTL0 Read/write 01B0h Reset with POR ADC10 control register 1 ADC10[...]

  • Page 411

    ADC10 Registers 18-25 ADC10 ADC10CTL0, ADC10 Control Register 0 15 14 13 12 1 1 10 9 8 SREFx ADC10SHTx ADC10SR REFOUT REFBURST rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 MSC REF2_5V REFON ADC10ON ADC10IE ADC10IFG ENC ADC10SC rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) Modifiable onl[...]

  • Page 412

    ADC10 Registers 18-26 ADC10 MSC Bit 7 Multiple sample and conversion. V alid only for sequence or repeated modes. 0 The sampling requires a rising edge of the SHI signal to trigger each sample-and-conversion. 1 The first rising edge of the SHI signal triggers the sampling timer , but further sample-and-conversions are performed automatically as soo[...]

  • Page 413

    ADC10 Registers 18-27 ADC10 ADC10CTL1, ADC10 Control Register 1 15 14 13 12 1 1 10 9 8 INCHx SHSx ADC10DF ISSH rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 ADC10DIVx ADC10SSELx CONSEQx ADC10 BUSY rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) r−0 Modifiable only when ENC = 0 INCHx Bits 15-12 In[...]

  • Page 414

    ADC10 Registers 18-28 ADC10 ADC10DIVx Bits 7-5 ADC10 clock divider 000 /1 001 /2 010 /3 01 1 /4 100 /5 101 /6 11 0 / 7 111 / 8 ADC10 SSELx Bits 4-3 ADC10 clock source select 00 ADC10OSC 01 ACLK 10 MCLK 1 1 SMCLK CONSEQx Bits 2-1 Conversion sequence mode select 00 Single-channel-single-conversion 01 Sequence-of-channels 10 Repeat-single-channel 1 1 [...]

  • Page 415

    ADC10 Registers 18-29 ADC10 ADC10MEM, Conversion-Memory Register , Binary Format 15 14 13 12 1 1 10 9 8 0 0 0 0 0 0 Conversion Results r0 r0 r0 r0 r0 r0 r r 76543 210 Conversion Results r r r r r r r r Conversion Results Bits 15-0 The 10-bit conversion results are right justified, straight-binary format. Bit 9 is the MSB. Bits 15-10 are always 0. A[...]

  • Page 416

    ADC10 Registers 18-30 ADC10 ADC10DTC0, Data T ransfer Control Register 0 76543 210 Reserved ADC10TB ADC10CT ADC10B1 ADC10 FETCH r0 r0 r0 r0 rw−(0) rw−(0) rw−(0) rw−(0) Reserved Bits 7-4 Reserved. Always read as 0. ADC10TB Bit 3 ADC10 two-block mode. 0 One-block transfer mode 1 T wo-block transfer mode ADC10CT Bit 2 ADC10 continuous transfer[...]

  • Page 417

    ADC10 Registers 18-31 ADC10 ADC10DTC1, Data T ransfer Control Register 1 76543 210 DTC T ransfers rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) DTC T ransfers Bits 7-0 DTC transfers. These bits define the number of transfers in each block. 0 DTC is disabled 01h-0FFh Number of transfers per block ADC10SA, Start Address Regi[...]

  • Page 418

    18-32 ADC10[...]

  • Page 419

    19-1 DAC12 (). Th e DAC12 module is a 12-bit, voltage output digital-to-analog converter . This chapter describes the DAC12. T wo DAC12 modules are implemented in the MSP430x15x and MSP430x16x devices. T opic Page 19.1 DAC12 Introduction 19-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19.2 DAC12 Operat[...]

  • Page 420

    DAC12 Introduction 19-2 DAC12 19.1 DAC12 Introduction The DAC12 module is a 12-bit, voltage output DAC. The DAC12 can be configured in 8 - o r 12-bit mode and may be used in conjunction with the DMA controller . When multiple DAC12 modules are present, they may be grouped together for synchronous update operation. Features of the DAC12 include: - 1[...]

  • Page 421

    DAC12 Introduction 19-3 DAC12 Figure 19−1. DAC12 Block Diagram DAC12_0 DAC12_0OUT 2.5V or 1.5V reference from ADC12 DAC12SREFx V R− V R+ DAC12_0DA T DAC12_0Latch DAC12_1 DAC12LSELx V R− V R+ DAC12_1DA T DAC12_1Latch TB2 TA 1 DAC12DF DAC12RES AV SS 00 01 10 11 00 01 10 11 00 01 10 11 Ve REF+ V REF+ DAC12DF DAC12RES Latch Bypass DAC12LSELx TB2 [...]

  • Page 422

    DAC12 Operation 19-4 DAC12 19.2 DAC12 Operation Th e DAC12 module is configured with user software. The setup and operation of the DAC12 is discussed in the following sections. 19.2.1 DAC12 Core The DAC12 can be configured to operate in 8- or 12-bit mode using the DAC12RES bit. The full-scale output is programmable to be 1x or 3x the selected refer[...]

  • Page 423

    DAC12 Operation 19-5 DAC12 19.2.2 DAC12 Reference The reference for the DAC12 is configured to use either an external reference voltage or the internal 1.5-V/2.5-V reference from the ADC12 module with the DAC12SREFx bits. When DAC12SREFx = {0,1} the V REF+ signal is used as th e reference and when DAC12SREFx = {2,3} the V e REF+ signal is used as t[...]

  • Page 424

    DAC12 Operation 19-6 DAC12 19.2.4 DAC12_xDA T Data Format The DAC12 supports both straight binary and 2’s compliment data formats. When using straight binary data format, the full-scale output value is 0FFFh in 12-bit mode (0FFh in 8-bit mode) as shown in Figure 19−2. Figure 19−2. Output V oltage vs DAC12 Data, 12-Bit, Straight Binary Mode Fu[...]

  • Page 425

    DAC12 Operation 19-7 DAC12 19.2.5 DAC12 Output Amplifier Offset Calibration The offset voltage of the DAC12 output amplifier can be positive or negative. When the of fset is negative, the output amplifier attempts to drive the voltage negative, but cannot do so. The output voltage remains at zero until the DAC12 digital input produces a sufficient [...]

  • Page 426

    DAC12 Operation 19-8 DAC12 19.2.6 Grouping Multiple DAC12 Modules Multiple DAC12s can be grouped together with the DAC12GRP bit to synchronize the update of each DAC12 output. Hardware ensures that all DAC12 modules in a group update simultaneously independent of any interrupt or NMI event. On the MSP430x15x and MSP430x16x devices, DAC12_0 and DAC1[...]

  • Page 427

    DAC12 Operation 19-9 DAC12 19.2.7 DAC12 Interrupts The DAC12 interrupt vector is shared with the DMA controller . Software must check the DAC12IFG and DMAIFG flags to determine the source of the interrupt. The DAC12IFG bit is set when DAC12LSELx > 0 and DAC12 data is latched from the DAC12_xDA T register into the data latch. When DAC12LSELx = 0,[...]

  • Page 428

    DAC12 Registers 19-10 DAC12 19.3 DAC12 Registers The DAC12 registers are listed in T able 19−2: T able 19−2. DAC12 Registers Register Short Form Register T ype Address Initial State DAC12_0 control DAC12_0CTL Read/write 01C0h Reset with POR DAC12_0 data DAC12_0DA T Read/write 01C8h Reset with POR DAC12_1 control DAC12_1CTL Read/write 01C2h Rese[...]

  • Page 429

    DAC12 Registers 19-1 1 DAC12 DAC12_xCTL, DAC12 Control Register 15 14 13 12 1 1 10 9 8 Reserved DAC12SREFx DAC12RES DAC12LSELx DAC12 CALON DAC12IR rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 DAC12AMPx DAC12DF DAC12IE DAC12IFG DAC12ENC DAC12 GRP rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw?[...]

  • Page 430

    DAC12 Registers 19-12 DAC12 DAC12 AMPx Bits 7-5 DAC12 amplifier setting. These bits select settling time vs. current consumption for the DAC12 input and output amplifiers. DAC12AMPx Input Buffer Output Buffer 000 Off DAC12 off, output high Z 001 Off DAC12 off, output 0 V 010 Low speed/current Low speed/current 01 1 Low speed/current Medium speed/cu[...]

  • Page 431

    DAC12 Registers 19-13 DAC12 DAC12_xDA T , DAC12 Data Register 15 14 13 12 1 1 10 9 8 0 0 0 0 DAC12 Data r(0) r(0) r(0) r(0) rw−(0) rw−(0) rw−(0) rw−(0) 76543 210 DAC12 Data rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) Unused Bits 15-12 Unused. These bits are always 0 and do not affect the DAC12 core. DAC12 Data Bi[...]

  • Page 432

    19-14 DAC12[...]