MSP430F2xx, MSP430G2xx Family: User's Guide
MSP430F2xx, MSP430G2xx Family: User's Guide
User’s Guide
Table of Contents
List of Figures
Figure 1-1. MSP430 Architecture.............................................................................................................................................. 24
Figure 1-2. Memory Map........................................................................................................................................................... 25
Figure 1-3. Bits, Bytes, and Words in a Byte-Organized Memory............................................................................................. 26
Figure 2-1. Power-On Reset and Power-Up Clear Schematic.................................................................................................. 30
Figure 2-2. Brownout Timing......................................................................................................................................................31
Figure 2-3. Interrupt Priority.......................................................................................................................................................32
Figure 2-4. Block Diagram of (Non)-Maskable Interrupt Sources..............................................................................................33
Figure 2-5. NMI Interrupt Handler..............................................................................................................................................35
Figure 2-6. Interrupt Processing................................................................................................................................................ 36
Figure 2-7. Return From Interrupt..............................................................................................................................................37
Figure 2-8. Typical Current Consumption of 'F21x1 Devices vs Operating Modes................................................................... 39
Figure 2-9. Operating Modes For Basic Clock System..............................................................................................................40
Figure 3-1. CPU Block Diagram................................................................................................................................................ 45
Figure 3-2. Program Counter.....................................................................................................................................................46
Figure 3-3. Stack Counter..........................................................................................................................................................46
Figure 3-4. Stack Usage............................................................................................................................................................ 46
Figure 3-5. PUSH SP - POP SP Sequence...............................................................................................................................46
Figure 3-6. Status Register Bits.................................................................................................................................................47
Figure 3-7. Register-Byte/Byte-Register Operations................................................................................................................. 48
Figure 3-8. Operand Fetch Operation........................................................................................................................................55
Figure 3-9. Double Operand Instruction Format........................................................................................................................ 58
Figure 3-10. Single Operand Instruction Format....................................................................................................................... 59
Figure 3-11. Jump Instruction Format........................................................................................................................................ 60
Figure 3-12. Core Instruction Map............................................................................................................................................. 63
Figure 3-13. Decrement Overlap............................................................................................................................................... 82
Figure 3-14. Main Program Interrupt....................................................................................................................................... 104
Figure 3-15. Destination Operand – Arithmetic Shift Left........................................................................................................ 105
Figure 3-16. Destination Operand - Carry Left Shift................................................................................................................ 107
Figure 3-17. Destination Operand – Arithmetic Right Shift......................................................................................................109
Figure 3-18. Destination Operand - Carry Right Shift.............................................................................................................. 110
Figure 3-19. Destination Operand - Byte Swap....................................................................................................................... 117
Figure 3-20. Destination Operand - Sign Extension.................................................................................................................118
Figure 4-1. MSP430X CPU Block Diagram............................................................................................................................. 123
Figure 4-2. PC Storage on the Stack for Interrupts................................................................................................................. 124
Figure 4-3. Program Counter...................................................................................................................................................125
Figure 4-4. PC Storage on the Stack for CALLA..................................................................................................................... 125
Figure 4-5. Stack Pointer......................................................................................................................................................... 126
Figure 4-6. Stack Usage.......................................................................................................................................................... 126
Figure 4-7. PUSHX.A Format on the Stack............................................................................................................................. 126
Figure 4-8. PUSH SP, POP SP Sequence...............................................................................................................................126
Figure 4-9. SR Bits.................................................................................................................................................................. 127
Figure 4-10. Register-Byte/Byte-Register Operation............................................................................................................... 129
Figure 4-11. Register-Word Operation.....................................................................................................................................129
Figure 4-12. Word-Register Operation.....................................................................................................................................130
List of Tables
Table 1-1. MSP430x2xx Family Enhancements........................................................................................................................ 27
Table 2-1. Interrupt Sources, Flags, and Vectors.......................................................................................................................38
Table 2-2. Operating Modes For Basic Clock System............................................................................................................... 40
Table 2-3. Connection of Unused Pins...................................................................................................................................... 42
Table 3-1. Description of Status Register Bits........................................................................................................................... 47
Table 3-2. Values of Constant Generators CG1, CG2............................................................................................................... 47
Table 3-3. Source and Destination Operand Addressing Modes...............................................................................................49
Table 3-4. Register Mode Description........................................................................................................................................50
Table 3-5. Indexed Mode Description........................................................................................................................................ 51
Table 3-6. Symbolic Mode Description...................................................................................................................................... 52
Table 3-7. Absolute Mode Description....................................................................................................................................... 53
Table 3-8. Indirect Mode Description......................................................................................................................................... 54
Table 3-9. Indirect Autoincrement Mode Description................................................................................................................. 55
Table 3-10. Immediate Mode Description.................................................................................................................................. 56
Table 3-11. Double Operand Instructions...................................................................................................................................58
Table 3-12. Single Operand Instructions....................................................................................................................................59
Table 3-13. Jump Instructions....................................................................................................................................................60
Table 3-14. Interrupt and Reset Cycles..................................................................................................................................... 61
Table 3-15. Format-II Instruction Cycles and Lengths............................................................................................................... 61
Table 3-16. Format 1 Instruction Cycles and Lengths............................................................................................................... 62
Table 3-17. MSP430 Instruction Set.......................................................................................................................................... 63
Table 4-1. SR Bit Description...................................................................................................................................................127
Table 4-2. Values of Constant Generators CG1, CG2............................................................................................................. 128
Table 4-3. Source/Destination Addressing...............................................................................................................................131
Table 4-4. MSP430 Double-Operand Instructions................................................................................................................... 147
Table 4-5. MSP430 Single-Operand Instructions.....................................................................................................................147
Table 4-6. Conditional Jump Instructions.................................................................................................................................148
Table 4-7. Emulated Instructions............................................................................................................................................. 148
Table 4-8. Interrupt, Return, and Reset Cycles and Length.....................................................................................................149
Table 4-9. MSP430 Format II Instruction Cycles and Length.................................................................................................. 149
Table 4-10. MSP430 Format I Instructions Cycles and Length................................................................................................150
Table 4-11. Description of the Extension Word Bits for Register Mode................................................................................... 151
Table 4-12. Description of Extension Word Bits for Non-Register Modes................................................................................152
Table 4-13. Extended Double-Operand Instructions................................................................................................................154
Table 4-14. Extended Single-Operand Instructions................................................................................................................. 156
Table 4-15. Extended Emulated Instructions........................................................................................................................... 158
Table 4-16. Address Instructions, Operate on 20-Bit Register Data........................................................................................ 159
Table 4-17. MSP430X Format II Instruction Cycles and Length.............................................................................................. 160
Table 4-18. MSP430X Format I Instruction Cycles and Length............................................................................................... 161
Table 4-19. Address Instruction Cycles and Length................................................................................................................ 162
Table 4-20. Instruction Map of MSP430X................................................................................................................................ 163
Table 5-1. Basic Clock Module+ Registers.............................................................................................................................. 285
Preface
Read This First
Chapter 1
Introduction
1.1 Architecture................................................................................................................................................................ 24
1.2 Flexible Clock System................................................................................................................................................24
1.3 Embedded Emulation.................................................................................................................................................25
1.4 Address Space............................................................................................................................................................25
1.5 MSP430x2xx Family Enhancements.........................................................................................................................27
1.1 Architecture
The 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) (see Figure 1-1). Partnering
a modern CPU with modular memory-mapped analog and digital peripherals, the MSP430 offers solutions for
demanding mixed-signal applications.
Key features of the MSP430x2xx family include:
• Ultralow-power architecture extends battery life
– 0.1 µA RAM retention
– 0.8 µA real-time clock mode
– 250 µA/MIPS active
• High-performance analog ideal for precision measurement
– Comparator-gated timers for measuring resistive elements
• 16-bit RISC CPU enables new applications at a fraction of the code size.
– Large register file eliminates working file bottleneck
– Compact core design reduces power consumption and cost
– Optimized for modern high-level programming
– Only 27 core instructions and seven addressing modes
– Extensive vectored-interrupt capability
• In-system programmable Flash permits flexible code changes, field upgrades and data logging
MCLK
MAB 16-Bit
JTAG/Debug
RISC CPU
16-Bit
JTAG
ACLK
SMCLK Watchdog Peripheral Peripheral Peripheral Peripheral
1FFFFh
Flash/ROM Word/Byte
10000h
0FFFFh
Interrupt Vector Table Word/Byte
0FFE0h
0FFDFh
Flash/ROM Word/Byte
RAM Word/Byte
0200h
01FFh
Word
16-Bit Peripheral Modules
0100h
0FFh
8-Bit Peripheral Modules Byte
010h
0Fh
Special Function Registers Byte
0h
1.4.1 Flash/ROM
The start address of Flash/ROM depends on the amount of Flash/ROM present and varies by device. The end
address for Flash/ROM is 0x0FFFF for devices with less that 60KB of Flash/ROM. Flash can be used for both
code and data. Word or byte tables can be stored and used in Flash/ROM without the need to copy the tables to
RAM before using them.
The interrupt vector table is mapped into the upper 16 words of Flash/ROM address space, with the highest
priority interrupt vector at the highest Flash/ROM word address (0x0FFFE).
1.4.2 RAM
RAM starts at 0200h. The end address of RAM depends on the amount of RAM present and varies by device.
RAM can be used for both code and data.
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 always 0.
The address space from 010h to 0FFh is reserved for 8-bit peripheral modules. These modules should be
accessed with byte instructions. Read access of byte modules using word instructions results in unpredictable
data in the high byte. If word data is written to a byte module only the low byte is written into the peripheral
register, ignoring the high byte.
1.4.4 Special Function Registers (SFRs)
Some peripheral functions are configured in the SFRs. The SFRs are located in the lower 16 bytes of the
address space, and are organized by byte. SFRs must be accessed using byte instructions only. See the
device-specific data sheets for applicable SFR bits.
1.4.5 Memory Organization
Bytes are located at even or odd addresses. Words are only located at even addresses as shown in Figure 1-3.
When using word instructions, only even addresses may be used. The low byte of a word is always an even
address. The high byte is at the next odd address. For example, if a data word is located at address xxx4h, then
the low byte of that data word is located at address xxx4h, and the high byte of that word is located at address
xxx5h.
xxxAh
15 14 . . Bits . . 9 8 xxx9h
7 6 . . Bits . . 1 0 xxx8h
Byte xxx7h
Byte xxx6h
xxx3h
• All MSP430x2xx devices integrate the Watchdog Timer+ module (WDT+). The WDT+ ensures the
Watchdog Timer clock source for the timer is never disabled.
Comparator_A • Comparator_A has expanded input capability with a new input multiplexer.
Chapter 2
System Resets, Interrupts, and Operating Modes
This chapter describes the MSP430x2xx system resets, interrupts, and operating modes.
Brownout
Reset POR
S Latch POR
R
0V ~50 µs
Delay
SVS_POR‡
RST/NMI
WDTNMI†
S
WDTTMSEL
WDTQn† S
Resetwd1 PUC
WDTIFG† S Latch
PUC
S
Resetwd2 S
EQU†
KEYV R
(from flash module)
Invalid instruction fetch
MCLK
† From watchdog timer peripheral module
‡ Devices with SVS only
A POR is a device reset. A POR is only generated by the following three events:
• Powering up the device
• A low signal on the RST/NMI pin when configured in the reset mode
• An SVS low condition when PORON = 1.
A PUC is always generated when a POR is generated, but a POR is not generated by a PUC. The following
events trigger a PUC:
• A POR signal
• Watchdog timer expiration when in watchdog mode only
• Watchdog timer security key violation
• A Flash memory security key violation
• A CPU instruction fetch from the peripheral address range 0h to 01FFh
2.1.1 Brownout Reset (BOR)
The brownout reset circuit detects low supply voltages such as when a supply voltage is applied to or removed
from the VCC terminal. The brownout reset circuit resets the device by triggering a POR signal when power is
applied or removed. The operating levels are shown in Figure 2-2.
The POR signal becomes active when VCC crosses the VCC(start) level. It remains active until VCC crosses the
V(B_IT+) threshold and the delay t(BOR) elapses. The delay t(BOR) is adaptive being longer for a slow ramping VCC.
The hysteresis Vhys(B_ IT-) ensures that the supply voltage must drop below V(B_IT-) to generate another POR
signal from the brownout reset circuitry.
VCC
Vhys(B_IT−)
V(B_IT+)
V(B_IT−)
VCC(start)
t
(BOR)
As the V(B_IT-) level is significantly above the Vmin level of the POR circuit, the BOR provides a reset for power
failures where VCC does not fall below Vmin. See device-specific data sheet for parameters.
2.1.2 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 registers are initialized as described in their respective chapters in this manual.
• Status register (SR) is reset.
• The watchdog timer powers up active in watchdog mode.
• Program counter (PC) is loaded with address contained at reset vector location (0FFFEh). If the reset vectors
content is 0FFFFh the device will be disabled for minimum power consumption.
2.1.2.1 Software Initialization
After a system reset, user software must initialize the MSP430 for the application requirements. The following
must occur:
• Initialize the SP, typically to the top of RAM.
• Initialize the watchdog to the requirements of the application.
• Configure peripheral modules to the requirements of the application.
Additionally, the watchdog timer, oscillator fault, and flash memory flags can be evaluated to determine the
source of the reset.
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-3. The nearer a module is to the CPU/NMIRS, the higher the priority. Interrupt priorities
determine what interrupt is taken when more than one interrupt is pending simultaneously.
There are three types of interrupts:
• System reset
• (Non)-maskable NMI
• Maskable
Priority High Low
GMIRS
GIE
Module Module WDT Module Module
CPU
NMIRS 1 2 Timer m n
1 2 1 2 1 2 1 2 1
PUC Bus
Grant
PUC
OSCfault
Circuit
Flash ACCV
Reset/NMI
ACCV
ACCVIFG
S POR
FCTL3.2
S
PORIFG
ACCVIE
IFG1.2
IE1.5
Clear
PUC
RST/NMI Flash Module
S
RSTIFG POR PUC
IFG1.3
Clear
KEYV SVS_POR BOR
POR
PUC
System Reset
Generator
POR
NMIIFG
S
NMIRS
IFG1.4
WDTTMSEL
Clear
WDTNMIES WDTNMI WDTQn EQU PUC POR
PUC
NMIIE
WDTIFG
S
IE1.4 IR
Clear IFG1.0 Q
Clear
PUC WDT
Counter
OSCFault POR
OFIFG
S
IFG1.1
IRQA
WDTTMSEL
OFIE
WDTIE
IE1.1
Clear
IE1.0
NMI_IRQA Clear
PUC
Note
Holding RST/NMI Low
When configured in the NMI mode, a signal generating an NMI event should not hold the RST/NMI pin
low. If a PUC occurs from a different source while the NMI signal is low, the device will be held in the
reset state because a PUC changes the RST/NMI pin to the reset function.
Note
Modifying WDTNMIES
When NMI mode is selected and the WDTNMIES bit is changed, an NMI can be generated,
depending on the actual level at the RST/NMI pin. When the NMI edge select bit is changed before
selecting the NMI mode, no NMI is generated.
no no no
OFIFG=1 ACCVIFG=1 NMIIFG=1
Optional
RETI
End of NMI Interrupt
Handler
Note
Enabling NMI Interrupts with ACCVIE, NMIIE, and OFIE
To prevent nested NMI interrupts, the ACCVIE, NMIIE, and OFIE enable bits should not be set inside
of an NMI interrupt service routine.
Item1 Item1
SP Item2 TOS Item2
PC
SP SR TOS
Item1 Item1
Item2 SP Item2 TOS
PC PC
SP SR TOS SR
200
225
VCC = 3 V
180
VCC = 2.2 V
135
90 55 32
45
17 11 0.9 0.7 0.1 0.1
0
AM LPM0 LPM2 LPM3 LPM4
Operating Modes
The low-power modes 0 to 4 are configured with the CPUOFF, OSCOFF, SCG0, and SCG1 bits in the status
register The advantage of including the CPUOFF, OSCOFF, SCG0, and SCG1 mode-control bits in the status
register is that the present operating mode is saved onto the stack during an interrupt service routine. Program
flow returns to the previous operating mode if the saved SR value is not altered during the interrupt service
routine. Program flow can be returned to a different operating mode by manipulating the saved SR value on
the stack inside of the interrupt service routine. The mode-control bits and the stack can be accessed with any
instruction.
When setting any of the mode-control bits, the selected operating mode takes effect immediately (see Figure
2-9). Peripherals operating with any disabled clock are disabled until the clock becomes active. The peripherals
may also be disabled with their individual control register settings. All I/O port pins and RAM/registers are
unchanged. Wake up is possible through all enabled interrupts.
RST/NMI
SVS_POR
Reset Active
POR
WDT
Time Expired, Overflow WDTIFG = 1 WDTIFG = 0
Active Mode
CPUOFF = 1 CPU Is Active CPUOFF = 1
SCG0 = 0 Peripheral Modules Are Active OSCOFF = 1
SCG1 = 0 SCG0 = 1
SCG1 = 1
LPM0
LPM4
CPU Off, MCLK Off,
CPU Off, MCLK Off, DCO
SMCLK On, ACLK On
Off, SMCLK Off,
ACLK Off
CPUOFF = 1
SCG0 = 1 DC Generator Off
CPUOFF = 1
SCG1 = 0 SCG0 = 1
CPUOFF = 1
SCG0 = 0 SCG1 = 1
LPM1 LPM3
CPU Off, MCLK Off, SCG1 = 1
CPU Off, MCLK Off, SMCLK
DCO off, SMCLK On, Off, DCO Off, ACLK On
ACLK On LPM2
CPU Off, MCLK Off, SMCLK
DC Generator Off if DCO Off, DCO Off, ACLK On DC Generator Off
not used for SMCLK
(1) The pulldown capacitor must not exceed 2.2 nF when using devices with Spy-Bi-Wire interface in Spy-Bi-Wire mode or in 4-wire JTAG
mode with TI tools like FET interfaces or GANG programmers.
Chapter 3
CPU
This chapter describes the MSP430 CPU, addressing modes, and instruction set.
15 0
R2/SR/CG1 Status
R4 General Purpose
R5 General Purpose
R6 General Purpose
R7 General Purpose
R8 General Purpose
R9 General Purpose
The PC can be addressed with all instructions and addressing modes. A few examples:
MOV #LABEL,PC ; Branch to address LABEL
MOV LABEL,PC ; Branch to address contained in LABEL
MOV @R14,PC ; Branch indirect to address in R14
0xxxh I1 I1 I1
0xxxh − 2 I2 I2 I2
0xxxh − 4 I3 SP I3 I3 SP
0xxxh − 6 0123h SP 0123h
0xxxh − 8
The special cases of using the SP as an argument to the PUSH and POP instructions are described and shown
in Figure 3-5.
PUSH SP POP SP
SPold
SP1 SP1 SP2 SP1
The stack pointer is changed after The stack pointer is not changed after a POP SP
a PUSH SP instruction. instruction. The POP SP instruction places SP1 into the
stack pointer SP (SP2=SP1)
is replaced by:
ADD 0(R3),dst
08Fh 05Fh
The seven addressing modes are explained in detail in the following sections. Most of the examples show the
same addressing mode for the source and destination, but any valid combination of source and destination
addressing modes is possible in an instruction.
Note
Use of Labels EDE, TONI, TOM, and LEO
Throughout MSP430 documentation EDE, TONI, TOM, and LEO are used as generic labels. They are
only labels. They have no special meaning.
Before: After:
PC PCold PC PCold + 2
Note
Data in Registers
The data in the register can be accessed using word or byte instructions. If byte instructions are used,
the high byte is always 0 in the result. The status bits are handled according to the result of the byte
instructions.
Before: After:
Address Register Address Register
Space Space
0xxxxh PC
0FF16h 00006h R5 01080h 0FF16h 00006h R5 01080h
0FF14h 00002h R6 0108Ch 0FF14h 00002h R6 0108Ch
0FF12h 04596h PC 0FF12h 04596h
0108Ch
01094h 0xxxxh +0006h 01094h 0xxxxh
01092h
01092h 05555h 01092h 01234h
01090h 0xxxxh 01090h 0xxxxh
01080h
01084h 0xxxxh +0002h 01084h 0xxxxh
01082h
01082h 01234h 01082h 01234h
01080h 0xxxxh 01080h 0xxxxh
Before: After:
Address Register Address Register
Space Space
0xxxxh PC
0FF16h 011FEh 0FF16h 011FEh
0FF14h 0F102h 0FF14h 0F102h
0FF12h 04090h PC 0FF12h 04090h
0FF14h
0F018h 0xxxxh +0F102h 0F018h 0xxxxh
0F016h
0F016h 0A123h 0F016h 0A123h
0F014h 0xxxxh 0F014h 0xxxxh
0FF16h
01116h 0xxxxh +011FEh 01116h 0xxxxh
01114h
01114h 05555h 01114h 0A123h
01112h 0xxxxh 01112h 0xxxxh
Before: After:
Address Register Address Register
Space Space
0xxxxh PC
0FF16h 01114h 0FF16h 01114h
0FF14h 0F016h 0FF14h 0F016h
0FF12h 04292h PC 0FF12h 04292h
This address mode is mainly for hardware peripheral modules that are located at an absolute, fixed address.
These are addressed with absolute mode to ensure software transportability (for example, position-independent
code).
Before: After:
Address Register Address Register
Space Space
0xxxxh 0xxxxh PC
0FF16 0000h R10 0FA33h 0FF16h 0000h R10 0FA33h
h
0FF14h 04AEBh PC R11 002A7h 0FF14h 04AEBh R11 002A7h
0FF12h 0xxxxh 0FF12h 0xxxxh
Before: After:
Address Register Address Register
Space Space
The auto-incrementing of the register contents occurs after the operand is fetched. This is shown in Figure 3-8.
+1/ +2
Before: After:
Address Register Address Register
Space Space
0FF18h 0xxxxh PC
0FF16h 01192h 0FF16h 01192h
0FF14h 00045h 0FF14h 00045h
0FF12h 040B0h PC 0FF12h 040B0h
0FF16h
010AAh 0xxxxh +01192h 010AAh 0xxxxh
010A8h
010A8h 01234h 010A8h 00045h
010A6h 0xxxxh 010A6h 0xxxxh
Note
Destination Address
Destination addresses are valid anywhere in the memory map. However, when using an instruction
that modifies the contents of the destination, the user must ensure the destination address is writable.
For example, a masked-ROM location would be a valid destination address, but the contents are not
modifiable, so the results of the instruction would be lost.
Note
Instructions CMP and SUB
The instructions CMP and SUB are identical except for the storage of the result. The same is true for
the BIT and AND instructions.
All addressing modes are possible for the CALL instruction. If the symbolic mode (ADDRESS), the immediate
mode (#N), the absolute mode (&EDE) or the indexed mode x(RN) is used, the word that follows contains the
address information.
3.4.3 Jumps
Figure 3-11 shows the conditional-jump instruction format.
Figure 3-11. Jump Instruction Format
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Op-code C 10-Bit PC Offset
Conditional jumps support program branching relative to the PC and do not affect the status bits. The possible
jump range is from –511 to +512 words relative to the PC value at the jump instruction. The 10-bit program-
counter offset is treated as a signed 10-bit value that is doubled and added to the program counter:
PCnew = PCold + 2 + PCoffset × 2
Note
Instruction Format II Immediate Mode
Do not use instruction RRA , RRC , SWPB , and SXT with the immediate mode in the destination field.
Use of these in the immediate mode results in an unpredictable program operation.
000 040 080 0C0 100 140 180 1C0 200 240 280 2C0 300 340 380 3C0
0xxx
4xxx
8xxx
Cxxx
1xxx RRC RRC.B SWPB RRA RRA.B SXT PUSH PUSH.B CALL RETI
14xx
18xx
1Cxx
20xx JNE/JNZ
24xx JEQ/JZ
28xx JNC
2Cxx JC
30xx JN
34xx JGE
38xx JL
3Cxx JMP
4xxx MOV, MOV.B
5xxx ADD, ADD.B
6xxx ADDC, ADDC.B
7xxx SUBC, SUBC.B
8xxx SUB, SUB.B
9xxx CMP, CMP.B
Axxx DADD, DADD.B
Bxxx BIT, BIT.B
Cxxx BIC, BIC.B
Dxxx BIS, BIS.B
Exxx XOR, XOR.B
Fxxx AND, AND.B
Syntax
ADC dst or ADC.W dst
ADC.B 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.
Example The 16-bit counter pointed to by R13 is added to a 32-bit counter pointed to by R12.
ADD @R13,0(R12) ; Add LSDs
ADC 2(R12) ; Add carry to MSD
Example The 8-bit counter pointed to by R13 is added to a 16-bit counter pointed to by R12.
ADD.B @R13,0(R12) ; Add LSDs
ADC.B 1(R12) ; Add carry to MSD
3.4.6.2 ADD
Syntax
ADD src,dst or ADD.W src,dst
ADD.B src,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 Bits N: Set if result is negative, reset if positive
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the result, cleared if not
V:Set if an arithmetic overflow occurs, otherwise reset
3.4.6.3 ADDC
Syntax
ADDC src,dst or ADDC.W src,dst
ADDC.B src,dst
Description The source operand and the carry bit (C) are added to the destination operand. The
source operand is not affected. The previous contents of the destination are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the MSB of the result, reset otherwise
V: Set if an arithmetic overflow occurs, otherwise reset
Example The 32-bit counter pointed to by R13 is added to a 32-bit counter, eleven words
(20/2 + 2/2) above the pointer in R13.
ADD @R13+,20(R13) ; ADD LSDs with no carry in
ADDC @R13+,20(R13) ; ADD MSDs with carry
... ; resulting from the LSDs
Example The 24-bit counter pointed to by R13 is added to a 24-bit counter, eleven words above the
pointer in R13.
ADD.B @R13+,10(R13) ; ADD LSDs with no carry in
ADDC.B @R13+,10(R13) ; ADD medium Bits with carry
ADDC.B @R13+,10(R13) ; ADD MSDs with carry
... ; resulting from the LSDs
3.4.6.4 AND
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.
Example The bits set in R5 are used as a mask (#0AA55h) for the word addressed by TOM. If the
result is zero, a branch is taken to label TONI.
MOV #0AA55h,R5 ; Load mask into register R5
AND R5,TOM ; mask word addressed by TOM with R5
JZ TONI ;
...... ; Result is not zero
;
;
; or
;
;
AND #0AA55h,TOM
JZ TONI
Example The bits of mask #0A5h are logically ANDed with the low byte TOM. If the result is zero, a
branch is taken to label TONI.
AND.B #0A5h,TOM ; mask Lowbyte TOM with 0A5h
JZ TONI ;
...... ; Result is not zero
3.4.6.5 BIC
Syntax
BIC src,dst or BIC.W src,dst
BIC.B src,dst
Description The inverted source operand and the destination operand are logically ANDed. The result
is placed into the destination. The source operand is not affected.
Status Bits Status bits are not affected.
Example The six MSBs of the RAM word LEO are cleared.
BIC #0FC00h,LEO ; Clear 6 MSBs in MEM(LEO)
Example The five MSBs of the RAM byte LEO are cleared.
BIC.B #0F8h,LEO ; Clear 5 MSBs in Ram location LEO
3.4.6.6 BIS
Syntax
BIS src,dst or BIS.W src,dst
BIS.B src,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 Bits Status bits are not affected.
Example The six LSBs of the RAM word TOM are set.
BIS #003Fh,TOM ; set the six LSBs in RAM location TOM
3.4.6.7 BIT
Syntax
BIT src,dst or BIT.W src,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 if MSB of result is set, reset otherwise
Z: Set if result is zero, reset otherwise
C: Set if result is not zero, reset otherwise (.NOT. Zero)
V: Reset
Example A serial communication receive bit (RCV) is tested. Because the carry bit is equal to the
state of the tested bit while using the BIT instruction to test a single bit, the carry bit is
used by the subsequent instruction; the read information is shifted into register RECBUF.
;
; Serial communication with LSB is shifted first:
; xxxx xxxx xxxx xxxx
BIT.B #RCV,RCCTL ; Bit info into carry
RRC RECBUF ; Carry -> MSB of RECBUF
; cxxx xxxx
...... ; repeat previous two instructions
...... ; 8 times
; cccc cccc
; ^ ^
; MSB LSB
; Serial communication with MSB shifted first:
BIT.B #RCV,RCCTL ; Bit info into carry
RLC.B RECBUF ; Carry -> LSB of RECBUF
; xxxx xxxc
...... ; repeat previous two instructions
...... ; 8 times
; cccc cccc
; |
; MSB LSB
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.
3.4.6.9 CALL
CALL Subroutine
Syntax
CALL dst
3.4.6.10 CLR
Syntax
CLR dst or CLR.W dst
CLR.B dst
Operation 0 → dst
Emulation
MOV #0,dst
MOV.B #0,dst
3.4.6.11 CLRC
Syntax
CLRC
Operation 0→C
Emulation
BIC #1,SR
Description The carry bit (C) is cleared. The clear carry instruction is a word instruction.
3.4.6.12 CLRN
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 instruction.
Example The Negative bit in the status register is cleared. This avoids special treatment with
negative numbers of the subroutine called.
CLRN
CALL SUBR
......
......
SUBR JN SUBRET ; If input is negative: do nothing and return
......
......
......
SUBRET RET
3.4.6.13 CLRZ
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.
3.4.6.14 CMP
Syntax
CMP src,dst or CMP.W src,dst
CMP.B src,dst
Description The source operand is subtracted from the destination operand. This is accomplished
by adding the 1s complement of the source operand plus 1. The two operands are not
affected and the result is not stored; only the status bits are affected.
Status Bits N: Set if result is negative (src > dst), reset if positive (src ≤ dst)
Z: Set if result is zero (src = dst), reset otherwise (src ≠ dst)
C: Set if there is a carry from the MSB of the result, reset otherwise
V: Set if an arithmetic overflow occurs, otherwise reset
Example R5 and R6 are compared. If they are equal, the program continues at the label EQUAL.
CMP R5,R6 ; R5 = R6?
JEQ EQUAL ; YES, JUMP
Example Two RAM blocks are compared. If they are not equal, the program branches to the label
ERROR.
MOV #NUM,R5 ; number of words to be compared
MOV #BLOCK1,R6 ; BLOCK1 start address in R6
MOV #BLOCK2,R7 ; BLOCK2 start address in R7
L$1 CMP @R6+,0(R7) ; Are Words equal? R6 increments
JNZ ERROR ; No, branch to ERROR
INCD R7 ; Increment R7 pointer
DEC R5 ; Are all words compared?
JNZ L$1 ; No, another compare
Example The RAM bytes addressed by EDE and TONI are compared. If they are equal, the
program continues at the label EQUAL.
CMP.B EDE,TONI ; MEM(EDE) = MEM(TONI)?
JEQ EQUAL ; YES, JUMP
3.4.6.15 DADC
Syntax
DADC dst or DADC.W src,dst
DADC.B dst
Emulation
DADD #0,dst
DADD.B #0,dst
Example The four-digit decimal number contained in R5 is added to an eight-digit decimal number
pointed to by R8.
CLRC ; Reset carry
; next instruction's start condition is defined
DADD R5,0(R8) ; Add LSDs + C
DADC 2(R8) ; Add carry to MSD
Example The two-digit decimal number contained in R5 is added to a four-digit decimal number
pointed to by R8.
CLRC ; Reset carry
; next instruction's start condition is defined
DADD.B R5,0(R8) ; Add LSDs + C
DADC.B 1(R8) ; Add carry to MSDs
3.4.6.16 DADD
Syntax
DADD src,dst or DADD.W src,dst
DADD.B src,dst
Description The source operand and the destination operand are treated as four binary coded
decimals (BCD) with positive signs. The source operand and the carry bit (C)are added
decimally to the destination operand. The source operand is not affected. The previous
contents of the destination are lost. The result is not defined for non-BCD numbers.
Status Bits N: Set if the MSB is 1, reset otherwise
Z: Set if result is zero, reset otherwise
C: Set if the result is greater than 9999
Set if the result is greater than 99
V: Undefined
Example The eight-digit BCD number contained in R5 and R6 is added decimally to an eight-digit
BCD number contained in R3 and R4 (R6 and R4 contain the MSDs).
CLRC ; clear carry
DADD R5,R3 ; add LSDs
DADD R6,R4 ; add MSDs with carry
JC OVERFLOW ; If carry occurs go to error handling routine
Example The two-digit decimal counter in the RAM byte CNT is incremented by one.
CLRC ; clear carry
DADD.B #1,CNT
or
SETC
DADD.B #0,CNT ; equivalent to DADC.B CNT
3.4.6.17 DEC
Syntax
DEC dst or DEC.W dst
DEC.B dst
Emulation
SUB #1,dst
SUB.B #1,dst
Description The destination operand is decremented by one. The original contents are lost.
Do not transfer tables using the routine above with the overlap shown in Figure 3-13.
(continued)
EDE
TONI
EDE+254
TONI+254
3.4.6.18 DECD
Syntax
DECD dst or DECD.W dst
DECD.B dst
Emulation
SUB #2,dst
Emulation
SUB.B #2,dst
Description The destination operand is decremented by two. The original contents are lost.
3.4.6.19 DINT
Syntax
DINT
Operation 0 → GIE
or
(0FFF7h .AND. SR → SR / .NOT.src .AND. dst → dst)
Emulation
BIC #8,SR
Mode Bits GIE is reset. OSCOFF and CPUOFF are not affected.
Example The general interrupt enable (GIE) bit in the status register is cleared to allow a
nondisrupted move of a 32-bit counter. This ensures that the counter is not modified
during the move by any interrupt.
DINT ; All interrupt events using the GIE bit are disabled
NOP
MOV COUNTHI,R5 ; Copy counter
MOV COUNTLO,R6
EINT ; All interrupt events using the GIE bit are enabled
Note
Disable Interrupt
If any code sequence needs to be protected from interruption, the DINT should
be executed at least one instruction before the beginning of the uninterruptible
sequence, or should be followed by a NOP instruction.
3.4.6.20 EINT
Syntax
EINT
Operation 1 → GIE
or
(0008h .OR. SR → SR / .src .OR. dst → dst)
Emulation
BIS #8,SR
Mode Bits GIE is set. OSCOFF and CPUOFF are not affected.
Example The general interrupt enable (GIE) bit in the status register is set.
; Interrupt routine of ports P1.2 to P1.7
; P1IN is the address of the register where all port bits are read. P1IFG is
; the address of the register where all interrupt events are latched.
PUSH.B &P1IN
BIC.B @SP,&P1IFG ; Reset only accepted flags
EINT ; Preset port 1 interrupt flags stored on stack
; other interrupts are allowed
BIT #Mask,@SP
JEQ MaskOK ; Flags are present identically to mask: jump
......
MaskOK BIC #Mask,@SP
......
INCD SP ; Housekeeping: inverse to PUSH instruction
; at the start of interrupt subroutine. Corrects
; the stack pointer.
RETI
Note
Enable Interrupt
The instruction following the enable interrupt instruction (EINT) is always
executed, even if an interrupt service request is pending when the interrupts
are enable.
3.4.6.21 INC
Syntax
INC dst or INC.W dst
INC.B dst
Emulation
ADD #1,dst
Description The destination operand is incremented by one. The original contents are lost.
Example The status byte, STATUS, of a process is incremented. When it is equal to 11, a branch to
OVFL is taken.
INC.B STATUS
CMP.B #11,STATUS
JEQ OVFL
3.4.6.22 INCD
Syntax
INCD dst or INCD.W dst
INCD.B dst
Emulation
ADD #2,dst
ADD.B #2,dst
Example The destination operand is incremented by two. The original contents are lost.
Example The item on the top of the stack (TOS) is removed without using a register.
PUSH R5 ; R5 is the result of a calculation, which is stored
; in the system stack
INCD SP ; Remove TOS by double-increment from stack
; Do not use INCD.B, SP is a word-aligned register
RET
3.4.6.23 INV
Syntax
INV dst
INV.B dst
Emulation
XOR #0FFFFh,dst
XOR.B #0FFh,dst
Description The destination operand is inverted. The original contents are lost.
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 program counter. If C is reset, the next instruction
following the jump is executed. JC (jump if carry/higher or same) is used for the
comparison of unsigned numbers (0 to 65536).
Example The P1IN.1 signal is used to define or control the program flow.
BIT.B #02h,&P1IN ; State of signal -> Carry
JC PROGA ; If carry=1 then execute program routine A
...... ; Carry=0, execute program here
Example R5 is compared to 15. If the content is higher or the same, branch to LABEL.
CMP #15,R5
JHS LABEL ; Jump is taken if R5 >= 15
...... ; Continue here if R5 < 15
3.4.6.25 JEQ, JZ
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. If Z is not set, the instruction following
the jump is executed.
3.4.6.26 JGE
Syntax
JGE label
Description The status register negative bit (N) and overflow bit (V) are tested. If both N and V are set
or reset, the 10-bit signed offset contained in the instruction LSBs is added to the program
counter. If only one is set, the instruction following the jump is executed.
This allows comparison of signed integers.
Example When the content of R6 is greater or equal to the memory pointed to by R7, the program
continues at label EDE.
CMP @R7,R6 ; R6 >= (R7)?, compare on signed numbers
JGE EDE ; Yes, R6 >= (R7)
...... ; No, proceed
......
......
3.4.6.27 JL
JL Jump if less
Syntax
JL label
Description The status register negative bit (N) and overflow bit (V) are tested. If only one is set, the
10-bit signed offset contained in the instruction LSBs is added to the program counter. If
both N and V are set or reset, the instruction following the jump is executed.
This allows comparison of signed integers.
Example When the content of R6 is less than the memory pointed to by R7, the program continues
at label EDE.
CMP @R7,R6 ; R6 < (R7)?, compare on signed numbers
JL EDE ; Yes, R6 < (R7)
...... ; No, proceed
......
......
3.4.6.28 JMP
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.
3.4.6.29 JN
JN Jump if negative
Syntax
JN label
Operation if N = 1: PC + 2 ×offset → PC
if N = 0: execute following instruction
Description The 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 reset, the next
instruction following the jump is executed.
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 program counter. If C is set, the next instruction
following the jump is executed. JNC (jump if no carry/lower) is used for the comparison of
unsigned numbers (0 to 65536).
Example The result in R6 is added in BUFFER. If an overflow occurs, an error handling routine at
address ERROR is used.
ADD R6,BUFFER ; BUFFER + R6 -> BUFFER
JNC CONT ; No carry, jump to CONT
ERROR ...... ; Error handler start
......
......
......
CONT ...... ; Continue with normal program flow
......
......
Syntax
JNE label
JNZ label
Operation If Z = 0: PC + 2 a 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 program counter. If Z is set, the next instruction
following the jump is executed.
3.4.6.32 MOV
Syntax
MOV src,dst or MOV.W src,dst
MOV.B src,dst
Example The contents of table EDE (word data) are copied to table TOM. The length of the tables
must be 020h locations.
MOV #EDE,R10 ; Prepare pointer
MOV #020h,R9 ; Prepare counter
Loop MOV @R10+,TOM-EDE-2(R10) ; Use pointer in R10 for both tables
DEC R9 ; Decrement counter
JNZ Loop ; Counter not 0, continue copying
...... ; Copying completed
......
......
Example The contents of table EDE (byte data) are copied to table TOM. The length of the tables
should be 020h locations
MOV #EDE,R10 ; Prepare pointer
MOV #020h,R9 ; Prepare counter
Loop MOV.B @R10+,TOM-EDE-1(R10) ; Use pointer in R10 for
; both tables
DEC R9 ; Decrement counter
JNZ Loop ; Counter not 0, continue
; copying
...... ; Copying completed
......
......
3.4.6.33 NOP
*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.
Note
Emulating No-Operation Instruction
Other instructions can emulate the NOP function while providing different
numbers of instruction cycles and code words. Some examples are:
MOV #0,R3 ; 1 cycle, 1 word
MOV 0(R4),0(R4) ; 6 cycles, 3 words
MOV @R4,0(R4) ; 5 cycles, 2 words
BIC #0,EDE(R4) ; 4 cycles, 2 words
JMP $+2 ; 2 cycles, 1 word
BIC #0,R5 ; 1 cycle, 1 word
3.4.6.34 POP
Syntax
POP dst
POP.B dst
Description The stack location pointed to by the stack pointer (TOS) is moved to the destination. The
stack pointer is incremented by two afterwards.
Example The contents of R7 and the status register are restored from the stack.
POP R7 ; Restore R7
POP SR ; Restore status register
Example The contents of RAM byte LEO is restored from the stack.
POP.B LEO ; The low byte of the stack is moved to LEO.
Example The contents of the memory pointed to by R7 and the status register are restored from the
stack.
POP.B 0(R7) ; The low byte of the stack is moved to the
; the byte which is pointed to by R7
; Example: R7 = 203h
; Mem(R7) = low byte of system stack
; Example: R7 = 20Ah
; Mem(R7) = low byte of system stack
POP SR ; Last word on stack moved to the SR
(continued)
Note
The System Stack Pointer
The system stack pinter (SP) is always incremented by two, independent of the
byte suffix.
100 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPU
3.4.6.35 PUSH
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).
Example The contents of the status register and R8 are saved on the stack.
PUSH SR ; save status register
PUSH R8 ; save R8
Note
System Stack Pointer
The System stack pointer (SP) is always decremented by two, independent of
the byte suffix.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 101
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPU www.ti.com
3.4.6.36 RET
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 the program
counter. The program continues at the code address following the subroutine call.
102 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPU
3.4.6.37 RETI
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.
The program counter is restored to the value at the beginning of interrupt service. This
is the consecutive step after the interrupted program flow. Restoration is performed by
replacing the present PC contents with the TOS memory contents. The stack pointer (SP)
is incremented.
Mode Bits OSCOFF, CPUOFF, and GIE are restored from system stack.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 103
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPU www.ti.com
(continued)
PC −6
PC −4
Interrupt Request
PC −2
PC Interrupt Accepted
PC +6 PCi +4
PC +8
PCi +n−4
PCi +n−2
PCi +n RETI
104 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPU
3.4.6.38 RLA
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-15. The MSB is
shifted into the carry bit (C) and the LSB is filled with 0. The RLA instruction acts as a
signed multiplication by 2.
An overflow occurs if dst ≥ 04000h and dst < 0C000h before operation is performed: the
result has changed sign.
Word 15 0
C 0
Byte 7 0
An overflow occurs if dst ≥ 040h and dst < 0C0h before the operation is performed: the
result has changed sign.
Status Bits N: Set if result is negative, reset if positive
Z: Set if result is zero, reset otherwise
C: Loaded from the MSB
V: Set if an arithmetic overflow occurs:
the initial value is 04000h ≤ dst < 0C000h; reset otherwise
Set if an arithmetic overflow occurs:
the initial value is 040h ≤ dst < 0C0h; reset otherwise
Example R7 is multiplied by 2.
RLA R7 ; Shift left R7 (x 2)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 105
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPU www.ti.com
(continued)
Note
RLA Substitution
The assembler does not recognize the instruction:
RLA @R5+, RLA.B @R5+, or RLA(.B) @R5
106 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPU
3.4.6.39 RLC
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-16. The carry bit
(C) is shifted into the LSB and the MSB is shifted into the carry bit (C).
Word 15 0
Byte 7 0
Example The input P1IN.1 information is shifted into the LSB of R5.
BIT.B #2,&P1IN ; Information -> Carry
RLC R5 ; Carry=P0in.1 -> LSB of R5
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 107
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPU www.ti.com
(continued)
Note
RLC and RLC.B Substitution
The assembler does not recognize the instruction:
RLC @R5+, RLC @R5, or RLC(.B) @R5
108 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPU
3.4.6.40 RRA
Syntax
RRA dst or RRA.W dst
RRA.B dst
Description The destination operand is shifted right one position as shown in Figure 3-17. The MSB is
shifted into the MSB, the MSB is shifted into the MSB-1, and the LSB+1 is shifted into the
LSB.
Word 15 0
Byte
7 0
Example R5 is shifted right one position. The MSB retains the old value. It operates equal to an
arithmetic division by 2.
RRA R5 ; R5/2 -> R5
; The value in R5 is multiplied by 0.75 (0.5 + 0.25).
;
PUSH R5 ; Hold R5 temporarily using stack
RRA R5 ; R5 x 0.5 -> R5
ADD @SP+,R5 ; R5 x 0.5 + R5 = 1.5 x R5 -> R5
RRA R5 ; (1.5 x R5) x 0.5 = 0.75 x R5 -> R5
......
Example The low byte of R5 is shifted right one position. The MSB retains the old value. It operates
equal to an arithmetic division by 2.
RRA.B R5 ; R5/2 -> R5: operation is on low byte only
; High byte of R5 is reset
PUSH.B R5 ; R5 x 0.5 -> TOS
RRA.B @SP ; TOS x 0.5 = 0.5 x R5 x 0.5 = 0.25 x R5 -> TOS
ADD.B @SP+,R5 ; R5 x 0.5 + R5 x 0.25 = 0.75 x R5 -> R5
......
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 109
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPU www.ti.com
3.4.6.41 RRC
Syntax
RRC dst or RRC.W dst
RRC dst
Description The destination operand is shifted right one position as shown in Figure 3-18. The carry
bit (C) is shifted into the MSB, the LSB is shifted into the carry bit (C).
Word 15 0
Byte 7 0
110 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPU
3.4.6.42 SBC
Syntax
SBC dst or SBC.W dst
SBC.B dst
Emulation
SUBC #0,dst
SUBC.B #0,dst
Description The carry bit (C) is added to the destination operand minus one. The previous contents of
the destination are lost.
Example The 16-bit counter pointed to by R13 is subtracted from a 32-bit counter pointed to by
R12.
SUB @R13,0(R12) ; Subtract LSDs
SBC 2(R12) ; Subtract carry from MSD
Example The 8-bit counter pointed to by R13 is subtracted from a 16-bit counter pointed to by R12.
SUB.B @R13,0(R12) ; Subtract LSDs
SBC.B 1(R12) ; Subtract carry from MSD
Note
Borrow Implementation
The borrow is treated as a .NOT. carry: Borrow Carry bit
Yes 0
No 1
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 111
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPU www.ti.com
3.4.6.43 SETC
Syntax
SETC
Operation 1→C
Emulation
BIS #1,SR
112 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPU
3.4.6.44 SETN
Syntax
SETN
Operation 1→N
Emulation
BIS #4,SR
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 113
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPU www.ti.com
3.4.6.45 SETZ
Syntax
SETZ
Operation 1→Z
Emulation
BIS #2,SR
114 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPU
3.4.6.46 SUB
Syntax
SUB src,dst or SUB.W src,dst
SUB.B src,dst
Note
Borrow Is Treated as a .NOT.
The borrow is treated as a .NOT. carry: Borrow Carry bit
Yes 0
No 1
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 115
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPU www.ti.com
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
Description The source operand is subtracted from the destination operand by adding the source
operand's 1s complement and the carry bit (C). The source operand is not affected. The
previous contents of the destination are lost.
Example The 16-bit counter pointed to by R13 is subtracted from a 16-bit counter in R10 and
R11(MSD).
SUB.B @R13+,R10 ; Subtract LSDs without carry
SUBC.B @R13,R11 ; Subtract MSDs with carry
... ; resulting from the LSDs
Note
Borrow Implementation
The borrow is treated as a .NOT. carry: Borrow Carry bit
Yes 0
No 1
116 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPU
3.4.6.48 SWPB
Syntax
SWPB dst
Description The destination operand high and low bytes are exchanged as shown in Figure 3-19.
Example
MOV #040BFh,R7 ; 0100000010111111 -> R7
SWPB R7 ; 1011111101000000 in R7
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 117
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPU www.ti.com
3.4.6.49 SXT
Syntax
SXT dst
Description The sign of the low byte is extended into the high byte as shown in Figure 3-20.
Example R7 is loaded with the P1IN value. The operation of the sign-extend instruction expands bit
8 to bit 15 with the value of bit 7.
R7 is then added to R6.
MOV.B &P1IN,R7 ; P1IN = 080h: .... .... 1000 0000
SXT R7 ; R7 = 0FF80h: 1111 1111 1000 0000
118 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPU
3.4.6.50 TST
Syntax
TST dst or TST.W dst
TST.B dst
Emulation
CMP #0,dst
CMP.B #0,dst
Description The destination operand is compared with zero. The status bits are set according to the
result. The destination is not affected.
Example R7 is tested. If it is negative, continue at R7NEG; if it is positive but not zero, continue at
R7POS.
TST R7 ; Test R7
JN R7NEG ; R7 is negative
JZ R7ZERO ; R7 is zero
R7POS ...... ; R7 is positive but not zero
R7NEG ...... ; R7 is negative
R7ZERO ...... ; R7 is zero
Example The low byte of R7 is tested. If it is negative, continue at R7NEG; if it is positive but not
zero, continue at R7POS.
TST.B R7 ; Test low byte of R7
JN R7NEG ; Low byte of R7 is negative
JZ R7ZERO ; Low byte of R7 is zero
R7POS ...... ; Low byte of R7 is positive but not zero
R7NEG ..... ; Low byte of R7 is negative
R7ZERO ...... ; Low byte of R7 is zero
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 119
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPU www.ti.com
3.4.6.51 XOR
Syntax
XOR src,dst or XOR.W src,dst
XOR.B src,dst
Description The source and destination operands are exclusive ORed. The result is placed into the
destination. The source operand is not affected.
Status Bits N: Set if result MSB is set, reset if not set
Z: Set if result is zero, reset otherwise
C: Set if result is not zero, reset otherwise ( = .NOT. Zero)
V: Set if both operands are negative
Example The bits set in R6 toggle the bits in the RAM word TONI.
XOR R6,TONI ; Toggle bits of word TONI on the bits set in R6
Example The bits set in R6 toggle the bits in the RAM byte TONI.
XOR.B R6,TONI ; Toggle bits of byte TONI on the bits set in
; low byte of R6
Example Reset to 0 those bits in low byte of R7 that are different from bits in RAM byte EDE.
XOR.B EDE,R7 ; Set different bit to "1s"
INV.B R7 ; Invert Lowbyte, Highbyte is 0h
120 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Chapter 4
CPUX
This chapter describes the extended MSP430X 16-bit RISC CPU with 1-MB memory access, its addressing
modes, and instruction set. The MSP430X CPU is implemented in all MSP430 devices that exceed 64-KB of
address space.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 121
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
122 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
19 16 15 0
R0/PC Program Counter 0
R4 General Purpose
R5 General Purpose
R6 General Purpose
R7 General Purpose
R8 General Purpose
R9 General Purpose
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 123
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.2 Interrupts
The MSP430X uses the same interrupt structure as the MSP430:
• Vectored interrupts with no polling necessary
• Interrupt vectors are located downward from address 0FFFEh
Interrupt operation for both MSP430 and MSP430X CPUs is described in Chapter 2 System Resets, Interrupts,
and Operating modes, Section 2 Interrupts. The interrupt vectors contain 16-bit addresses that point into the
lower 64-KB memory. This means all interrupt handlers must start in the lower 64-KB memory, even in MSP430X
devices.
During an interrupt, the program counter and the status register are pushed onto the stack as shown in Figure
4-2. The MSP430X architecture efficiently stores the complete 20-bit PC value by automatically appending the
PC bits 19:16 to the stored SR value on the stack. When the RETI instruction is executed, the full 20-bit PC is
restored making return from interrupt to any address in the memory range possible.
124 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
The PC can be addressed with all instructions and addressing modes. A few examples:
MOV.W #LABEL,PC ; Branch to address LABEL (lower 64KB)
MOVA #LABEL,PC ; Branch to address LABEL (1MB memory)
MOV.W LABEL,PC ; Branch to address in word LABEL
; (lower 64KB)
MOV.W @R14,PC ; Branch indirect to address in
; R14 (lower 64KB)
ADDA #4,PC ; Skip two words (1MB memory)
The BR and CALL instructions reset the upper four PC bits to 0. Only addresses in the lower 64-KB address
range can be reached with the BR or CALL instruction. When branching or calling, addresses beyond the lower
64-KB range can only be reached using the BRA or CALLA instructions. Also, any instruction to directly modify
the PC does so according to the used addressing mode. For example, MOV.W #value,PC clears the upper
four bits of the PC, because it is a .W instruction.
The PC is automatically stored on the stack with CALL (or CALLA) instructions and during an interrupt service
routine. Figure 4-4 shows the storage of the PC with the return address after a CALLA instruction. A CALL
instruction stores only bits 15:0 of the PC.
SPold Item n
PC.19:16
SP PC.15:0
The RETA instruction restores bits 19:0 of the PC and adds 4 to the stack pointer (SP). The RET instruction
restores bits 15:0 to the PC and adds 2 to the SP.
4.3.2 Stack Pointer (SP)
The 20-bit SP (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 4-5 shows the SP. The SP is initialized into RAM by the user, and is always
aligned to even addresses.
Figure 4-6 shows the stack usage. Figure 4-7 shows the stack usage when 20-bit address words are pushed.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 125
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
19 1 0
0xxxh I1 I1 I1
0xxxh − 2 I2 I2 I2
0xxxh − 4 I3 SP I3 I3 SP
0xxxh − 6 0123h SP
0xxxh − 8
Item.19:16
SP Item.15:0
The special cases of using the SP as an argument to the PUSH and POP instructions are described and shown
in Figure 4-8.
PUSH SP POP SP
SPold
SP1 SPold SP2 SP1
The stack pointer is changed after The stack pointer is not changed after a POP SP
a PUSH SP instruction. instruction. The POP SP instruction places SP1 into the
stack pointer SP (SP2 = SP1)
126 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
15 9 8 7 0
OSC CPU
Reserved V SCG1 SCG0 OFF OFF GIE N Z C
rw-0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 127
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
128 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
19 16 15 87 0
Un- Unused
Memory Register
used
Operation Operation
Memory 0 0 Register
Figure 4-11 and Figure 4-12 show 16-bit word handling (.W suffix). The handling is shown for a source register
and a destination memory word and for a source memory word and a destination register.
Register-Word Operation
Memory
Operation
Memory
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 129
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
Memory
19 16 15 87 0
Un-
Register
used
Operation
0 Register
Figure 4-13 and Figure 4-14 show 20-bit address-word handling (.A suffix). The handling is shown for a source
register and a destination memory address-word and for a source memory address-word and a destination
register.
Register − Address-Word Operation
Operation
Memory +2 0 Memory
130 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Register
Operation
Register
The seven addressing modes are explained in detail in the following sections. Most of the examples show the
same addressing mode for the source and destination, but any valid combination of source and destination
addressing modes is possible in an instruction.
Note
Use of Labels EDE, TONI, TOM, and LEO
Throughout MSP430 documentation, EDE, TONI, TOM, and LEO are used as generic labels. They
are only labels and have no special meaning.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 131
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
A550h.or.1111h = B551h
Example: BISX.A R5,R6 ;
This instruction logically ORs the 20-bit data contained in R5 with the 20-bit contents of R6.
The extension word contains the A/L bit for 20-bit data. The instruction word uses byte mode with bits A/L:B/W
= 01. The result of the instruction is:
Before: After:
Address Register Address Register
Space Space
AA550h.or.11111h = BB551h
132 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
10000
0FFFF
Lower 64KB
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 133
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
Before: After:
Address Register Address Register
Space Space
0479Ch
0579Eh xxxxh +1000h 0579Eh xxxxh
0579Ch
0579Ch xx32h 0579Ch xx32h
Rn.19:0 Rn ± 32KB
134 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Rn.19:0
FFFFF
±32KB
Rn.19:0
±32KB
10000 Rn.19:0
0FFFF
Lower 64KB
Rn.19:0
0000C
Before: After:
Address Register Address Register
Space Space
23456h
1B79Eh xxxxh +F8346h 1B79Eh xxxxh
1B79Ch
1B79Ch 5432h 1B79Ch 5432h
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 135
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
The extension word contains the MSBs of the source index and of the destination index and the A/L bit for 20-bit
data. The instruction word uses byte mode due to the 20-bit data length with bits A/L:B/W = 01.
Before: After:
Address Register Address Register
Space Space
23456h
3579Eh 0006h +12346h 3579Eh 0006h
3579Ch
3579Ch 5432h 3579Ch 5432h
136 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Operation: The signed 16-bit index in the next word after the instruction is added temporarily to the PC. The resulting bits
19:16 are cleared giving a truncated 16-bit memory address, which points to an operand address in the range
00000h to 0FFFFh. The operand is the content of the addressed memory location.
Length: Two or three words
Comment: Valid for source and destination. The assembler calculates the PC index and inserts it.
Example: ADD.B EDE,TONI ;
This instruction adds the 8-bit data contained in source byte EDE and destination byte TONI and places the
result into the destination byte TONI. Bytes EDE and TONI and the program are located in the lower 64KB.
Source: Byte EDE located at address 0579Ch, pointed to by PC + 4766h, where the PC index 4766h is the result of
0579Ch – 01036h = 04766h. Address 01036h is the location of the index for this example.
Destination: Byte TONI located at address 00778h, pointed to by PC + F740h, is the truncated 16-bit result of 00778h –
1038h = FF740h. Address 01038h is the location of the index for this example.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 137
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
Before: After:
Address Address
Space Space
01036h
0579Eh xxxxh +04766h 0579Eh xxxxh
0579Ch
0579Ch xx32h 0579Ch xx32h
PC.19:0 PC ±32KB
138 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
PC.19:0
FFFFF
±32KB
PC.19:0
±32KB
10000 PC.19:0
0FFFF
Lower 64KB
PC.19:0
0000C
Before: After:
Address Address
Space Space
2F036h
3379Eh xxxxh +04766h 3379Eh xxxxh
3379Ch
3379Ch 5432h 3379Ch 5432h
5432h src
0077Ah xxxxh 0077Ah xxxxh +2345h dst
7777h Sum
00778h 2345h 00778h 7777h
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 139
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
21036h
3579Eh xxxxh +14766h 3579Eh xxxxh
3579Ch
3579Ch xx32h 3579Ch xx32h
140 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
5432h src
0777Ah xxxxh 0777Ah xxxxh +2345h dst
7777h Sum
07778h 2345h 07778h 7777h
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 141
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
Before: After:
Address Address
Space Space
65432h src
7777Ah 0001h 7777Ah 0007h +12345h dst
77777h Sum
77778h 2345h 77778h 7777h
142 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Before: After:
Address Register Address Register
Space Space
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 143
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
Before: After:
Address Register Address Register
Space Space
144 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Before: After:
Address Address
Space Space
3456h src
0077Ah xxxxh 0077Ah xxxxh +2345h dst
579Bh Sum
00778h 2345h 00778h 579Bh
Before: After:
Address Address
Space Space
23456h src
7777Ah 0001h 7777Ah 0003h +12345h dst
3579Bh Sum
77778h 2345h 77778h 579Bh
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 145
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
Destination 15:0
146 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Destination 15:0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 147
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
148 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
(1) * = Status bit is affected; – = Status bit is not affected; 0 = Status bit is cleared; 1 = Status bit is set.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 149
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
Rm 1 1 MOV R5,R8
PC 2 1 BR R9
Rn x(Rm) 4(1) 2 ADD R5,4(R6)
EDE 4(1) 2 XOR R8,EDE
&EDE 4(1) 2 MOV R5,&EDE
Rm 2 1 AND @R4,R5
PC 3 1 BR @R8
@Rn x(Rm) 5(1) 2 XOR @R5,8(R6)
EDE 5(1) 2 MOV @R5,EDE
&EDE 5(1) 2 XOR @R5,&EDE
Rm 2 1 ADD @R5+,R6
PC 3 1 BR @R9+
@Rn+ x(Rm) 5(1) 2 XOR @R5,8(R6)
EDE 5(1) 2 MOV @R9+,EDE
&EDE 5(1) 2 MOV @R9+,&EDE
Rm 2 2 MOV #20,R9
PC 3 2 BR #2AEh
#N x(Rm) 5(1) 3 MOV #0300h,0(SP)
EDE 5(1) 3 ADD #33,EDE
&EDE 5(1) 3 ADD #33,&EDE
Rm 3 2 MOV 2(R5),R7
PC 3 2 BR 2(R6)
x(Rn) TONI 6(1) 3 MOV 4(R7),TONI
x(Rm) 6(1) 3 ADD 4(R4),6(R9)
&TONI 6(1) 3 MOV 2(R4),&TONI
Rm 3 2 AND EDE,R6
PC 3 2 BR EDE
EDE TONI 6(1) 3 CMP EDE,TONI
x(Rm) 6(1) 3 MOV EDE,0(SP)
&TONI 6(1) 3 MOV EDE,&TONI
Rm 3 2 MOV &EDE,R8
PC 3 2 BR &EDE
&EDE TONI 6(1) 3 MOV &EDE,TONI
x(Rm) 6(1) 3 MOV &EDE,0(SP)
&TONI 6(1) 3 MOV &EDE,&TONI
(1) MOV, BIT, and CMP instructions execute in one fewer cycle.
150 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Table 4-11. Description of the Extension Word Bits for Register Mode
Bit Description
15:11 Extension word op-code. Op-codes 1800h to 1FFFh are extension words.
10:9 Reserved
ZC Zero carry
0 The executed instruction uses the status of the carry bit C.
1 The executed instruction uses the carry bit as 0. The carry bit is defined by the result of the final operation after
instruction execution.
# Repetition
0 The number of instruction repetitions is set by extension word bits 3:0.
1 The number of instruction repetitions is defined by the value of the four LSBs of Rn. See description for bits 3:0.
A/L Data length extension. Together with the B/W bits of the following MSP430 instruction, the AL bit defines the used data length of
the instruction.
A/L B/W Comment
0 0 Reserved
0 1 20-bit address word
1 0 16-bit word
1 1 8-bit byte
5:4 Reserved
3:0 Repetition count
#=0 These four bits set the repetition count n. These bits contain n – 1.
#=1 These four bits define the CPU register whose bits 3:0 set the number of repetitions. Rn.3:0 contain n – 1.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 151
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
Note
B/W and A/L bit settings for SWPBX and SXTX
A/L B/W
0 0 SWPBX.A, SXTX.A
0 1 N/A
1 0 SWPB.W, SXTX.W
1 1 N/A
152 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
XORX.A R9,R8
1: Repetition count
in bits 3:0
0: Use Carry 01: Address word
0 0 0 1 1 0 0 0 0 0 0
14(XOR) 9 0 1 0 8(R8)
Destination
register mode
Source
register mode
Source 15:0
Destination 15:0
X(Rn)
01: Address
word @PC+
0 0 0 1 1 1 0 0 4
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 153
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
The four possible addressing combinations for the extension word for Format I instructions are shown in Figure
4-28.
154 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
15 14 13 12 11 10 9 8 7 6 5 4 3 0
0 0 0 1 1 0 0 ZC # A/L 0 0 n−1/Rn
0 0 0 1 1 src.19:16 A/L 0 0 0 0 0 0
src.15:0
0 0 0 1 1 0 0 0 0 A/L 0 0 dst.19:16
dst.15:0
src.15:0
dst.15:0
If the 20-bit address of a source or destination operand is located in memory, not in a CPU register, then two
words are used for this operand as shown in Figure 4-29.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 155
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
The three possible addressing mode combinations for Format II instructions are shown in Figure 4-30.
15 14 13 12 11 10 9 8 7 6 5 4 3 0
0 0 0 1 1 0 0 ZC # A/L 0 0 n−1/Rn
0 0 0 1 1 0 0 0 0 A/L 0 0 0 0 0 0
0 0 0 1 1 0 0 0 0 A/L 0 0 dst.19:16
dst.15:0
156 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
#imm15:0 / &abs15:0
index15:0
Op-code Rdst
Op-code Rdst
index15:0
Op-code #imm/ix/abs19:16
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 157
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
158 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 159
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
160 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
(1) Repeat instructions require n + 1 cycles, where n is the number of times the instruction is executed.
(2) Reduce the cycle count by one for MOV, BIT, and CMP instructions.
(3) Reduce the cycle count by two for MOV, BIT, and CMP instructions.
(4) Reduce the cycle count by one for MOV, ADD, and SUB instructions.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 161
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
162 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 163
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
Instruction
Instruction Group Bit Loc. Inst. ID dst
Instruction Identifier
15 12 11 10 9 8 7 4 3 0
RRCM.A 0 0 0 0 n–1 0 0 0 1 0 0 dst RRCM.A #n,Rdst
RRAM.A 0 0 0 0 n–1 0 1 0 1 0 0 dst RRAM.A #n,Rdst
RLAM.A 0 0 0 0 n–1 1 0 0 1 0 0 dst RLAM.A #n,Rdst
RRUM.A 0 0 0 0 n–1 1 1 0 1 0 0 dst RRUM.A #n,Rdst
RRCM.W 0 0 0 0 n–1 0 0 0 1 0 1 dst RRCM.W #n,Rdst
RRAM.W 0 0 0 0 n–1 0 1 0 1 0 1 dst RRAM.W #n,Rdst
RLAM.W 0 0 0 0 n–1 1 0 0 1 0 1 dst RLAM.W #n,Rdst
RRUM.W 0 0 0 0 n–1 1 1 0 1 0 1 dst RRUM.W #n,Rdst
164 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 165
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
166 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.1 ADC
* 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 result is negative, reset if positive
Z: Set if result is zero, reset otherwise
C: Set if dst was incremented from 0FFFFh to 0000, reset otherwise
Set if dst was incremented from 0FFh to 00, reset otherwise
V: Set if an arithmetic overflow occurs, otherwise reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 16-bit counter pointed to by R13 is added to a 32-bit counter pointed to by R12.
Example The 8-bit counter pointed to by R13 is added to a 16-bit counter pointed to by R12.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 167
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.2 ADD
ADD[.W] Add source word to destination word
ADD.B Add source byte to destination byte
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 previous content of the destination is lost.
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the MSB of the result, reset otherwise
V: Set if the result of two positive operands is negative, or if the result of two negative numbers is positive, reset
otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Ten is added to the 16-bit counter CNTR located in lower 64KB.
Example A table word pointed to by R5 (20-bit address in R5) is added to R6. The jump to label TONI is performed on a carry.
Example A table byte pointed to by R5 (20-bit address) is added to R6. The jump to label TONI is performed if no carry occurs.
The table pointer is auto-incremented by 1. R6.19:8 = 0
168 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.3 ADDC
ADDC[.W] Add source word and carry to destination word
ADDC.B Add source byte and carry to destination byte
Syntax ADDC src,dst or ADDC.W src,dst
ADDC.B src,dst
Operation src + dst + C → dst
Description The source operand and the carry bit C are added to the destination operand. The previous content of the destination
is lost.
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the MSB of the result, reset otherwise
V: Set if the result of two positive operands is negative, or if the result of two negative numbers is positive, reset
otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Constant value 15 and the carry of the previous instruction are added to the 16-bit counter CNTR located in lower
64KB.
Example A table word pointed to by R5 (20-bit address) and the carry C are added to R6. The jump to label TONI is performed
on a carry. R6.19:16 = 0
Example A table byte pointed to by R5 (20-bit address) and the carry bit C are added to R6. The jump to label TONI is
performed if no carry occurs. The table pointer is auto-incremented by 1. R6.19:8 = 0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 169
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.4 AND
AND[.W] Logical AND of source word with destination word
AND.B Logical AND of source byte with destination byte
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. The
source operand is not affected.
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if the result is not zero, reset otherwise. C = (.not. Z)
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The bits set in R5 (16-bit data) are used as a mask (AA55h) for the word TOM located in the lower 64KB. If the result
is zero, a branch is taken to label TONI. R5.19:16 = 0
or shorter:
Example A table byte pointed to by R5 (20-bit address) is logically ANDed with R6. R5 is incremented by 1 after the fetching of
the byte. R6.19:8 = 0
170 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.5 BIC
BIC[.W] Clear bits set in source word in destination word
BIC.B Clear bits set in source byte in destination byte
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 not affected.
Status Bits N: Not affected
Z: Not affected
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The bits 15:14 of R5 (16-bit data) are cleared. R5.19:16 = 0
Example A table word pointed to by R5 (20-bit address) is used to clear bits in R7. R7.19:16 = 0
Example A table byte pointed to by R5 (20-bit address) is used to clear bits in Port1.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 171
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.6 BIS
BIS[.W] Set bits set in source word in destination word
BIS.B Set bits set in source byte in destination byte
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 Bits N: Not affected
Z: Not affected
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Bits 15 and 13 of R5 (16-bit data) are set to one. R5.19:16 = 0
Example A table word pointed to by R5 (20-bit address) is used to set bits in R7. R7.19:16 = 0
Example A table byte pointed to by R5 (20-bit address) is used to set bits in Port1. R5 is incremented by 1 afterwards.
172 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.7 BIT
BIT[.W] Test bits set in source word in destination word
BIT.B Test bits set in source byte in destination byte
Syntax BIT src,dst or BIT.W src,dst
BIT.B src,dst
Operation src .and. dst
Description The source operand and the destination operand are logically ANDed. The result affects only the status bits in SR.
Register mode: the register bits Rdst.19:16 (.W) resp. Rdst. 19:8 (.B) are not cleared!
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if the result is not zero, reset otherwise. C = (.not. Z)
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Test if one (or both) of bits 15 and 14 of R5 (16-bit data) is set. Jump to label TONI if this is the case. R5.19:16 are not
affected.
Example A table word pointed to by R5 (20-bit address) is used to test bits in R7. Jump to label TONI if at least one bit is set.
R7.19:16 are not affected.
Example A table byte pointed to by R5 (20-bit address) is used to test bits in output Port1. Jump to label TONI if no bit is set.
The next table byte is addressed.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 173
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
174 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.9 CALL
CALL Call a subroutine in lower 64KB
Syntax CALL dst
Operation dst → PC 16-bit dst is evaluated and stored
SP – 2 → SP
PC → @SP updated PC with return address to TOS
tmp → PC saved 16-bit dst to PC
Description A subroutine call is made from an address in the lower 64KB to a subroutine address in the lower 64KB. All seven
source addressing modes can be used. The call instruction is a word instruction. The return is made with the RET
instruction.
Status Bits Status bits are not affected.
PC.19:16 cleared (address in lower 64KB)
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Examples Examples for all addressing modes are given.
Immediate Mode: Call a subroutine at label EXEC (lower 64KB) or call directly to address.
Symbolic Mode: Call a subroutine at the 16-bit address contained in address EXEC. EXEC is located at the address
(PC + X) where X is within PC + 32 K.
Absolute Mode: Call a subroutine at the 16-bit address contained in absolute address EXEC in the lower 64KB.
Register mode: Call a subroutine at the 16-bit address contained in register R5.15:0.
Indirect Mode: Call a subroutine at the 16-bit address contained in the word pointed to by register R5 (20-bit address).
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 175
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.10 CLR
* 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 affected.
Example RAM word TONI is cleared.
CLR R5
176 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.11 CLRC
* 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 affected
Z: Not affected
C: Cleared
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 16-bit decimal counter pointed to by R13 is added to a 32-bit counter pointed to by R12.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 177
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.12 CLRN
* 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 instruction.
Status Bits N: Reset to 0
Z: Not affected
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The negative bit in the SR is cleared. This avoids special treatment with negative numbers of the subroutine called.
CLRN
CALL SUBR
...
...
SUBR JN SUBRET ; If input is negative: do nothing and return
...
...
...
SUBRET RET
178 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.13 CLRZ
* 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.
Status Bits N: Not affected
Z: Reset to 0
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The zero bit in the SR is cleared.
CLRZ
Indirect, Auto-Increment mode: Call a subroutine at the 16-bit address contained in the word pointed to by register R5
(20-bit address) and increment the 16-bit address in R5 afterwards by 2. The next time the software uses R5 as a
pointer, it can alter the program execution due to access to the next word address in the table pointed to by R5.
Indexed mode: Call a subroutine at the 16-bit address contained in the 20-bit address pointed to by register (R5 + X),
for example, a table with addresses starting at X. The address is within the lower 64KB. X is within +32KB.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 179
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.14 CMP
CMP[.W] Compare source word and destination word
CMP.B Compare source byte and destination byte
Syntax CMP src,dst or CMP.W src,dst
CMP.B src,dst
Operation (.not.src) + 1 + dst
or
dst – src
Emulation BIC #2,SR
Description The source operand is subtracted from the destination operand. This is made by adding the 1s complement of the
source + 1 to the destination. The result affects only the status bits in SR.
Register mode: the register bits Rdst.19:16 (.W) resp. Rdst. 19:8 (.B) are not cleared.
Status Bits N: Set if result is negative (src > dst), reset if positive (src ≤ dst)
Z: Set if result is zero (src = dst), reset otherwise (src ≠ dst)
C: Set if there is a carry from the MSB, reset otherwise
V: Set if the subtraction of a negative source operand from a positive destination operand delivers a negative
result, or if the subtraction of a positive source operand from a negative destination operand delivers a positive
result, reset otherwise (no overflow).
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Compare word EDE with a 16-bit constant 1800h. Jump to label TONI if EDE equals the constant. The address of EDE
is within PC + 32 K.
Example A table word pointed to by (R5 + 10) is compared with R7. Jump to label TONI if R7 contains a lower, signed 16-bit
number. R7.19:16 is not cleared. The address of the source operand is a 20-bit address in full memory range.
Example A table byte pointed to by R5 (20-bit address) is compared to the value in output Port1. Jump to label TONI if values
are equal. The next table byte is addressed.
180 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.15 DADC
* DADC[.W] Add carry decimally to destination
* DADC.B Add carry decimally to destination
Syntax DADC dst or DADC.W 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 1
Z: Set if dst is 0, reset otherwise
C: Set if destination increments from 9999 to 0000, reset otherwise
Set if destination increments from 99 to 00, reset otherwise
V: Undefined
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The four-digit decimal number contained in R5 is added to an eight-digit decimal number pointed to by R8.
Example The two-digit decimal number contained in R5 is added to a four-digit decimal number pointed to by R8.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 181
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.16 DADD
* DADD[.W] Add source word and carry decimally to destination word
* DADD.B Add source byte and carry decimally to destination byte
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 two (.B) or four (.W) binary coded decimals (BCD) with
positive signs. The source operand and the carry bit C are added decimally to the destination operand. The source
operand is not affected. The previous content of the destination is lost. The result is not defined for non-BCD numbers.
Status Bits N: Set if MSB of result is 1 (word > 7999h, byte > 79h), reset if MSB is 0
Z: Set if result is zero, reset otherwise
C: Set if the BCD result is too large (word > 9999h, byte > 99h), reset otherwise
V: Undefined
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Decimal 10 is added to the 16-bit BCD counter DECCNTR.
Example The eight-digit BCD number contained in 16-bit RAM addresses BCD and BCD+2 is added decimally to an eight-digit
BCD number contained in R4 and R5 (BCD+2 and R5 contain the MSDs). The carry C is added, and cleared.
Example The two-digit BCD number contained in word BCD (16-bit address) is added decimally to a two-digit BCD number
contained in R4. The carry C is added, also. R4.19:8 = 0CLRC ; Clear carryDADD.B &BCD,R4 ; Add BCD to R4
decimally. R4: 0,00ddh
182 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.17 DEC
* 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
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, reset if positive
Z: Set if dst contained 1, reset otherwise
C: Reset if dst contained 0, set otherwise
V: Set if an arithmetic overflow occurs, otherwise reset.
Set if initial value of destination was 08000h, otherwise reset.
Set if initial value of destination was 080h, otherwise reset.
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example R10 is decremented by 1.
Do not transfer tables using the routine above with the overlap shown in Figure 4-35.
EDE
TONI
EDE+254
TONI+254
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 183
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.18 DECD
* 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
SUB.B #2,dst
Description The destination operand is decremented by two. The original contents are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if dst contained 2, reset otherwise
C: Reset if dst contained 0 or 1, set otherwise
V: Set if an arithmetic overflow occurs, otherwise reset
Set if initial value of destination was 08001 or 08000h, otherwise reset
Set if initial value of destination was 081 or 080h, otherwise reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example R10 is decremented by 2.
DECD.B STATUS
184 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.19 DINT
* 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.
The constant 08h is inverted and logically ANDed with the SR. The result is placed into the SR.
Status Bits Status bits are not affected.
Mode Bits GIE is reset. OSCOFF and CPUOFF are not affected.
Example The general interrupt enable (GIE) bit in the SR is cleared to allow a nondisrupted move of a 32-bit counter. This
ensures that the counter is not modified during the move by any interrupt.
DINT ; All interrupt events using the GIE bit are disabled
NOP
MOV COUNTHI,R5 ; Copy counter
MOV COUNTLO,R6
EINT ; All interrupt events using the GIE bit are enabled
Note
Disable interrupt
If any code sequence needs to be protected from interruption, DINT should be executed at least one
instruction before the beginning of the uninterruptible sequence, or it should be followed by a NOP
instruction.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 185
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.20 EINT
* 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 SR are logically ORed. The result is placed into the SR.
Status Bits Status bits are not affected.
Mode Bits GIE is set. OSCOFF and CPUOFF are not affected.
Example The general interrupt enable (GIE) bit in the SR is set.
Note
Enable interrupt
The instruction following the enable interrupt instruction (EINT) is always executed, even if an interrupt
service request is pending when the interrupts are enabled.
186 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.21 INC
* 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 The destination operand is incremented by one. The original contents are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if dst contained 0FFFFh, reset otherwise
Set if dst contained 0FFh, reset otherwise
C: Set if dst contained 0FFFFh, reset otherwise
Set if dst contained 0FFh, reset otherwise
V: Set if dst contained 07FFFh, reset otherwise
Set if dst contained 07Fh, reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The status byte, STATUS, of a process is incremented. When it is equal to 11, a branch to OVFL is taken.
INC.B STATUS
CMP.B #11,STATUS
JEQ OVFL
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 187
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.22 INCD
* 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
ADD.B #2,dst
Description The destination operand is incremented by two. The original contents are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if dst contained 0FFFEh, reset otherwise
Set if dst contained 0FEh, reset otherwise
C: Set if dst contained 0FFFEh or 0FFFFh, reset otherwise
Set if dst contained 0FEh or 0FFh, reset otherwise
V: Set if dst contained 07FFEh or 07FFFh, reset otherwise
Set if dst contained 07Eh or 07Fh, reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The item on the top of the stack (TOS) is removed without using a register.
.......
PUSH R5 ; R5 is the result of a calculation, which is stored
; in the system stack
INCD SP ; Remove TOS by double-increment from stack
; Do not use INCD.B, SP is a word-aligned register
RET
188 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.23 INV
* INV[.W] Invert destination
* INV.B Invert destination
Syntax INV dst or INV.W dst
INV.B dst
Operation .not.dst → dst
Emulation XOR #0FFFFh,dst
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: Set if dst contained 0FFFFh, reset otherwise
Set if dst contained 0FFh, reset otherwise
C: Set if result is not zero, reset otherwise ( = .NOT. Zero)
V: Set if initial destination operand was negative, otherwise reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Content of R5 is negated (2s complement).
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 189
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
190 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.25 JEQ, JZ
JEQ Jump if equal
JZ Jump if zero
Syntax JEQ label
JZ label
Operation If Z = 1: PC + (2 × Offset) → PC
If Z = 0: execute following instruction
Description The zero bit Z in the SR is tested. If it is set, the signed 10-bit word offset contained in the instruction is multiplied by
two, sign extended, and added to the 20-bit PC. This means a jump in the range –511 to +512 words relative to the PC
in the full memory range. If Z is reset, the instruction after the jump is executed.
JZ is used for the test of the zero bit Z.
JEQ is used for the comparison of operands.
Status Bits Status bits are not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The state of the P2IN.0 bit defines the program flow.
Example R7 (20-bit counter) is incremented. If its content is zero, the program continues at Label4.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 191
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.26 JGE
JGE Jump if greater or equal (signed)
Syntax JGE label
Operation If (N .xor. V) = 0: PC + (2 × Offset) → PC
If (N .xor. V) = 1: execute following instruction
Description The negative bit N and the overflow bit V in the SR are tested. If both bits are set or both are reset, the signed 10-bit
word offset contained in the instruction is multiplied by two, sign extended, and added to the 20-bit PC. This means a
jump in the range -511 to +512 words relative to the PC in full Memory range. If only one bit is set, the instruction after
the jump is executed.
JGE is used for the comparison of signed operands: also for incorrect results due to overflow, the decision made by
the JGE instruction is correct.
Note: JGE emulates the nonimplemented JP (jump if positive) instruction if used after the instructions AND, BIT, RRA,
SXTX, and TST. These instructions clear the V bit.
Status Bits Status bits are not affected.
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example If byte EDE (lower 64KB) contains positive data, go to Label1. Software can run in the full memory range.
Example If the content of R6 is greater than or equal to the memory pointed to by R7, the program continues a Label5. Signed
data. Data and program in full memory range.
Example If R5 ≥ 12345h (signed operands), the program continues at Label2. Program in full memory range.
192 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.27 JL
JL Jump if less (signed)
Syntax JL label
Operation If (N .xor. V) = 1: PC + (2 × Offset) → PC
If (N .xor. V) = 0: execute following instruction
Description The negative bit N and the overflow bit V in the SR are tested. If only one is set, the signed 10-bit word offset
contained in the instruction is multiplied by two, sign extended, and added to the 20-bit PC. This means a jump in the
range –511 to +512 words relative to the PC in full memory range. If both bits N and V are set or both are reset, the
instruction after the jump is executed.
JL is used for the comparison of signed operands: also for incorrect results due to overflow, the decision made by the
JL instruction is correct.
Status Bits Status bits are not affected.
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example If byte EDE contains a smaller, signed operand than byte TONI, continue at Label1. The address EDE is within PC ±
32 K.
Example If the signed content of R6 is less than the memory pointed to by R7 (20-bit address), the program continues at
Label5. Data and program in full memory range.
Example If R5 < 12345h (signed operands), the program continues at Label2. Data and program in full memory range.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 193
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.28 JMP
JMP Jump unconditionally
Syntax JMP label
Operation PC + (2 × Offset) → PC
Description The signed 10-bit word offset contained in the instruction is multiplied by two, sign extended, and added to the 20-bit
PC. This means an unconditional jump in the range –511 to +512 words relative to the PC in the full memory. The JMP
instruction may be used as a BR or BRA instruction within its limited range relative to the PC.
Status Bits Status bits are not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The byte STATUS is set to 10. Then a jump to label MAINLOOP is made. Data in lower 64KB, program in full memory
range.
Example The interrupt vector TAIV of Timer_A3 is read and used for the program flow. Program in full memory range, but
interrupt handlers always starts in lower 64KB.
194 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.29 JN
JN Jump if negative
Syntax JN label
Operation If N = 1: PC + (2 × Offset) → PC
If N = 0: execute following instruction
Description The negative bit N in the SR is tested. If it is set, the signed 10-bit word offset contained in the instruction is multiplied
by two, sign extended, and added to the 20-bit program PC. This means a jump in the range -511 to +512 words
relative to the PC in the full memory range. If N is reset, the instruction after the jump is executed.
Status Bits Status bits are not affected.
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The byte COUNT is tested. If it is negative, program execution continues at Label0. Data in lower 64KB, program in full
memory range.
Example R6 is subtracted from R5. If the result is negative, program continues at Label2. Program in full memory range.
Example R7 (20-bit counter) is decremented. If its content is below zero, the program continues at Label4. Program in full
memory range.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 195
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
Example The word TONI is added to R5. If no carry occurs, continue at Label0. The address of TONI is within PC ± 32 K.
196 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Example If word EDE ≠ 1500, the program continues at Label2. Data in lower 64KB, program in full memory range.
Example R7 (20-bit counter) is decremented. If its content is not zero, the program continues at Label4. Program in full memory
range.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 197
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.32 MOV
MOV[.W] Move source word to destination word
MOV.B Move source byte to destination byte
Syntax MOV src,dst or MOV.W src,dst
MOV.B src,dst
Operation src → dst
Description The source operand is copied to the destination. The source operand is not affected.
Status Bits N: Not affected
Z: Not affected
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Move a 16-bit constant 1800h to absolute address-word EDE (lower 64KB)
Example The contents of table EDE (word data, 16-bit addresses) are copied to table TOM. The length of the tables is 030h
words. Both tables reside in the lower 64KB.
Example The contents of table EDE (byte data, 16-bit addresses) are copied to table TOM. The length of the tables is 020h
bytes. Both tables may reside in full memory range, but must be within R10 ± 32 K.
198 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.33 NOP
* 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 affected.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 199
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.34 POP
* 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
MOV.B @SP+,dst
Description The stack location pointed to by the SP (TOS) is moved to the destination. The SP is incremented by two afterwards.
Status Bits Status bits are not affected.
Example The contents of R7 and the SR are restored from the stack.
POP R7 ; Restore R7
POP SR ; Restore status register
Example The contents of RAM byte LEO is restored from the stack.
Example The contents of the memory pointed to by R7 and the SR are restored from the stack.
Note
System stack pointer
The system SP is always incremented by two, independent of the byte suffix.
200 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.35 PUSH
PUSH[.W] Save a word on the stack
PUSH.B Save a byte on the stack
Syntax PUSH dst or PUSH.W dst
PUSH.B dst
Operation SP – 2 → SP
dst → @SP
Description The 20-bit SP SP is decremented by two. The operand is then copied to the RAM word addressed by the SP. A
pushed byte is stored in the low byte; the high byte is not affected.
Status Bits Status bits are not affected.
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Save the two 16-bit registers R9 and R10 on the stack
Example Save the two bytes EDE and TONI on the stack. The addresses EDE and TONI are within PC ± 32 K.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 201
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.36 RET
RET Return from subroutine
Syntax RET
Operation @SP →PC.15:0 Saved PC to PC.15:0. PC.19:16 ← 0
SP + 2 → SP
Description The 16-bit return address (lower 64KB), pushed onto the stack by a CALL instruction is restored to the PC. The
program continues at the address following the subroutine call. The four MSBs of the PC.19:16 are cleared.
Status Bits Status bits are not affected.
PC.19:16: Cleared
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Call a subroutine SUBR in the lower 64KB and return to the address in the lower 64KB after the CALL.
Item n SP Item n
SP PCReturn
202 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.37 RETI
RETI Return from interrupt
Syntax RETI
Operation @SP → SR.15:0 Restore saved SR with PC.19:16
SP + 2 → SP
@SP → PC.15:0 Restore saved PC.15:0
SP + 2 → SP Housekeeping
Description The SR is restored to the value at the beginning of the interrupt service routine. This includes the four MSBs of the
PC.19:16. The SP is incremented by two afterward.
The 20-bit PC is restored from PC.19:16 (from same stack location as the status bits) and PC.15:0. The 20-bit PC is
restored to the value at the beginning of the interrupt service routine. The program continues at the address following
the last executed instruction when the interrupt was granted. The SP is incremented by two afterward.
Status Bits N: Restored from stack
C: Restored from stack
Z: Restored from stack
V: Restored from stack
Mode Bits OSCOFF, CPUOFF, and GIE are restored from stack.
Example Interrupt handler in the lower 64KB. A 20-bit return address is stored on the stack.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 203
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.38 RLA
* 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 4-37. The MSB is shifted into the carry bit (C)
and the LSB is filled with 0. The RLA instruction acts as a signed multiplication by 2.
An overflow occurs if dst ≥ 04000h and dst < 0C000h before operation is performed; the result has changed sign.
W ord 15 0
C 0
Byte 7 0
An overflow occurs if dst ≥ 040h and dst < 0C0h before the operation is performed; the result has changed sign.
Status Bits N: Set if result is negative, reset if positive
Z: Set if result is zero, reset otherwise
C: Loaded from the MSB
V: Set if an arithmetic overflow occurs; the initial value is 04000h ≤ dst < 0C000h, reset otherwise
Set if an arithmetic overflow occurs; the initial value is 040h ≤ dst < 0C0h, reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example R7 is multiplied by 2.
Note
RLA substitution
The assembler does not recognize the instructions:
RLA @R5+ RLA.B @R5+ RLA(.B) @R5
204 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.39 RLC
* 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 4-38. The carry bit (C) is shifted into the LSB,
and the MSB is shifted into the carry bit (C).
W ord 15 0
Byte 7 0
Example The input P1IN.1 information is shifted into the LSB of R5.
Note
RLA substitution
The assembler does not recognize the instructions:
RLC @R5+ RLC.B @R5+ RLC(.B) @R5
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 205
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.40 RRA
RRA[.W] Rotate right arithmetically destination word
RRA.B Rotate right arithmetically destination byte
Syntax RRA.B dst or RRA.W dst
Operation MSB → MSB → MSB–1 → ... LSB+1 → LSB → C
Description The destination operand is shifted right arithmetically by one bit position as shown in Figure 4-39. The MSB retains
its value (sign). RRA operates equal to a signed division by 2. The MSB is retained and shifted into the MSB–1. The
LSB+1 is shifted into the LSB. The previous LSB is shifted into the carry bit C.
Status Bits N: Set if result is negative (MSB = 1), reset otherwise (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Loaded from the LSB
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The signed 16-bit number in R5 is shifted arithmetically right one position.
Example The signed RAM byte EDE is shifted arithmetically right one position.
19 15 7 0
C 0 0 0 0 0 0 0 0 0 0 0 0 MSB LSB
19 15 0
C 0 0 0 0 MSB LSB
206 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.41 RRC
RRC[.W] Rotate right through carry destination word
RRC.B Rotate right through carry destination byte
Syntax RRC dst or RRC.W dst
RRC.B dst
Operation C → MSB → MSB–1 → ... LSB+1 → LSB → C
Description The destination operand is shifted right by one bit position as shown in Figure 4-40. The carry bit C is shifted into the
MSB and the LSB is shifted into the carry bit C.
Status Bits N: Set if result is negative (MSB = 1), reset otherwise (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Loaded from the LSB
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example RAM word EDE is shifted right one bit position. The MSB is loaded with 1.
19 15 7 0
C 0 0 0 0 0 0 0 0 0 0 0 0 MSB LSB
19 15 0
C 0 0 0 0 MSB LSB
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 207
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.42 SBC
* SBC[.W] Subtract borrow (.NOT. carry) from destination
* SBC.B Subtract 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 The carry bit (C) is added to the destination operand minus one. The previous contents of the destination are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the MSB of the result, reset otherwise
Set to 1 if no borrow, reset if borrow
V: Set if an arithmetic overflow occurs, reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 16-bit counter pointed to by R13 is subtracted from a 32-bit counter pointed to by R12.
Example The 8-bit counter pointed to by R13 is subtracted from a 16-bit counter pointed to by R12.
Note
Borrow implementation
The borrow is treated as a .NOT. carry:
Borrow Carry Bit
Yes 0
No 1
208 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.43 SETC
* 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:
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 209
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.44 SETN
* 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.
210 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.45 SETZ
* SETZ Set zero bit
Syntax SETZ
Operation 1→N
Emulation BIS #2,SR
Description The zero bit (Z) is set.
Status Bits N: Not affected
Z: Set
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 211
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.46 SUB
SUB[.W] Subtract source word from destination word
SUB.B Subtract source byte from destination byte
Syntax SUB src,dst or SUB.W src,dst
SUB.B src,dst
Operation (.not.src) + 1 + dst → dst or dst – src → dst
Description The source operand is subtracted from the destination operand. This is made by adding the 1s complement of the
source + 1 to the destination. The source operand is not affected, the result is written to the destination operand.
Status Bits N: Set if result is negative (src > dst), reset if positive (src ≤ dst)
Z: Set if result is zero (src = dst), reset otherwise (src ≠ dst)
C: Set if there is a carry from the MSB, reset otherwise
V: Set if the subtraction of a negative source operand from a positive destination operand delivers a negative
result, or if the subtraction of a positive source operand from a negative destination operand delivers a positive
result, reset otherwise (no overflow)
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example A 16-bit constant 7654h is subtracted from RAM word EDE.
Example A table word pointed to by R5 (20-bit address) is subtracted from R7. Afterwards, if R7 contains zero, jump to label
TONI. R5 is then auto-incremented by 2. R7.19:16 = 0.
Example Byte CNT is subtracted from byte R12 points to. The address of CNT is within PC ± 32K. The address R12 points to is
in full memory range.
212 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.47 SUBC
SUBC[.W] Subtract source word with carry from destination word
SUBC.B Subtract source byte with carry from destination byte
Syntax SUBC src,dst or SUBC.W src,dst
SUBC.B src,dst
Operation (.not.src) + C + dst → dst or dst – (src – 1) + C → dst
Description The source operand is subtracted from the destination operand. This is done by adding the 1s complement of the
source + carry to the destination. The source operand is not affected, the result is written to the destination operand.
Used for 32, 48, and 64-bit operands.
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the MSB, reset otherwise
V: Set if the subtraction of a negative source operand from a positive destination operand delivers a negative
result, or if the subtraction of a positive source operand from a negative destination operand delivers a positive
result, reset otherwise (no overflow)
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example A 16-bit constant 7654h is subtracted from R5 with the carry from the previous instruction. R5.19:16 = 0
Example A 48-bit number (3 words) pointed to by R5 (20-bit address) is subtracted from a 48-bit counter in RAM, pointed to by
R7. R5 points to the next 48-bit number afterwards. The address R7 points to is in full memory range.
Example Byte CNT is subtracted from the byte, R12 points to. The carry of the previous instruction is used. The address of CNT
is in lower 64KB.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 213
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.48 SWPB
SWPB Swap bytes
Syntax SWPB dst
Operation dst.15:8 ↔ dst.7:0
Description The high and the low byte of the operand are exchanged. PC.19:16 bits are cleared in register mode.
Status Bits Status bits are not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Exchange the bytes of RAM word EDE (lower 64KB)
Before SWPB
15 8 7 0
After SWPB
15 8 7 0
After SWPB
19 16 15 8 7 0
214 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.49 SXT
SXT Extend sign
Syntax SXT dst
Operation dst.7 → dst.15:8, dst.7 → dst.19:8 (register mode)
Description Register mode: the sign of the low byte of the operand is extended into the bits Rdst.19:8.
Other modes: the sign of the low byte of the operand is extended into the high byte.
Example The signed 8-bit data in EDE (PC +32 K) is sign extended and added to the 20-bit data in R7.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 215
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.2.50 TST
* TST[.W] Test destination
* TST.B Test 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 The destination operand is compared with zero. The status bits are set according to the result. The destination is not
affected.
Status Bits N: Set if destination is negative, reset if positive
Z: Set if destination contains zero, reset otherwise
C: Set
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example R7 is tested. If it is negative, continue at R7NEG; if it is positive but not zero, continue at R7POS.
TST R7 ; Test R7
JN R7NEG ; R7 is negative
JZ R7ZERO ; R7 is zero
R7POS ...... ; R7 is positive but not zero
R7NEG ...... ; R7 is negative
R7ZERO ...... ; R7 is zero
Example The low byte of R7 is tested. If it is negative, continue at R7NEG; if it is positive but not zero, continue at R7POS.
216 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.2.51 XOR
XOR[.W] Exclusive OR source word with destination word
XOR.B Exclusive OR source byte with destination byte
Syntax XOR src,dst or XOR.W src,dst
XOR.B src,dst
Operation src .xor. dst → dst
Description The source and destination operands are exclusively ORed. The result is placed into the destination. The source
operand is not affected. The previous content of the destination is lost.
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if result is not zero, reset otherwise (C = .not. Z)
V: Set if both operands are negative before execution, reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Toggle bits in word CNTR (16-bit data) with information (bit = 1) in address-word TONI. Both operands are located in
lower 64KB.
Example A table word pointed to by R5 (20-bit address) is used to toggle bits in R6. R6.19:16 = 0.
Example Reset to zero those bits in the low byte of R7 that are different from the bits in byte EDE. R7.19:8 = 0. The address of
EDE is within PC ± 32 K.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 217
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
218 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.1 ADCX
* ADCX.A Add carry to destination address-word
* ADCX.[W] Add carry to destination word
* ADCX.B Add carry to destination byte
Syntax ADCX.A dst
ADCX dst or ADCX.W dst
ADCX.B dst
Operation dst + C → dst
Emulation ADDCX.A #0,dst
ADDCX #0,dst
ADDCX.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 result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the MSB of the result, reset otherwise
V: Set if the result of two positive operands is negative, or if the result of two negative numbers is positive, reset
otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 40-bit counter, pointed to by R12 and R13, is incremented.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 219
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.2 ADDX
ADDX.A Add source address-word to destination address-word
ADDX.[W] Add source word to destination word
ADDX.B Add source byte to destination byte
Syntax ADDX.A src,dst
ADDX src,dst or ADDX.W src,dst
ADDX.B src,dst
Operation src + dst → dst
Description The source operand is added to the destination operand. The previous contents of the destination are lost. Both
operands can be located in the full address space.
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the MSB of the result, reset otherwise
V: Set if the result of two positive operands is negative, or if the result of two negative numbers is positive, reset
otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Ten is added to the 20-bit pointer CNTR located in two words CNTR (LSBs) and CNTR+2 (MSBs).
Example A table word (16-bit) pointed to by R5 (20-bit address) is added to R6. The jump to label TONI is performed on a carry.
Example A table byte pointed to by R5 (20-bit address) is added to R6. The jump to label TONI is performed if no carry occurs.
The table pointer is auto-incremented by 1.
Note: Use ADDA for the following two cases for better code density and execution.
ADDX.A Rsrc,Rdst
ADDX.A #imm20,Rdst
220 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.3 ADDCX
ADDCX.A Add source address-word and carry to destination address-word
ADDCX.[W] Add source word and carry to destination word
ADDCX.B Add source byte and carry to destination byte
Syntax ADDCX.A src,dst
ADDCX src,dst or ADDCX.W src,dst
ADDCX.B src,dst
Operation src + dst + C → dst
Description The source operand and the carry bit C are added to the destination operand. The previous contents of the destination
are lost. Both operands may be located in the full address space.
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the MSB of the result, reset otherwise
V: Set if the result of two positive operands is negative, or if the result of two negative numbers is positive, reset
otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Constant 15 and the carry of the previous instruction are added to the 20-bit counter CNTR located in two words.
Example A table word pointed to by R5 (20-bit address) and the carry C are added to R6. The jump to label TONI is performed
on a carry.
Example A table byte pointed to by R5 (20-bit address) and the carry bit C are added to R6. The jump to label TONI is
performed if no carry occurs. The table pointer is auto-incremented by 1.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 221
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.4 ANDX
ANDX.A Logical AND of source address-word with destination address-word
ANDX.[W] Logical AND of source word with destination word
ANDX.B Logical AND of source byte with destination byte
Syntax ANDX.A src,dst
ANDX src,dst or ANDX.W src,dst
ANDX.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. The
source operand is not affected. Both operands may be located in the full address space.
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if the result is not zero, reset otherwise. C = (.not. Z)
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The bits set in R5 (20-bit data) are used as a mask (AAA55h) for the address-word TOM located in two words. If the
result is zero, a branch is taken to label TONI.
or shorter:
Example A table byte pointed to by R5 (20-bit address) is logically ANDed with R6. R6.19:8 = 0. The table pointer is auto-
incremented by 1.
222 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.5 BICX
BICX.A Clear bits set in source address-word in destination address-word
BICX.[W] Clear bits set in source word in destination word
BICX.B Clear bits set in source byte in destination byte
Syntax BICX.A src,dst
BICX src,dst or BICX.W src,dst
BICX.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 not affected. Both operands may be located in the full address space.
Status Bits N: Not affected
Z: Not affected
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The bits 19:15 of R5 (20-bit data) are cleared.
Example A table word pointed to by R5 (20-bit address) is used to clear bits in R7. R7.19:16 = 0.
Example A table byte pointed to by R5 (20-bit address) is used to clear bits in output Port1.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 223
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.6 BISX
BISX.A Set bits set in source address-word in destination address-word
BISX.[W] Set bits set in source word in destination word
BISX.B Set bits set in source byte in destination byte
Syntax BISX.A src,dst
BISX src,dst or BISX.W src,dst
BISX.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. Both operands may be located in the full address space.
Status Bits N: Not affected
Z: Not affected
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Bits 16 and 15 of R5 (20-bit data) are set to one.
Example A table word pointed to by R5 (20-bit address) is used to set bits in R7.
Example A table byte pointed to by R5 (20-bit address) is used to set bits in output Port1.
224 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.7 BITX
BITX.A Test bits set in source address-word in destination address-word
BITX.[W] Test bits set in source word in destination word
BITX.B Test bits set in source byte in destination byte
Syntax BITX.A src,dst
BITX src,dst or BITX.W src,dst
BITX.B src,dst
Operation src .and. dst → dst
Description The source operand and the destination operand are logically ANDed. The result affects only the status bits. Both
operands may be located in the full address space.
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if the result is not zero, reset otherwise. C = (.not. Z)
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Test if bit 16 or 15 of R5 (20-bit data) is set. Jump to label TONI if so.
Example A table word pointed to by R5 (20-bit address) is used to test bits in R7. Jump to label TONI if at least one bit is set.
Example A table byte pointed to by R5 (20-bit address) is used to test bits in input Port1. Jump to label TONI if no bit is set. The
next table byte is addressed.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 225
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.8 CLRX
* CLRX.A Clear destination address-word
* CLRX.[W] Clear destination word
* CLRX.B Clear destination byte
Syntax CLRX.A dst
CLRX dst or CLRX.W dst
CLRX.B dst
Operation 0 → dst
Emulation MOVX.A #0,dst
MOVX #0,dst
MOVX.B #0,dst
Description The destination operand is cleared.
Status Bits Status bits are not affected.
Example RAM address-word TONI is cleared.
226 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.9 CMPX
CMPX.A Compare source address-word and destination address-word
CMPX.[W] Compare source word and destination word
CMPX.B Compare source byte and destination byte
Syntax CMPX.A src,dst
CMPX src,dst or CMPX.W src,dst
CMPX.B src,dst
Operation (.not. src) + 1 + dst or dst – src
Description The source operand is subtracted from the destination operand by adding the 1s complement of the source + 1 to the
destination. The result affects only the status bits. Both operands may be located in the full address space.
Status Bits N: Set if result is negative (src > dst), reset if positive (src ≤ dst)
Z: Set if result is zero (src = dst), reset otherwise (src ≠ dst)
C: Set if there is a carry from the MSB, reset otherwise
V: Set if the subtraction of a negative source operand from a positive destination operand delivers a negative
result, or if the subtraction of a positive source operand from a negative destination operand delivers a positive
result, reset otherwise (no overflow)
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Compare EDE with a 20-bit constant 18000h. Jump to label TONI if EDE equals the constant.
Example A table word pointed to by R5 (20-bit address) is compared with R7. Jump to label TONI if R7 contains a lower, signed,
16-bit number.
Example A table byte pointed to by R5 (20-bit address) is compared to the input in I/O Port1. Jump to label TONI if the values
are equal. The next table byte is addressed.
Note: Use CMPA for the following two cases for better density and execution.
CMPA Rsrc,Rdst
CMPA #imm20,Rdst
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 227
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.10 DADCX
* DADCX.A Add carry decimally to destination address-word
* DADCX.[W] Add carry decimally to destination word
* DADCX.B Add carry decimally to destination byte
Syntax DADCX.A dst
DADCX dst or DADCX.W dst
DADCX.B dst
Operation dst + C → dst (decimally)
Emulation DADDX.A #0,dst
DADDX #0,dst
DADDX.B #0,dst
Description The carry bit (C) is added decimally to the destination.
Status Bits N: Set if MSB of result is 1 (address-word > 79999h, word > 7999h, byte > 79h), reset if MSB is 0
Z: Set if result is zero, reset otherwise
C: Set if the BCD result is too large (address-word > 99999h, word > 9999h, byte > 99h), reset otherwise
V: Undefined
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 40-bit counter, pointed to by R12 and R13, is incremented decimally.
228 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.11 DADDX
DADDX.A Add source address-word and carry decimally to destination address-word
DADDX.[W] Add source word and carry decimally to destination word
DADDX.B Add source byte and carry decimally to destination byte
Syntax DADDX.A src,dst
DADDX src,dst or DADDX.W src,dst
DADDX.B src,dst
Operation src + dst + C → dst (decimally)
Description The source operand and the destination operand are treated as two (.B), four (.W), or five (.A) binary coded decimals
(BCD) with positive signs. The source operand and the carry bit C are added decimally to the destination operand. The
source operand is not affected. The previous contents of the destination are lost. The result is not defined for non-BCD
numbers. Both operands may be located in the full address space.
Status Bits N: Set if MSB of result is 1 (address-word > 79999h, word > 7999h, byte > 79h), reset if MSB is 0.
Z: Set if result is zero, reset otherwise
C: Set if the BCD result is too large (address-word > 99999h, word > 9999h, byte > 99h), reset otherwise
V: Undefined
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Decimal 10 is added to the 20-bit BCD counter DECCNTR located in two words.
Example The eight-digit BCD number contained in 20-bit addresses BCD and BCD+2 is added decimally to an eight-digit BCD
number contained in R4 and R5 (BCD+2 and R5 contain the MSDs).
Example The two-digit BCD number contained in 20-bit address BCD is added decimally to a two-digit BCD number contained
in R4.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 229
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.12 DECX
* DECX.A Decrement destination address-word
* DECX.[W] Decrement destination word
* DECX.B Decrement destination byte
Syntax DECX.A dst
DECX dst or DECX.W dst
DECX.B dst
Operation dst – 1 → dst
Emulation SUBX.A #1,dst
SUBX #1,dst
SUBX.B #1,dst
Description The destination operand is decremented by one. The original contents are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if dst contained 1, reset otherwise
C: Reset if dst contained 0, set otherwise
V: Set if an arithmetic overflow occurs, otherwise reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example RAM address-word TONI is decremented by one.
230 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.13 DECDX
* DECDX.A Double-decrement destination address-word
* DECDX.[W] Double-decrement destination word
* DECDX.B Double-decrement destination byte
Syntax DECDX.A dst
DECDX dst or DECDX.W dst
DECDX.B dst
Operation dst – 2 → dst
Emulation SUBX.A #2,dst
SUBX #2,dst
SUBX.B #2,dst
Description The destination operand is decremented by two. The original contents are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if dst contained 2, reset otherwise
C: Reset if dst contained 0 or 1, set otherwise
V: Set if an arithmetic overflow occurs, otherwise reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example RAM address-word TONI is decremented by two.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 231
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.14 INCX
* INCX.A Increment destination address-word
* INCX.[W] Increment destination word
* INCX.B Increment destination byte
Syntax INCX.A dst
INCX dst or INCX.W dst
INCX.B dst
Operation dst + 1 → dst
Emulation ADDX.A #1,dst
ADDX #1,dst
ADDX.B #1,dst
Description The destination operand is incremented by one. The original contents are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if dst contained 0FFFFFh, reset otherwise
Set if dst contained 0FFFFh, reset otherwise
Set if dst contained 0FFh, reset otherwise
C: Set if dst contained 0FFFFFh, reset otherwise
Set if dst contained 0FFFFh, reset otherwise
Set if dst contained 0FFh, reset otherwise
V: Set if dst contained 07FFFh, reset otherwise
Set if dst contained 07FFFh, reset otherwise
Set if dst contained 07Fh, reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example RAM address-word TONI is incremented by one.
232 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.15 INCDX
* INCDX.A Double-increment destination address-word
* INCDX.[W] Double-increment destination word
* INCDX.B Double-increment destination byte
Syntax INCDX.A dst
INCDX dst or INCDX.W dst
INCDX.B dst
Operation dst + 2 → dst
Emulation ADDX.A #2,dst
ADDX #2,dst
ADDX.B #2,dst
Description The destination operand is incremented by two. The original contents are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if dst contained 0FFFFEh, reset otherwise
Set if dst contained 0FFFEh, reset otherwise
Set if dst contained 0FEh, reset otherwise
C: Set if dst contained 0FFFFEh or 0FFFFFh, reset otherwise
Set if dst contained 0FFFEh or 0FFFFh, reset otherwise
Set if dst contained 0FEh or 0FFh, reset otherwise
V: Set if dst contained 07FFFEh or 07FFFFh, reset otherwise
Set if dst contained 07FFEh or 07FFFh, reset otherwise
Set if dst contained 07Eh or 07Fh, reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example RAM byte LEO is incremented by two; PC points to upper memory.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 233
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.16 INVX
* INVX.A Invert destination
* INVX.[W] Invert destination
* INVX.B Invert destination
Syntax INVX.A dst
INVX dst or INVX.W dst
INVX.B dst
Operation .NOT.dst → dst
Emulation XORX.A #0FFFFFh,dst
XORX #0FFFFh,dst
XORX.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: Set if dst contained 0FFFFFh, reset otherwise
Set if dst contained 0FFFFh, reset otherwise
Set if dst contained 0FFh, reset otherwise
C: Set if result is not zero, reset otherwise ( = .NOT. Zero)
V: Set if initial destination operand was negative, otherwise reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example 20-bit content of R5 is negated (2s complement).
INVX.A R5 ; Invert R5
INCX.A R5 ; R5 is now negated
234 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.17 MOVX
MOVX.A Move source address-word to destination address-word
MOVX.[W] Move source word to destination word
MOVX.B Move source byte to destination byte
Syntax MOVX.A src,dst
MOVX src,dst or MOVX.W src,dst
MOVX.B src,dst
Operation src → dst
Description The source operand is copied to the destination. The source operand is not affected. Both operands may be located in
the full address space.
Status Bits N: Not affected
Z: Not affected
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Move a 20-bit constant 18000h to absolute address-word EDE
Example The contents of table EDE (word data, 20-bit addresses) are copied to table TOM. The length of the table is 030h
words.
Example The contents of table EDE (byte data, 20-bit addresses) are copied to table TOM. The length of the table is 020h
bytes.
Ten of the 28 possible addressing combinations of the MOVX.A instruction can use the MOVA instruction. This saves
two bytes and code cycles. Examples for the addressing combinations are:
The next four replacements are possible only if 16-bit indexes are sufficient for the addressing:
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 235
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
236 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.18 POPM
POPM.A Restore n CPU registers (20-bit data) from the stack
POPM.[W] Restore n CPU registers (16-bit data) from the stack
Syntax POPM.A #n,Rdst 1 ≤ n ≤ 16
POPM.W #n,Rdst or POPM #n,Rdst 1 ≤ n ≤ 16
Operation POPM.A: Restore the register values from stack to the specified CPU registers. The SP is incremented by four for
each register restored from stack. The 20-bit values from stack (two words per register) are restored to the registers.
POPM.W: Restore the 16-bit register values from stack to the specified CPU registers. The SP is incremented by two
for each register restored from stack. The 16-bit values from stack (one word per register) are restored to the CPU
registers.
Note : This instruction does not use the extension word.
Description POPM.A: The CPU registers pushed on the stack are moved to the extended CPU registers, starting with the CPU
register (Rdst – n + 1). The SP is incremented by (n × 4) after the operation.
POPM.W: The 16-bit registers pushed on the stack are moved back to the CPU registers, starting with CPU register
(Rdst – n + 1). The SP is incremented by (n × 2) after the instruction. The MSBs (Rdst.19:16) of the restored CPU
registers are cleared.
Status Bits Status bits are not affected, except SR is included in the operation.
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Restore the 20-bit registers R9, R10, R11, R12, R13 from the stack
Example Restore the 16-bit registers R9, R10, R11, R12, R13 from the stack.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 237
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.19 PUSHM
PUSHM.A Save n CPU registers (20-bit data) on the stack
PUSHM.[W] Save n CPU registers (16-bit words) on the stack
Syntax PUSHM.A #n,Rdst 1 ≤ n ≤ 16
PUSHM.W #n,Rdst or PUSHM #n,Rdst 1 ≤ n ≤ 16
Operation PUSHM.A: Save the 20-bit CPU register values on the stack. The SP is decremented by four for each register stored
on the stack. The MSBs are stored first (higher address).
PUSHM.W: Save the 16-bit CPU register values on the stack. The SP is decremented by two for each register stored
on the stack.
Description PUSHM.A: The n CPU registers, starting with Rdst backwards, are stored on the stack. The SP is decremented by (n
× 4) after the operation. The data (Rn.19:0) of the pushed CPU registers is not affected.
PUSHM.W: The n registers, starting with Rdst backwards, are stored on the stack. The SP is decremented by (n × 2)
after the operation. The data (Rn.19:0) of the pushed CPU registers is not affected.
Note : This instruction does not use the extension word.
Status Bits Status bits are not affected.
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Save the five 20-bit registers R9, R10, R11, R12, R13 on the stack
Example Save the five 16-bit registers R9, R10, R11, R12, R13 on the stack
238 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.20 POPX
* POPX.A Restore single address-word from the stack
* POPX.[W] Restore single word from the stack
* POPX.B Restore single byte from the stack
Syntax POPX.A dst
POPX dst or POPX.W dst
POPX.B dst
Operation Restore the 8-/16-/20-bit value from the stack to the destination. 20-bit addresses are possible. The SP is
incremented by two (byte and word operands) and by four (address-word operand).
Emulation MOVX(.B,.A) @SP+,dst
Description The item on TOS is written to the destination operand. Register mode, Indexed mode, Symbolic mode, and Absolute
mode are possible. The SP is incremented by two or four.
Note: The SP is incremented by two also for byte operations.
Status Bits Status bits are not affected.
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Write the 16-bit value on TOS to the 20-bit address &EDE
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 239
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.21 PUSHX
PUSHX.A Save single address-word to the stack
PUSHX.[W] Save single word to the stack
PUSHX.B Save single byte to the stack
Syntax PUSHX.A src
PUSHX src or PUSHX.W src
PUSHX.B src
Operation Save the 8-/16-/20-bit value of the source operand on the TOS. 20-bit addresses are possible. The SP is
decremented by two (byte and word operands) or by four (address-word operand) before the write operation.
Description The SP is decremented by two (byte and word operands) or by four (address-word operand). Then the source
operand is written to the TOS. All seven addressing modes are possible for the source operand.
Status Bits Status bits are not affected.
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Save the byte at the 20-bit address &EDE on the stack
240 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.22 RLAM
RLAM.A Rotate left arithmetically the 20-bit CPU register content
RLAM.[W] Rotate left arithmetically the 16-bit CPU register content
Syntax RLAM.A #n,Rdst 1≤n≤4
RLAM.W #n,Rdst or RLAM #n,Rdst 1≤n≤4
Operation C ← MSB ← MSB-1 .... LSB+1 ← LSB ← 0
Description The destination operand is shifted arithmetically left one, two, three, or four positions as shown in Figure 4-43. RLAM
works as a multiplication (signed and unsigned) with 2, 4, 8, or 16. The word instruction RLAM.W clears the bits
Rdst.19:16.
Note : This instruction does not use the extension word.
Status Bits N: Set if result is negative
.A: Rdst.19 = 1, reset if Rdst.19 = 0
.W: Rdst.15 = 1, reset if Rdst.15 = 0
Z: Set if result is zero, reset otherwise
C: Loaded from the MSB (n = 1), MSB-1 (n = 2), MSB-2 (n = 3), MSB-3 (n = 4)
V: Undefined
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 20-bit operand in R5 is shifted left by three positions. It operates equal to an arithmetic multiplication by 8.
RLAM.A #3,R5 ; R5 = R5 x 8
19 16 15 0
19 0
C MSB LSB 0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 241
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.23 RLAX
* RLAX.A Rotate left arithmetically address-word
* RLAX.[W] Rotate left arithmetically word
* RLAX.B Rotate left arithmetically byte
Syntax RLAX.A dst
RLAX dst or RLAX.W dst
RLAX.B dst
Operation C ← MSB ← MSB-1 .... LSB+1 ← LSB ← 0
Emulation ADDX.A dst,dst
ADDX dst,dst
ADDX.B dst,dst
Description The destination operand is shifted left one position as shown in Figure 4-44. The MSB is shifted into the carry bit (C)
and the LSB is filled with 0. The RLAX instruction acts as a signed multiplication by 2.
Status Bits N: Set if result is negative, reset if positive
Z: Set if result is zero, reset otherwise
C: Loaded from the MSB
V: Set if an arithmetic overflow occurs: the initial value is 040000h ≤ dst < 0C0000h; reset otherwise
Set if an arithmetic overflow occurs: the initial value is 04000h ≤ dst < 0C000h; reset otherwise
Set if an arithmetic overflow occurs: the initial value is 040h ≤ dst < 0C0h; reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 20-bit value in R7 is multiplied by 2
C MSB LSB 0
242 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.24 RLCX
* RLCX.A Rotate left through carry address-word
* RLCX.[W] Rotate left through carry word
* RLCX.B Rotate left through carry byte
Syntax RLCX.A dst
RLCX dst or RLCX.W dst
RLCX.B dst
Operation C ← MSB ← MSB-1 .... LSB+1 ← LSB ← C
Emulation ADDCX.A dst,dst
ADDCX dst,dst
ADDCX.B dst,dst
Description The destination operand is shifted left one position as shown in Figure 4-45. The carry bit (C) is shifted into the LSB
and the MSB is shifted into the carry bit (C).
Status Bits N: Set if result is negative, reset if positive
Z: Set if result is zero, reset otherwise
C: Loaded from the MSB
V: Set if an arithmetic overflow occurs: the initial value is 040000h ≤ dst < 0C0000h; reset otherwise
Set if an arithmetic overflow occurs: the initial value is 04000h ≤ dst < 0C000h; reset otherwise
Set if an arithmetic overflow occurs: the initial value is 040h ≤ dst < 0C0h; reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 20-bit value in R5 is shifted left one position.
Example The RAM byte LEO is shifted left one position. PC is pointing to upper memory.
C MSB LSB
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 243
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.25 RRAM
RRAM.A Rotate right arithmetically the 20-bit CPU register content
RRAM.[W] Rotate right arithmetically the 16-bit CPU register content
Syntax RRAM.A #n,Rdst 1≤n≤4
RRAM.W #n,Rdst or RRAM #n,Rdst 1≤n≤4
Operation MSB → MSB → MSB–1 ... LSB+1 → LSB → C
Description The destination operand is shifted right arithmetically by one, two, three, or four bit positions as shown in Figure 4-46.
The MSB retains its value (sign). RRAM operates equal to a signed division by 2/4/8/16. The MSB is retained and
shifted into MSB-1. The LSB+1 is shifted into the LSB, and the LSB is shifted into the carry bit C. The word instruction
RRAM.W clears the bits Rdst.19:16.
Note : This instruction does not use the extension word.
Status Bits N: Set if result is negative
.A: Rdst.19 = 1, reset if Rdst.19 = 0
.W: Rdst.15 = 1, reset if Rdst.15 = 0
Z: Set if result is zero, reset otherwise
C: Loaded from the LSB (n = 1), LSB+1 (n = 2), LSB+2 (n = 3), or LSB+3 (n = 4)
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The signed 20-bit number in R5 is shifted arithmetically right two positions.
Example The signed 20-bit value in R15 is multiplied by 0.75. (0.5 + 0.25) × R15.
19 16 15 0
19 0
C MSB LSB
244 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.26 RRAX
RRAX.A Rotate right arithmetically the 20-bit operand
RRAX.[W] Rotate right arithmetically the 16-bit operand
RRAX.B Rotate right arithmetically the 8-bit operand
Syntax RRAX.A Rdst
RRAX.W Rdst
RRAX Rdst
RRAX.B Rdst
RRAX.A dst
RRAX dst or RRAX.W dst
RRAX.B dst
Operation MSB → MSB → MSB–1 ... LSB+1 → LSB → C
Description Register mode for the destination: the destination operand is shifted right by one bit position as shown in Figure
4-47. The MSB retains its value (sign). The word instruction RRAX.W clears the bits Rdst.19:16, the byte instruction
RRAX.B clears the bits Rdst.19:8. The MSB retains its value (sign), the LSB is shifted into the carry bit. RRAX here
operates equal to a signed division by 2.
All other modes for the destination: the destination operand is shifted right arithmetically by one bit position as shown
in Figure 4-48. The MSB retains its value (sign), the LSB is shifted into the carry bit. RRAX here operates equal
to a signed division by 2. All addressing modes, with the exception of the Immediate mode, are possible in the full
memory.
Status Bits N: Set if result is negative, reset if positive
.A: dst.19 = 1, reset if dst.19 = 0
.W: dst.15 = 1, reset if dst.15 = 0
.B: dst.7 = 1, reset if dst.7 = 0
Z: Set if result is zero, reset otherwise
C: Loaded from the LSB
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The signed 20-bit number in R5 is shifted arithmetically right four positions.
RPT #4
RRAX.A R5 ; R5/16 -> R5
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 245
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
19 8 7 0
C 0 0 MSB LSB
19 16 15 0
19 0
C MSB LSB
C MSB LSB
15 0
C MSB LSB
31 20
0 0
19 0
C MSB LSB
246 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.27 RRCM
RRCM.A Rotate right through carry the 20-bit CPU register content
RRCM.[W] Rotate right through carry the 16-bit CPU register content
Syntax RRCM.A #n,Rdst 1≤n≤4
RRCM.W #n,Rdst or RRCM #n,Rdst 1≤n≤4
Operation C → MSB → MSB–1 ... LSB+1 → LSB → C
Description The destination operand is shifted right by one, two, three, or four bit positions as shown in Figure 4-49. The carry
bit C is shifted into the MSB, the LSB is shifted into the carry bit. The word instruction RRCM.W clears the bits
Rdst.19:16.
Note : This instruction does not use the extension word.
Status Bits N: Set if result is negative
.A: Rdst.19 = 1, reset if Rdst.19 = 0
.W: Rdst.15 = 1, reset if Rdst.15 = 0
Z: Set if result is zero, reset otherwise
C: Loaded from the LSB (n = 1), LSB+1 (n = 2), LSB+2 (n = 3), or LSB+3 (n = 4)
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The address-word in R5 is shifted right by three positions. The MSB–2 is loaded with 1.
Example The word in R6 is shifted right by two positions. The MSB is loaded with the LSB. The MSB–1 is loaded with the
contents of the carry flag.
19 16 15 0
C 0 MSB LSB
19 0
C MSB LSB
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 247
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.28 RRCX
RRCX.A Rotate right through carry the 20-bit operand
RRCX.[W] Rotate right through carry the 16-bit operand
RRCX.B Rotate right through carry the 8-bit operand
Syntax RRCX.A Rdst
RRCX.W Rdst
RRCX Rdst
RRCX.B Rdst
RRCX.A dst
RRCX dst or RRCX.W dst
RRCX.B dst
Operation C → MSB → MSB–1 ... LSB+1 → LSB → C
Description Register mode for the destination: the destination operand is shifted right by one bit position as shown in Figure 4-50.
The word instruction RRCX.W clears the bits Rdst.19:16, the byte instruction RRCX.B clears the bits Rdst.19:8. The
carry bit C is shifted into the MSB, the LSB is shifted into the carry bit.
All other modes for the destination: the destination operand is shifted right by one bit position as shown in Figure
4-51. The carry bit C is shifted into the MSB, the LSB is shifted into the carry bit. All addressing modes, with the
exception of the Immediate mode, are possible in the full memory.
Status Bits N: Set if result is negative
.A: dst.19 = 1, reset if dst.19 = 0
.W: dst.15 = 1, reset if dst.15 = 0
.B: dst.7 = 1, reset if dst.7 = 0
Z: Set if result is zero, reset otherwise
C: Loaded from the LSB
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 20-bit operand at address EDE is shifted right by one position. The MSB is loaded with 1.
RPT #12
RRCX.W R6 ; R6 = R6 » 12. R6.19:16 = 0
248 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
19 8 7 0
19 16 15 0
C 0 0 0 0 MSB LSB
19 0
C MSB LSB
C MSB LSB
15 0
C MSB LSB
31 20
0 0
19 0
C MSB LSB
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 249
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.29 RRUM
RRUM.A Rotate right through carry the 20-bit CPU register content
RRUM.[W] Rotate right through carry the 16-bit CPU register content
Syntax RRUM.A #n,Rdst 1≤n≤4
RRUM.W #n,Rdst or RRUM #n,Rdst 1≤n≤4
Operation 0 → MSB → MSB–1 ... LSB+1 → LSB → C
Description The destination operand is shifted right by one, two, three, or four bit positions as shown in Figure 4-52. Zero is
shifted into the MSB, the LSB is shifted into the carry bit. RRUM works like an unsigned division by 2, 4, 8, or 16. The
word instruction RRUM.W clears the bits Rdst.19:16.
Note : This instruction does not use the extension word.
Status Bits N: Set if result is negative
.A: Rdst.19 = 1, reset if Rdst.19 = 0
.W: Rdst.15 = 1, reset if Rdst.15 = 0
Z: Set if result is zero, reset otherwise
C: Loaded from the LSB (n = 1), LSB+1 (n = 2), LSB+2 (n = 3), or LSB+3 (n = 4)
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The unsigned address-word in R5 is divided by 16.
Example The word in R6 is shifted right by one bit. The MSB R6.15 is loaded with 0.
19 16 15 0
19 0
C 0 MSB LSB
250 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.30 RRUX
RRUX.A Shift right unsigned the 20-bit CPU register content
RRUX.[W] Shift right unsigned the 16-bit CPU register content
RRUX.B Shift right unsigned the 8-bit CPU register content
Syntax RRUX.A Rdst
RRUX.W Rdst
RRUX Rdst
RRUX.B Rdst
Operation C=0 → MSB → MSB–1 ... LSB+1 → LSB → C
Description RRUX is valid for register mode only: the destination operand is shifted right by one bit position as shown in
Figure 4-53. The word instruction RRUX.W clears the bits Rdst.19:16. The byte instruction RRUX.B clears the bits
Rdst.19:8. Zero is shifted into the MSB, the LSB is shifted into the carry bit.
Status Bits N: Set if result is negative
.A: dst.19 = 1, reset if dst.19 = 0
.W: dst.15 = 1, reset if dst.15 = 0
.B: dst.7 = 1, reset if dst.7 = 0
Z: Set if result is zero, reset otherwise
C: Loaded from the LSB
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The word in R6 is shifted right by 12 positions.
RPT #12
RRUX.W R6 ; R6 = R6 » 12. R6.19:16 = 0
19 8 7 0
0
19 16 15 0
C 0 0 0 0 MSB LSB
19 0
C 0 MSB LSB
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 251
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.31 SBCX
* SBCX.A Subtract borrow (.NOT. carry) from destination address-word
* SBCX.[W] Subtract borrow (.NOT. carry) from destination word
* SBCX.B Subtract borrow (.NOT. carry) from destination byte
Syntax SBCX.A dst
SBCX dst or SBCX.W dst
SBCX.B dst
Operation dst + 0FFFFFh + C → dst
dst + 0FFFFh + C → dst
dst + 0FFh + C → dst
Emulation SBCX.A #0,dst
SBCX #0,dst
SBCX.B #0,dst
Description The carry bit (C) is added to the destination operand minus one. The previous contents of the destination are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the MSB of the result, reset otherwise
Set to 1 if no borrow, reset if borrow
V: Set if an arithmetic overflow occurs, reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 8-bit counter pointed to by R13 is subtracted from a 16-bit counter pointed to by R12.
Note
Borrow implementation
The borrow is treated as a .NOT. carry:
Borrow Carry Bit
Yes 0
No 1
252 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.32 SUBX
SUBX.A Subtract source address-word from destination address-word
SUBX.[W] Subtract source word from destination word
SUBX.B Subtract source byte from destination byte
Syntax SUBX.A src,dst
SUBX src,dst or SUBX.W src,dst
SUBX.B src,dst
Operation (.not. src) + 1 + dst → dst or dst – src → dst
Description The source operand is subtracted from the destination operand. This is done by adding the 1s complement of the
source + 1 to the destination. The source operand is not affected. The result is written to the destination operand. Both
operands may be located in the full address space.
Status Bits N: Set if result is negative (src > dst), reset if positive (src ≤ dst)
Z: Set if result is zero (src = dst), reset otherwise (src ≠ dst)
C: Set if there is a carry from the MSB, reset otherwise
V: Set if the subtraction of a negative source operand from a positive destination operand delivers a negative
result, or if the subtraction of a positive source operand from a negative destination operand delivers a positive
result, reset otherwise (no overflow)
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example A 20-bit constant 87654h is subtracted from EDE (LSBs) and EDE+2 (MSBs).
Example A table word pointed to by R5 (20-bit address) is subtracted from R7. Jump to label TONI if R7 contains zero after the
instruction. R5 is auto-incremented by two. R7.19:16 = 0.
Example Byte CNT is subtracted from the byte R12 points to in the full address space. Address of CNT is within PC ± 512 K.
Note: Use SUBA for the following two cases for better density and execution.
SUBX.A Rsrc,Rdst
SUBX.A #imm20,Rdst
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 253
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.33 SUBCX
SUBCX.A Subtract source address-word with carry from destination address-word
SUBCX.[W] Subtract source word with carry from destination word
SUBCX.B Subtract source byte with carry from destination byte
Syntax SUBCX.A src,dst
SUBCX src,dst or SUBCX.W src,dst
SUBCX.B src,dst
Operation (.not. src) + C + dst → dst or dst – (src – 1) + C → dst
Description The source operand is subtracted from the destination operand. This is made by adding the 1s complement of the
source + carry to the destination. The source operand is not affected, the result is written to the destination operand.
Both operands may be located in the full address space.
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the MSB, reset otherwise
V: Set if the subtraction of a negative source operand from a positive destination operand delivers a negative
result, or if the subtraction of a positive source operand from a negative destination operand delivers a positive
result, reset otherwise (no overflow).
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example A 20-bit constant 87654h is subtracted from R5 with the carry from the previous instruction.
Example A 48-bit number (3 words) pointed to by R5 (20-bit address) is subtracted from a 48-bit counter in RAM, pointed to by
R7. R5 auto-increments to point to the next 48-bit number.
Example Byte CNT is subtracted from the byte R12 points to. The carry of the previous instruction is used. 20-bit addresses.
254 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.34 SWPBX
SWPBX.A Swap bytes of lower word
SWPBX.[W] Swap bytes of word
Syntax SWPBX.A dst
SWPBX dst or SWPBX.W dst
Operation dst.15:8 ↔ dst.7:0
Description Register mode: Rn.15:8 are swapped with Rn.7:0. When the .A extension is used, Rn.19:16 are unchanged. When
the .W extension is used, Rn.19:16 are cleared.
Other modes: When the .A extension is used, bits 31:20 of the destination address are cleared, bits 19:16 are left
unchanged, and bits 15:8 are swapped with bits 7:0. When the .W extension is used, bits 15:8 are swapped with bits
7:0 of the addressed word.
Status Bits Status bits are not affected.
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Exchange the bytes of RAM address-word EDE
Before SWPBX.A
19 16 15 8 7 0
After SWPBX.A
19 16 15 8 7 0
After SWPBX.A
31 20 19 16 15 8 7 0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 255
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
Before SWPBX
19 16 15 8 7 0
After SWPBX
19 16 15 8 7 0
After SWPBX
15 8 7 0
256 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.35 SXTX
SXTX.A Extend sign of lower byte to address-word
SXTX.[W] Extend sign of lower byte to word
Syntax SXTX.A dst
SXTX dst or SXTX.W dst
Operation dst.7 → dst.15:8, Rdst.7 → Rdst.19:8 (Register mode)
Description Register mode: The sign of the low byte of the operand (Rdst.7) is extended into the bits Rdst.19:8.
Other modes: SXTX.A: the sign of the low byte of the operand (dst.7) is extended into dst.19:8. The bits dst.31:20 are
cleared.
SXTX[.W]: the sign of the low byte of the operand (dst.7) is extended into dst.15:8.
Status Bits N: Set if result is negative, reset otherwise
Z: Set if result is zero, reset otherwise
C: Set if result is not zero, reset otherwise (C = .not.Z)
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The signed 8-bit data in EDE.7:0 is sign extended to 20 bits: EDE.19:8. Bits 31:20 located in EDE+2 are cleared.
SXTX.A Rdst
19 16 15 8 7 6 0
SXTX.A dst
31 20 19 16 15 8 7 6 0
0 ...... 0 S
SXTX[.W] dst
15 8 7 6 0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 257
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.3.36 TSTX
* TSTX.A Test destination address-word
* TSTX.[W] Test destination word
* TSTX.B Test destination byte
Syntax TSTX.A dst
TSTX dst or TSTX.W dst
TSTX.B dst
Operation dst + 0FFFFFh + 1
dst + 0FFFFh + 1
dst + 0FFh + 1
Emulation CMPX.A #0,dst
CMPX #0,dst
CMPX.B #0,dst
Description The destination operand is compared with zero. The status bits are set according to the result. The destination is not
affected.
Status Bits N: Set if destination is negative, reset if positive
Z: Set if destination contains zero, reset otherwise
C: Set
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example RAM byte LEO is tested; PC is pointing to upper memory. If it is negative, continue at LEONEG; if it is positive but not
zero, continue at LEOPOS.
258 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.3.37 XORX
XORX.A Exclusive OR source address-word with destination address-word
XORX.[W] Exclusive OR source word with destination word
XORX.B Exclusive OR source byte with destination byte
Syntax XORX.A src,dst
XORX src,dst or XORX.W src,dst
XORX.B src,dst
Operation src .xor. dst → dst
Description The source and destination operands are exclusively ORed. The result is placed into the destination. The source
operand is not affected. The previous contents of the destination are lost. Both operands may be located in the full
address space.
Status Bits N: Set if result is negative (MSB = 1), reset if positive (MSB = 0)
Z: Set if result is zero, reset otherwise
C: Set if result is not zero, reset otherwise (carry = .not. Zero)
V: Set if both operands are negative (before execution), reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Toggle bits in address-word CNTR (20-bit data) with information in address-word TONI (20-bit address)
Example A table word pointed to by R5 (20-bit address) is used to toggle bits in R6.
Example Reset to zero those bits in the low byte of R7 that are different from the bits in byte EDE (20-bit address)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 259
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
260 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.4.1 ADDA
ADDA Add 20-bit source to a 20-bit destination register
Syntax ADDA Rsrc,Rdst
ADDA #imm20,Rdst
Operation src + Rdst → Rdst
Description The 20-bit source operand is added to the 20-bit destination CPU register. The previous contents of the destination
are lost. The source operand is not affected.
Status Bits N: Set if result is negative (Rdst.19 = 1), reset if positive (Rdst.19 = 0)
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the 20-bit result, reset otherwise
V: Set if the result of two positive operands is negative, or if the result of two negative numbers is positive, reset
otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example R5 is increased by 0A4320h. The jump to TONI is performed if a carry occurs.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 261
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.4.2 BRA
* BRA Branch to destination
Syntax BRA dst
Operation dst → PC
Emulation MOVA dst,PC
Description An unconditional branch is taken to a 20-bit address anywhere in the full address space. All seven source addressing
modes can be used. The branch instruction is an address-word instruction. If the destination address is contained in a
memory location X, it is contained in two ascending words: X (LSBs) and (X + 2) (MSBs).
Status Bits N: Not affected
Z: Not affected
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Examples Examples for all addressing modes are given.
Immediate mode: Branch to label EDE located anywhere in the 20-bit address space or branch directly to address.
Symbolic mode: Branch to the 20-bit address contained in addresses EXEC (LSBs) and EXEC+2 (MSBs). EXEC is
located at the address (PC + X) where X is within +32 K. Indirect addressing.
Note: If the 16-bit index is not sufficient, a 20-bit index may be used with the following instruction.
Absolute mode: Branch to the 20-bit address contained in absolute addresses EXEC (LSBs) and EXEC+2 (MSBs).
Indirect addressing.
Register mode: Branch to the 20-bit address contained in register R5. Indirect R5.
Indirect mode: Branch to the 20-bit address contained in the word pointed to by register R5 (LSBs). The MSBs have
the address (R5 + 2). Indirect, indirect R5.
Indirect, Auto-Increment mode: Branch to the 20-bit address contained in the words pointed to by register R5 and
increment the address in R5 afterwards by 4. The next time the S/W flow uses R5 as a pointer, it can alter the
program execution due to access to the next address in the table pointed to by R5. Indirect, indirect R5.
262 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Indexed mode: Branch to the 20-bit address contained in the address pointed to by register (R5 + X) (for example, a
table with addresses starting at X). (R5 + X) points to the LSBs, (R5 + X + 2) points to the MSBs of the address. X is
within R5 + 32 K. Indirect, indirect (R5 + X).
Note: If the 16-bit index is not sufficient, a 20-bit index X may be used with the following instruction:
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 263
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.4.3 CALLA
CALLA Call a subroutine
Syntax CALLA dst
Operation dst → tmp 20-bit dst is evaluated and stored
SP – 2 → SP
PC.19:16 → @SP updated PC with return address to TOS (MSBs)
SP – 2 → SP
PC.15:0 → @SP updated PC to TOS (LSBs)
tmp → PC saved 20-bit dst to PC
Description A subroutine call is made to a 20-bit address anywhere in the full address space. All seven source addressing modes
can be used. The call instruction is an address-word instruction. If the destination address is contained in a memory
location X, it is contained in two ascending words, X (LSBs) and (X + 2) (MSBs). Two words on the stack are needed
for the return address. The return is made with the instruction RETA.
Status Bits N: Not affected
Z: Not affected
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Examples Examples for all addressing modes are given.
Immediate mode: Call a subroutine at label EXEC or call directly an address.
Symbolic mode: Call a subroutine at the 20-bit address contained in addresses EXEC (LSBs) and EXEC+2 (MSBs).
EXEC is located at the address (PC + X) where X is within +32 K. Indirect addressing.
Absolute mode: Call a subroutine at the 20-bit address contained in absolute addresses EXEC (LSBs) and EXEC+2
(MSBs). Indirect addressing.
Register mode: Call a subroutine at the 20-bit address contained in register R5. Indirect R5.
Indirect mode: Call a subroutine at the 20-bit address contained in the word pointed to by register R5 (LSBs). The
MSBs have the address (R5 + 2). Indirect, indirect R5.
Indirect, Auto-Increment mode: Call a subroutine at the 20-bit address contained in the words pointed to by register
R5 and increment the 20-bit address in R5 afterwards by 4. The next time the S/W flow uses R5 as a pointer, it can
alter the program execution due to access to the next word address in the table pointed to by R5. Indirect, indirect
R5.
264 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Indexed mode: Call a subroutine at the 20-bit address contained in the address pointed to by register (R5 + X); for
example, a table with addresses starting at X. (R5 + X) points to the LSBs, (R5 + X + 2) points to the MSBs of the
word address. X is within R5 + 32 K. Indirect, indirect (R5 + X).
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 265
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.4.4 CLRA
* CLRA Clear 20-bit destination register
Syntax CLRA Rdst
Operation 0 → Rdst
Emulation MOVA #0,Rdst
Description The destination register is cleared.
Status Bits Status bits are not affected.
Example The 20-bit value in R10 is cleared.
266 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.4.5 CMPA
CMPA Compare the 20-bit source with a 20-bit destination register
Syntax CMPA Rsrc,Rdst
CMPA #imm20,Rdst
Operation (.not. src) + 1 + Rdst or Rdst – src
Description The 20-bit source operand is subtracted from the 20-bit destination CPU register. This is made by adding the 1s
complement of the source + 1 to the destination register. The result affects only the status bits.
Status Bits N: Set if result is negative (src > dst), reset if positive (src ≤ dst)
Z: Set if result is zero (src = dst), reset otherwise (src ≠ dst)
C: Set if there is a carry from the MSB, reset otherwise
V: Set if the subtraction of a negative source operand from a positive destination operand delivers a negative
result, or if the subtraction of a positive source operand from a negative destination operand delivers a
positive result, reset otherwise (no overflow)
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example A 20-bit immediate operand and R6 are compared. If they are equal, the program continues at label EQUAL.
Example The 20-bit values in R5 and R6 are compared. If R5 is greater than (signed) or equal to R6, the program continues at
label GRE.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 267
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.4.6 DECDA
* DECDA Double-decrement 20-bit destination register
Syntax DECDA Rdst
Operation Rdst – 2 → Rdst
Emulation SUBA #2,Rdst
Description The destination register is decremented by two. The original contents are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if Rdst contained 2, reset otherwise
C: Reset if Rdst contained 0 or 1, set otherwise
V: Set if an arithmetic overflow occurs, otherwise reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 20-bit value in R5 is decremented by 2.
268 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.4.7 INCDA
* INCDA Double-increment 20-bit destination register
Syntax INCDA Rdst
Operation Rdst + 2 → Rdst
Emulation ADDA #2,Rdst
Description The destination register is incremented by two. The original contents are lost.
Status Bits N: Set if result is negative, reset if positive
Z: Set if Rdst contained 0FFFFEh, reset otherwise
Set if Rdst contained 0FFFEh, reset otherwise
Set if Rdst contained 0FEh, reset otherwise
C: Set if Rdst contained 0FFFFEh or 0FFFFFh, reset otherwise
Set if Rdst contained 0FFFEh or 0FFFFh, reset otherwise
Set if Rdst contained 0FEh or 0FFh, reset otherwise
V: Set if Rdst contained 07FFFEh or 07FFFFh, reset otherwise
Set if Rdst contained 07FFEh or 07FFFh, reset otherwise
Set if Rdst contained 07Eh or 07Fh, reset otherwise
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 20-bit value in R5 is incremented by two.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 269
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.4.8 MOVA
MOVA Move the 20-bit source to the 20-bit destination
Syntax MOVA Rsrc,Rdst
MOVA #imm20,Rdst
MOVA z16(Rsrc),Rdst
MOVA EDE,Rdst
MOVA &abs20,Rdst
MOVA @Rsrc,Rdst
MOVA @Rsrc+,Rdst
MOVA Rsrc,z16(Rdst)
MOVA Rsrc,&abs20
Operation src → Rdst
Rsrc → dst
Description The 20-bit source operand is moved to the 20-bit destination. The source operand is not affected. The previous
content of the destination is lost.
Status Bits N: Not affected
Z: Not affected
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Examples Copy 20-bit value in R9 to R8
Copy 20-bit value addressed by (R9 + 100h) to R8. Source operand in addresses (R9 + 100h) LSBs and (R9 + 102h)
MSBs.
Move 20-bit value in 20-bit absolute addresses EDE (LSBs) and EDE+2 (MSBs) to R12
Move 20-bit value in 20-bit addresses EDE (LSBs) and EDE+2 (MSBs) to R12. PC index ± 32 K.
Copy 20-bit value R9 points to (20 bit address) to R8. Source operand in addresses @R9 LSBs and @(R9 + 2)
MSBs.
270 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
Copy 20-bit value R9 points to (20 bit address) to R8. R9 is incremented by four afterwards. Source operand in
addresses @R9 LSBs and @(R9 + 2) MSBs.
Copy 20-bit value in R8 to destination addressed by (R9 + 100h). Destination operand in addresses @(R9 + 100h)
LSBs and @(R9 + 102h) MSBs.
Move 20-bit value in R13 to 20-bit absolute addresses EDE (LSBs) and EDE+2 (MSBs)
Move 20-bit value in R13 to 20-bit addresses EDE (LSBs) and EDE+2 (MSBs). PC index ± 32 K.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 271
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.4.9 RETA
* RETA Return from subroutine
Syntax RETA
Operation @SP → PC.15:0 LSBs (15:0) of saved PC to PC.15:0
SP + 2 → SP
@SP → PC.19:16 MSBs (19:16) of saved PC to PC.19:16
SP + 2 → SP
Emulation MOVA @SP+,PC
Description The 20-bit return address information, pushed onto the stack by a CALLA instruction, is restored to the PC. The
program continues at the address following the subroutine call. The SR bits SR.11:0 are not affected. This allows the
transfer of information with these bits.
Status Bits N: Not affected
Z: Not affected
C: Not affected
V: Not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example Call a subroutine SUBR from anywhere in the 20-bit address space and return to the address after the CALLA
272 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com CPUX
4.6.4.10 TSTA
* TSTA Test 20-bit destination register
Syntax TSTA Rdst
Operation dst + 0FFFFFh + 1
dst + 0FFFFh + 1
dst + 0FFh + 1
Emulation CMPA #0,Rdst
Description The destination register is compared with zero. The status bits are set according to the result. The destination register
is not affected.
Status Bits N: Set if destination register is negative, reset if positive
Z: Set if destination register contains zero, reset otherwise
C: Set
V: Reset
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 20-bit value in R7 is tested. If it is negative, continue at R7NEG; if it is positive but not zero, continue at R7POS.
TSTA R7 ; Test R7
JN R7NEG ; R7 is negative
JZ R7ZERO ; R7 is zero
R7POS ...... ; R7 is positive but not zero
R7NEG ...... ; R7 is negative
R7ZERO ...... ; R7 is zero
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 273
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
CPUX www.ti.com
4.6.4.11 SUBA
SUBA Subtract 20-bit source from 20-bit destination register
Syntax SUBA Rsrc,Rdst
SUBA #imm20,Rdst
Operation (.not.src) + 1 + Rdst → Rdst or Rdst – src → Rdst
Description The 20-bit source operand is subtracted from the 20-bit destination register. This is made by adding the 1s
complement of the source + 1 to the destination. The result is written to the destination register, the source is
not affected.
Status Bits N: Set if result is negative (src > dst), reset if positive (src ≤ dst)
Z: Set if result is zero (src = dst), reset otherwise (src ≠ dst)
C: Set if there is a carry from the MSB (Rdst.19), reset otherwise
V: Set if the subtraction of a negative source operand from a positive destination operand delivers a negative
result, or if the subtraction of a positive source operand from a negative destination operand delivers a
positive result, reset otherwise (no overflow)
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The 20-bit value in R5 is subtracted from R6. If a carry occurs, the program continues at label TONI.
274 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Basic Clock Module+
Chapter 5
Basic Clock Module+
The basic clock module+ provides the clocks for MSP430x2xx devices. This chapter describes the operation of
the basic clock module+ of the MSP430x2xx device family.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 275
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Basic Clock Module+ www.ti.com
276 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Basic Clock Module+
Internal VLOCLK
LP/LF DIVAx
Oscillator†
10 Divider
Min. Pulse LFXT1CLK /1/2/4/8
else
Filter ACLK
Auxillary Clock
OSCOFF LFXT1Sx
XTS
XIN
0V
LF XT†
LFOff XT1Off
XOUT 0V
SELMx
LFXT1 Oscillator DIVMx
CPUOFF
XCAPx
00
01 Divider
Min. Pulse 0
10 /1/2/4/8
Filter 1
11 MCLK
XT2OFF XT2S
XT2IN Main System Clock
Connected only when
XT2 not present on−chip
XT
XT2OUT MODx
XT2 Oscillator
VCC
Modulator
DCOR SCG0 RSELx DCOx
SELS DIVSx
SCG1
off n
0 DC 0 Min. Puls
DCO 0 Divider
1 Generator 1 Filter 0
n+1 DCOCLK /1/2/4/8
1
Rosc 1
SMCLK
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 277
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Basic Clock Module+ www.ti.com
Note
† Device-Specific Clock Variations
Not all clock features are available on all MSP430x2xx devices
MSP430G22x0: LFXT1 is not present, XT2 is not present, ROSC is not supported.
MSP430F20xx, MSP430G2xx1, MSP430G2xx2, MSP430G2xx3: LFXT1 does not support HF mode,
XT2 is not present, ROSC is not supported.
MSP430x21x1: Internal LP/LF oscillator is not present, XT2 is not present, ROSC is not supported.
MSP430x21x2: XT2 is not present.
MSP430F22xx, MSP430G2x55, MSP430x23x0: XT2 is not present.
DIVAx
VLOCLK
Internal 10
LP/LF
Divider
else /1/2/4/8
ACLK
Auxillary Clock
OSCOFF
LFXT1Sx
SELMx
DIVMx
CPUOFF
00
01 Divider
Min. Pulse 0
10 /1/2/4/8
Filter 1
11 MCLK
XT2OFF XT2Sx
XT2IN Main System Clock
XT
XT2OUT MODx
XT2 Oscillator
VCC Modulator
SCG0 RSELx DCOx
SELS DIVSx
SCG1
off n
DC 0 Min. Puls
DCO 0 Divider
Generator 1 Filter 0
n+1 DCOCLK /1/2/4/8
1
1
SMCLK
Note
LFXT1 is not present in MSP430AFE2xx devices.
278 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Basic Clock Module+
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 279
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Basic Clock Module+ www.ti.com
Software can disable LFXT1 by setting OSCOFF, if LFXT1CLK does not source SMCLK or MCLK, as shown in
Figure 5-3. LFXT1 is switched on if requested as source for ACLK (ACLK_request), MCLK (MCLK_request), or
SMCLK (SMCLK_request) and not disabled by software.
XTS
ACLK_request
OSCOFF
MCLK_request
CPUOFF LFOff
LFXT1Off
SELM0
SELM1
XT2 XT1Off
Note
LFXT1 Oscillator Characteristics
Low-frequency crystals often require hundreds of milliseconds to start up, depending on the crystal.
Ultra-low-power oscillators such as the LFXT1 in LF mode should be guarded from noise coupling
from other sources. The crystal should be placed as close as possible to the MSP430 with the crystal
housing grounded and the crystal traces guarded with ground traces.
MCLK_request
CPUOFF
SELM0 XT2off (internal signal)
SELM1
SMCLK_request
SCG1
SELS
280 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Basic Clock Module+
D Q 1: on
SMCLK_request
SCG1 0: of f
SELS
DCOCLK
DCOCLK SYNC
XT2CLK
DCO_Gen_on
SCG0 1: on
0: of f
20000 kHz
RSEL = 7
1000 kHz
RSEL=0
100 kHz
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 281
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Basic Clock Module+ www.ti.com
Each MSP430F2xx device (and most MSP430G2xx devices; see device-specific data sheets) has calibrated
DCOCTL and BCSCTL1 register settings for specific frequencies stored in information memory segment A. To
use the calibrated settings, the information is copied into the DCOCTL and BCSCTL1 registers. The calibrated
settings affect the DCOx, MODx, and RSELx bits, and clear all other bits, except XT2OFF which remains set.
The remaining bits of BCSCTL1 can be set or cleared as needed with BIS.B or BIC.B instructions.
; Set DCO to 1 MHz:
CLR.B &DCOCTL ; Select lowest DCOx
; and MODx settings
MOV.B &CALBC1_1MHZ,&BCSCTL1 ; Set range
MOV.B &CALDCO_1MHZ,&DCOCTL ; Set DCO step + modulation
282 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Basic Clock Module+
MODx
31
24
16
15
2
Lower DCO Tap Frequency fDCO Upper DCO Tap Frequency fDCO+1
XT2OF
XT2_OscFault
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 283
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Basic Clock Module+ www.ti.com
DCOCLK
LFXT1CLK
MCLK
Wait for
DCOCLK LFXT1CLK
LFXT1CLK
284 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Basic Clock Module+
(1) Some of the register bits are POR initialzed, and some are PUC initialized (see Section 5.3.2 ).
(2) The initial state of BCSCTL3 is 000h in the MSP430AFE2xx devices.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 285
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Basic Clock Module+ www.ti.com
286 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Basic Clock Module+
(1) XTS = 1 is not supported in MSP430x20xx and MSP430G2xx devices (see Figure 5-1 and Figure 5-2 for details on supported settings
for all devices).
(2) This bit is reserved in the MSP430AFE2xx devices.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 287
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Basic Clock Module+ www.ti.com
288 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Basic Clock Module+
01b = Reserved
00b = Reserved
01b = Reserved
10b = VLOCLK
11b = Reserved
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 289
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Basic Clock Module+ www.ti.com
(1) MSP430G22x0: The LFXT1Sx bits should be programmed to 10b during the initialization and start-up code to select VLOCLK (for
more details, refer to the Digital I/O chapter). The other bits are reserved and should not be altered.
(2) This bit is reserved in the MSP430AFE2xx devices.
(3) Does not apply to MSP430x2xx, MSP430x21xx, or MSP430x22xx devices.
290 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Basic Clock Module+
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 set or clear this bit using BIS.B or BIC.B
1 OFIE(1) R/W 0h instructions, rather than MOV.B or CLR.B instructions.
MSP430G22x0: This bit should not be set.
0b = Interrupt not enabled
1b = Interrupt enabled
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 291
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Basic Clock Module+ www.ti.com
(1) MSP430G22x0: The LFXT1 oscillator pins are not available in this device. The oscillator fault flag will always be set by hardware. The
interrupt enable bit should not be set.
292 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
Chapter 6
DMA Controller
The DMA controller module transfers data from one address to another without CPU intervention. This chapter
describes the operation of the DMA controller of the MSP430x2xx device family.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 293
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
294 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
DMA0TSELx
4
DMAREQ 0000
TACCR2_CCIFG 0001
TBCCR2_CCIFG 0010
USCI A0 data receive 0011
USCI A0 data transmit 0100
DAC12_0IFG 0101
ADC12_IFGx 0110
TACCR0_CCIFG 0111 JTAG Active
TBCCR0_CCIFG 1000 NMI Interrupt Request
USCI A1 data receive 1001 Halt ENNMI
ROUNDROBIN
USCI A1 data transmit 1010
Multiplier ready 1011 DMADSTINCRx DMADTx
DMA0SZ
DMA1TSELx
4 2 DMASRSBYTE
DMASRCINCRx DMAEN
DMAREQ 0000
TACCR2_CCIFG 0001
TBCCR2_CCIFG 0010
DMADSTINCRx DMADTx
USCI A0 data receive 0011
DMADSTBYTE
USCI A0 data transmit 0100 2 3
DMA Priority And Controll
DMA Channel 2
DMA2TSEL DMA2SA
DT
4
DMA2DA
DMAREQ 0000
DMA2SZ
TACCR2_CCIFG 0001
TBCCR2_CCIFG 0010 2 DMASRSBYTE
USCI A0 data receive 0011 DMASRCINCRx DMAEN
USCI A0 data transmit 0100
DMAONFETCH
DAC12_0IFG 0101
ADC12_IFGx 0110
Halt CPU
TACCR0_CCIFG 0111
TBCCR0_CCIFG 1000
USCI A1 data receive 1001
USCI A1 data transmit 1010
Multiplier ready 1011
USCI B0 data receive 1100
USCI B0 data transmit 1101
DMA1IFG 1110
DMAE0 1111
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 295
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
296 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 297
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
Reset
DMAEN = 0 DMAEN = 0
DMAEN = 1
DMAREQ = 0
T_Size → DMAxSZ
DMAxSZ → T_Size
DMAxSA → T_SourceAdd
[ DMADTx = 0 DMAxDA → T_DestAdd
AND DMAxSZ = 0]
OR DMAEN = 0
DMAABORT = 1
Idle
DMAABORT=0 DMAREQ = 0
DMAxSZ > 0
Wait for Trigger
AND DMAEN = 1
T_Size → DMAxSZ
Hold CPU, DMAxSA → T_SourceAdd
Transfer one word/byte DMAxDA → T_DestAdd
[ENNMI = 1
AND NMI event]
OR
DMADTx = 4
[DMALEVEL = 1
AND DMAxSZ = 0
AND Trigger = 0]
AND DMAEN = 1
Decrement DMAxSZ
Modify T_SourceAdd
Modify T_DestAdd
298 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 299
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
DMAEN = 0
Reset
DMAEN = 0
DMAREQ = 0 DMAEN = 0
DMAEN = 1
T_Size → DMAxSZ
DMAxSZ → T_Size
[DMADTx = 1
DMAxSA → T_SourceAdd
AND DMAxSZ = 0] DMAxDA → T_DestAdd
OR
DMAEN = 0
DMAABORT = 1
Idle
DMAREQ = 0
T_Size → DMAxSZ
DMAABORT=0
DMAxSA → T_SourceAdd
DMAxDA → T_DestAdd
Hold CPU,
Transfer one word/byte
[ENNMI = 1
AND NMI event]
DMAxSZ > 0
OR
[DMALEVEL = 1
AND Trigger = 0]
Decrement DMAxSZ
Modify T_SourceAdd
Modify T_DestAdd
300 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 301
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
DMAEN = 0
Reset
DMAEN = 0
DMAREQ = 0 DMAEN = 0
T_Size → DMAxSZ DMAEN = 1
DMAxSZ → T_Size
[DMADTx = {2, 3} DMAxSA → T_SourceAdd
AND DMAxSZ = 0] DMAxDA → T_DestAdd
OR
DMAEN = 0
DMAABORT = 1
Idle
DMAABORT=0
Hold CPU,
Transfer one word/byte
[ENNMI = 1
AND NMI event]
T_Size → DMAxSZ
OR
DMAxSA → T_SourceAdd
[DMALEVEL = 1 DMAxDA → T_DestAdd
AND Trigger = 0]
DMAxSZ > 0
Decrement DMAxSZ
Modify T_SourceAdd
Modify T_DestAdd
302 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
Note
DMAONFETCH Must Be Used When The DMA Writes To Flash
If the DMA controller is used to write to flash memory, the DMAONFETCH bit must be set. Otherwise,
unpredictable operation can result.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 303
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
304 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
When the ROUNDROBIN bit is cleared the channel priority returns to the default priority.
6.2.6 DMA Transfer 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 cycle time is
dependent on the MSP430 operating mode and clock system setup.
If the MCLK source is active, but the CPU is off, the DMA controller will use the MCLK source for each transfer,
without re-enabling the CPU. If the MCLK source is off, the DMA controller will temporarily restart MCLK,
sourced with DCOCLK, for the single transfer or complete block or burst-block transfer. The CPU remains off,
and after the transfer completes, MCLK is turned off. The maximum DMA cycle time for all operating modes is
shown in Table 6-4.
Table 6-4. Maximum Single-Transfer DMA Cycle Time
CPU Operating Mode Clock Source Maximum DMA Cycle Time
Active mode MCLK = DCOCLK 4 MCLK cycles
Active mode MCLK = LFXT1CLK 4 MCLK cycles
Low-power mode LPM0/1 MCLK = DCOCLK 5 MCLK cycles
Low-power mode LPM3/4 MCLK = DCOCLK 5 MCLK cycles + 6 µs(1)
Low-power mode LPM0/1 MCLK = LFXT1CLK 5 MCLK cycles
Low-power mode LPM3 MCLK = LFXT1CLK 5 MCLK cycles
Low-power mode LPM4 MCLK = LFXT1CLK 5 MCLK cycles + 6 µs(1)
(1) The additional 6 µs are needed to start the DCOCLK. It is the t(LPMx) parameter in the data sheet.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 305
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
6.2.9 Using the USCI_B I2C Module with the DMA Controller
The USCI_B I2C module provides two trigger sources for the DMA controller. The USCI_B I2C module can
trigger a transfer when new I2C data is received and when data is needed for transmit.
A transfer is triggered if UCB0RXIFG is set. The UCB0RXIFG is cleared automatically when the DMA controller
acknowledges the transfer. If UCB0RXIE is set, UCB0RXIFG will not trigger a transfer.
A transfer is triggered if UCB0TXIFG is set. The UCB0TXIFG is cleared automatically when the DMA controller
acknowledges the transfer. If UCB0TXIE is set, UCB0TXIFG will not trigger a transfer.
306 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 307
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
308 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
7 6 5 4 3 2 1 0
DMA1TSELx DMA0TSELx
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 309
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
7 6 5 4 3 2 1 0
Reserved DMAONFETCH ROUNDROBIN ENNMI
r-0 r-0 r-0 r-0 r-0 rw-(0) rw-(0) rw-(0)
310 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
7 6 5 4 3 2 1 0
DMADSTBYTE DMASRCBYTE DMALEVEL DMAEN DMAIFG DMAIE DMAABORT DMAREQ
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 311
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
DMA enable
4 DMAEN R/W 0h 0b = Disabled
1b = Enabled
312 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
7 6 5 4 3 2 1 0
Reserved DMAxSA
r-0 r-0 r-0 r-0 rw rw rw rw
15 14 13 12 11 10 9 8
DMAxSA
rw rw rw rw rw rw rw rw
7 6 5 4 3 2 1 0
DMAxSA
rw rw rw rw rw rw rw rw
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 313
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
7 6 5 4 3 2 1 0
Reserved DMAxDA
r-0 r-0 r-0 r-0 rw rw rw rw
15 14 13 12 11 10 9 8
DMAxDA
rw rw rw rw rw rw rw rw
7 6 5 4 3 2 1 0
DMAxDA
rw rw rw rw rw rw rw rw
314 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DMA Controller
7 6 5 4 3 2 1 0
DMAxSZ
rw rw rw rw rw rw rw rw
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 315
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DMA Controller www.ti.com
7 6 5 4 3 2 1 0
DMAIVx
r-0 r-0 r-0 r-0 r-(0) r-(0) r-(0) r-0
316 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Flash Memory Controller
Chapter 7
Flash Memory Controller
This chapter describes the operation of the MSP430x2xx flash memory controller.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 317
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Flash Memory Controller www.ti.com
Note
Minimum VCC during flash write or erase
The minimum VCC voltage during a flash write or erase operation is 2.2 V. If VCC falls below 2.2 V
during write or erase, the result of the write or erase is unpredictable.
MAB
MDB
FCTL2
Enable
Address
FCTL3 Latch
Flash
Memory
FCTL4 Array
Timing
Generator Enable
Data Latch
Programming
Voltage
Generator
318 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Flash Memory Controller
The information memory has four 64-byte segments. The main memory has one or more 512-byte segments.
The main memory segments are further divided into blocks of 64 bytes. See the device-specific data sheet for
the complete memory map of a device.
Figure 7-2 shows the flash segmentation using an example of 32KB of flash that has 64 main segments and four
information segments.
0x0FFFF
0x0FFFF 0x0FFFF
Segment 0 Block
0x0FE00 0x0FFC0
32K-byte
Flash 0x0FDFF 0x0FFBF
Segment 1 Block
Main Memory 0x0FC00 0x0FF80
0x0FF7F
0x08000 Segment 2 Block
0x0FF40
0x010FF 256-byte 0x0FF3F
Block
Flash 0x0FF00
Information Memory
0x01000 0x0FEFF
Block
0x0FEC0
0x0FEBF
Segment 61 Block
0x0FE80
0x0FE7F
Segment 62 Block
0x0FE40
0x0FE3F
Segment 63 Block
0x08000 0x0FE00
0x010FF
Segment A
Segment B
Segment C
Segment D
0x01000
7.2.1 Segment A
Segment A of the information memory is locked separately from all other segments with the LOCKA bit. When
LOCKA = 1, Segment A cannot be written or erased and all information memory is protected from erasure
during a mass erase or production programming. When LOCKA = 0, Segment A can be erased and written
as any other flash memory segment, and all information memory is erased during a mass erase or production
programming.
The state of the LOCKA bit is toggled when a 1 is written to it. Writing a 0 to LOCKA has no effect. This allows
existing flash programming routines to be used unchanged.
; Unlock SegmentA
BIT #LOCKA,&FCTL3 ; Test LOCKA
JZ SEGA_UNLOCKED ; Already unlocked?
MOV #FWKEY+LOCKA,&FCTL3 ; No, unlock SegmentA
SEGA_UNLOCKED ; Yes, continue
; SegmentA is unlocked
; Lock SegmentA
BIT #LOCKA,&FCTL3 ; Test LOCKA
JNZ SEGA_LOCKED ; Already locked?
MOV #FWKEY+LOCKA,&FCTL3 ; No, lock SegmentA
SEGA_LOCKED ; Yes, continue
; SegmentA is locked
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 319
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Flash Memory Controller www.ti.com
ACLK 00
fFTG
MCLK 01 Reset
Divider, 1−64
SMCLK 10 Flash Timing Generator
SMCLK 11
BUSY WAIT
320 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Flash Memory Controller
Any erase is initiated by a dummy write into the address range to be erased. The dummy write starts the
flash timing generator and the erase operation. Figure 7-4 shows the erase cycle timing. The BUSY bit is set
immediately after the dummy write and remains set throughout the erase cycle. BUSY, MERAS, and ERASE are
automatically cleared when the cycle completes. The erase cycle timing is not dependent on the amount of flash
memory present on a device. Erase cycle times are equivalent for all MSP430F2xx and MSP430G2xx devices.
BUSY
tmass erase = 10593/fFTG, tsegment erase = 4819/fFTG
A dummy write to an address not in the range to be erased does not start the erase cycle, does not affect the
flash memory, and is not flagged in any way. This errant dummy write is ignored.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 321
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Flash Memory Controller www.ti.com
Disable watchdog
Dummy write
; Segment Erase from flash. 514 kHz < SMCLK < 952 kHz
; Assumes ACCVIE = NMIIE = OFIE = 0.
MOV #WDTPW+WDTHOLD,&WDTCTL ; Disable WDT
MOV #FWKEY+FSSEL1+FN0,&FCTL2 ; SMCLK/2
MOV #FWKEY, &FCTL3 ; Clear LOCK
MOV #FWKEY+ERASE, &FCTL1 ; Enable segment erase
CLR &0FC10h ; Dummy write, erase S1
MOV #FWKEY+LOCK, &FCTL3 ; Done, set LOCK
... ; Re-enable WDT?
322 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Flash Memory Controller
Disable watchdog
yes
BUSY = 1
Dummy write
yes
BUSY = 1
; Segment Erase from RAM. 514 kHz < SMCLK < 952 kHz
; Assumes ACCVIE = NMIIE = OFIE = 0.
MOV #WDTPW+WDTHOLD,&WDTCTL ; Disable WDT
L1 BIT #BUSY, &FCTL3 ; Test BUSY
JNZ L1 ; Loop while busy
MOV #FWKEY+FSSEL1+FN0, &FCTL2 ; SMCLK/2
MOV #FWKEY&FCTL3 ; Clear LOCK
MOV #FWKEY+ERASE, &FCTL1 ; Enable erase
CLR &0FC10h ; Dummy write, erase S1
L2 BIT #BUSY, &FCTL3 ; Test BUSY
JNZ L2 ; Loop while busy
MOV #FWKEY+LOCK&FCTL3 ; Done, set LOCK
... ; Re-enable WDT?
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 323
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Flash Memory Controller www.ti.com
Both write modes use a sequence of individual write instructions, but using the block write mode is
approximately twice as fast as byte or word mode, because the voltage generator remains on for the complete
block write. Any instruction that modifies a destination can be used to modify a flash location in either byte or
word write mode or block write mode. A flash word (low and high bytes) must not be written more than twice
between erasures. Otherwise, damage can occur.
The BUSY bit is set while a write operation is active and cleared when the operation completes. If the write
operation is initiated from RAM, the CPU must not access flash while BUSY = 1. Otherwise, an access violation
occurs, ACCVIFG is set, and the flash write is unpredictable.
7.3.3.1 Byte or Word Write
A byte or word write operation can be initiated from within flash memory or from RAM. When initiating from within
flash memory, all timing is controlled by the flash controller, and the CPU is held while the write completes. After
the write completes, the CPU resumes code execution with the instruction following the write. Figure 7-7 shows
the byte or word write timing.
BUSY
tWord Write = 30/fFTG
When a byte or word write is executed from RAM, the CPU continues to execute code from RAM. The BUSY bit
must be zero before the CPU accesses flash again, otherwise an access violation occurs, ACCVIFG is set, and
the write result is unpredictable.
In byte or word mode, the internally-generated programming voltage is applied to the complete 64-byte block,
each time a byte or word is written, for 27 of the 30 fFTG cycles. With each byte or word write, the amount of
time the block is subjected to the programming voltage accumulates. The cumulative programming time, tCPT,
must not be exceeded for any block. If the cumulative programming time is met, the block must be erased
before performing any further writes to any address within the block. See the device-specific data sheet for
specifications.
324 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Flash Memory Controller
Disable watchdog
; Byte/word write from flash. 514 kHz < SMCLK < 952 kHz
; Assumes 0FF1Eh is already erased
; Assumes ACCVIE = NMIIE = OFIE = 0.
MOV #WDTPW+WDTHOLD,&WDTCTL ; Disable WDT
MOV #FWKEY+FSSEL1+FN0,&FCTL2 ; SMCLK/2
MOV #FWKEY,&FCTL3 ; Clear LOCK
MOV #FWKEY+WRT,&FCTL1 ; Enable write
MOV #0123h,&0FF1Eh ; 0123h -> 0FF1Eh
MOV #FWKEY,&FCTL1 ; Done. Clear WRT
MOV #FWKEY+LOCK,&FCTL3 ; Set LOCK
... ; Re-enable WDT?
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 325
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Flash Memory Controller www.ti.com
Disable watchdog
yes
BUSY = 1
yes
BUSY = 1
; Byte/word write from RAM. 514 kHz < SMCLK < 952 kHz
; Assumes 0FF1Eh is already erased
; Assumes ACCVIE = NMIIE = OFIE = 0.
MOV #WDTPW+WDTHOLD,&WDTCTL ; Disable WDT
L1 BIT #BUSY,&FCTL3 ; Test BUSY
JNZ L1 ; Loop while busy
MOV #FWKEY+FSSEL1+FN0,&FCTL2 ; SMCLK/2
MOV #FWKEY,&FCTL3 ; Clear LOCK
MOV #FWKEY+WRT,&FCTL1 ; Enable write
MOV #0123h,&0FF1Eh ; 0123h -> 0FF1Eh
L2 BIT #BUSY,&FCTL3 ; Test BUSY
JNZ L2 ; Loop while busy
MOV #FWKEY,&FCTL1 ; Clear WRT
MOV #FWKEY+LOCK,&FCTL3 ; Set LOCK
... ; Re-enable WDT?
326 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Flash Memory Controller
Cumulative Programming Time tCPT ∼=< 4ms, VCC Current Consumption is Increased
BUSY
tBlock, 0 = 25/fFTG tBlock, 1-63 = 18/fFTG tBlock, 1-63 = 18/fFTG tend = 6/fFTG
WAIT
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 327
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Flash Memory Controller www.ti.com
Disable watchdog
yes
BUSY = 1
Set BLKWRT=WRT=1
yes
WAIT=0?
no
Block Border?
Set BLKWRT=0
yes
BUSY = 1
yes Another
Block?
328 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Flash Memory Controller
Interrupts are automatically disabled during any flash operation when EEI = 0 and EEIEX = 0 and on
MSP430x20xx and MSP430G2xx devices where EEI and EEIEX are not present. After the flash operation
has completed, interrupts are automatically re-enabled. Any interrupt that occurred during the operation has its
associated flag set and generates an interrupt request when re-enabled.
When EEIEX = 1 and GIE = 1, an interrupt immediately aborts any flash operation and the FAIL flag is set.
When EEI = 1, GIE = 1, and EEIEX = 0, a segment erase is interrupted by a pending interrupt every 32 fFTG
cycles. After servicing the interrupt, the segment erase is continued for at least 32 fFTG cycles or until it is
complete. During the servicing of the interrupt, the BUSY bit remains set but the flash memory can be accessed
by the CPU without causing an access violation occurs. Nested interrupts and using the RETI instruction inside
interrupt service routines are not supported.
The watchdog timer (in watchdog mode) must be disabled before a flash erase cycle. A reset aborts the erase,
and the results are unpredictable. After the erase cycle has completed, the watchdog may be enabled again.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 329
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Flash Memory Controller www.ti.com
330 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Flash Memory Controller
Flash Memory
Commands, data, etc.
UART,
Px.x, CPU executes
Host MSP430
SPI, user software
etc.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 331
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Flash Memory Controller www.ti.com
(1) KEYV is initialized with POR. All other bits are initialized with PUC.
(2) Not present in all devices. See device-specific data sheet.
332 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Flash Memory Controller
7 6 5 4 3 2 1 0
BLKWRT WRT Reserved EEIEX(1) EEI(1) MERAS ERASE Reserved
rw-0 rw-0 r0 rw-0 rw-0 rw-0 rw-0 r0
Block write mode. WRT must also be set for block write mode.
BLKWRT is automatically reset when EMEX is set.
7 BLKWRT R/W 0h
0b = Block-write mode is off
1b = Block-write mode is on
Write. This bit is used to select any write mode. WRT is automatically
reset when EMEX is set.
6 WRT R/W 0h
0b = Write mode is off
1b = Write mode is on
5 Reserved R 0h
Enable emergency interrupt exit. Setting this bit enables an interrupt
to cause an emergency exit from a flash operation when GIE = 1.
EEIEX is automatically reset when EMEX is set.
4 EEIEX R/W 0h
Not present on MSP430x20xx and MSP430G2xx devices.
0b = Exit interrupt disabled.
1b = Exit on interrupt enabled.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 333
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Flash Memory Controller www.ti.com
7 6 5 4 3 2 1 0
FSSELx FNx
rw-0 rw-1 rw-0 rw-0 rw-0 rw-0 rw-1 rw-0
Flash controller clock divider. These six bits select the divider for the
flash controller clock. The divisor value is FNx + 1. For example,
5-0 FNx R/W 2h
when FNx = 00h, the divisor is 1. When FNx = 03Fh, the divisor is
64.
334 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Flash Memory Controller
7 6 5 4 3 2 1 0
FAIL LOCKA EMEX LOCK WAIT ACCVIFG KEYV BUSY
r(w)-0 r(w)-1 rw-0 rw-1 r-1 rw-0 rw-(0) r-0
Operation failure. This bit is set if the fFTG clock source fails, or a
flash operation is aborted from an interrupt when EEIEX = 1. FAIL
7 FAIL R/W 0h must be reset with software.
0b = No failure
1b = Failure
Segment A and Info lock. Write a 1 to this bit to change its state.
Writing 0 has no effect.
0b = Segment A unlocked and all information memory is erased
6 LOCKA R/W 1h
during a mass erase.
1b = Segment A locked and all information memory is protected from
erasure during a mass erase.
Emergency exit
5 EMEX R/W 0h 0b = No emergency exit
1b = Emergency exit
Lock. This bit unlocks the flash memory for writing or erasing. The
LOCK bit can be set any time during a byte or word write or erase
operation, and the operation completes normally. In the block write
4 LOCK R/W 1h mode if the LOCK bit is set while BLKWRT = WAIT = 1, then
BLKWRT and WAIT are reset and the mode ends normally.
0b = Unlocked
1b = Locked
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 335
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Flash Memory Controller www.ti.com
336 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Flash Memory Controller
7 6 5 4 3 2 1 0
Reserved MRG1 MRG0 Reserved
r-0 r-0 rw-0 rw-0 r-0 r-0 r-0 r-0
Marginal read 1 mode. This bit enables the marginal 1 read mode.
The marginal read 1 bit is cleared if the CPU starts execution from
the flash memory. If both MRG1 and MRG0 are set, MRG1 is active
5 MRG1 R/W 0h
and MRG0 is ignored.
0b = Marginal 1 read mode is disabled.
1b = Marginal 1 read mode is enabled.
Marginal read 0 mode. This bit enables the marginal 0 read mode.
The marginal mode 0 is cleared if the CPU starts execution from the
flash memory. If both MRG1 and MRG0 are set, MRG1 is active and
4 MRG0 R/W 0h
MRG0 is ignored.
0b = Marginal 0 read mode is disabled.
1b = Marginal 0 read mode is enabled.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 337
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Flash Memory Controller www.ti.com
Flash memory access violation interrupt enable. This bit enables the
ACCVIFG interrupt.
Because other bits in IE1 may be used for other modules, Ti
5 ACCVIE R/W 0h recommends setting or clearing this bit using BIS.B or BIC.B
instructions, respectively, rather than MOV.B or CLR.B instructions.
0b = Interrupt not enabled
1b = Interrupt enabled
338 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Digital I/O
Chapter 8
Digital I/O
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 339
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Digital I/O www.ti.com
Note
MSP430G22x0 : These devices feature digital I/O pins P1.2, P1.5, P1.6, and P1.7. The GPIOs P1.0,
P1.1, P1.3, P1.4, P2.6, and P2.7 are implemented on this device but not available on the device
pinout. To avoid floating inputs on these GPIOs, these digital I/Os should be properly initialized by
running a start-up code similar to the following sample:
mov.b #0x1B, P1REN; ; Terminate unavailable Port1 pins properly
; Config as Input with pulldown enabled
xor.b #0x20, BCSCTL3; ; Select VLO as low freq clock
The initialization code configures GPIOs P1.0, P1.1, P1.3, and P1.4 as inputs with pulldown resistor
enabled (that is, P1REN.x = 1) and GPIOs P2.6 and P2.7 are terminated by selecting VLOCLK as
ACLK – see the Basic Clock System chapter for details. The register bits of P1.0, P1.1, P1.3, and
P1.4 in registers P1OUT, P1DIR, P1IFG, P1IE, P1IES, P1SEL, and P1REN should not be altered after
the initialization code is executed. Also, all Port 2 registers are should not be altered.
Note
Writing to Read-Only Registers PxIN
Writing to these read-only registers results in increased current consumption while the write attempt is
active.
340 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Digital I/O
Setting PxSELx = 1 does not automatically set the pin direction. Other peripheral module functions may
require the PxDIR bits to be configured according to the direction needed for the module function. See the
pin schematics in the device-specific data sheet.
Note
Setting PxREN = 1 When PxSEL = 1
On some I/O ports on the MSP430F261x and MSP430F2416/7/8/9, enabling the pullup/pulldown
resistor (PxREN = 1) while the module function is selected (PxSEL = 1) does not disable the logic
output driver. This combination is not recommended and may result in unwanted current flow through
the internal resistor. See the device-specific data sheet pin schematics for more information.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 341
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Digital I/O www.ti.com
Note
P1 and P2 Interrupts Are Disabled When PxSEL = 1
When any P1SELx or P2SELx bit is set, the corresponding pin's interrupt function is disabled.
Therefore, signals on these pins will not generate P1 or P2 interrupts, regardless of the state of
the corresponding P1IE or P2IE bit.
When a port pin is selected as an input to a peripheral, the input signal to the peripheral is a latched
representation of the signal at the device pin. While PxSELx = 1, the internal input signal follows the signal
at the pin. However, if the PxSELx = 0, the input to the peripheral maintains the value of the input signal at the
device pin before the PxSELx bit was reset.
8.2.6 Pin Oscillator
Some MSP430 devices have a pin oscillator function built-in to some pins. The pin oscillator function may be
used in capacitive touch sensing applications to eliminate external passive components. Additionally, the pin
oscillator may be used in sensor applications.
No external components to create the oscillation
Capacitive sensors can be connected directly to MSP430 pin
Robust, typical built-in hysteresis of ~0.7 V
When the pin oscillator function is enabled, other pin configurations are overwritten. The output driver is turned
off while the weak pullup/pulldown is enabled and controlled by the voltage level on the pin itself. The voltage on
the I/O is fed into the Schmitt trigger of the pin and then routed to a timer. The connection to the timer is device
specific and, thus, defined in the device-specific data sheet. The Schmitt-trigger output is inverted and then
decides if the pullup or the pulldown is enabled. Due to the inversion, the pin starts to oscillate as soon as the pin
oscillator pin configuration is selected. Some of the pin-oscillator outputs are combined by a logical OR before
routing to a timer clock input or timer capture channel. Therefore, only one pin oscillator should be enabled at a
time. The oscillation frequency of each pin is defined by the load on the pin and by the I/O type. I/Os with analog
functions typically show a lower oscillation frequency than pure digital I/Os. See the device-specific data sheet
for details. Pins without external load show typical oscillation frequencies of 1 MHz to 3 MHz.
Pin Oscillator in a Capacitive-Touch Application
A typical touch pad application using the pin oscillator is shown in Figure 8-1.
342 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Digital I/O
DVSS 0
DVCC 1
PAD
TAxCLK
1
ID.x
0
1 Divider 16-bit Timer
2 1/2/4/8 TAR
3
Capture Register
CCRx
Figure 8-1. Example Circuitry and Configuration using the Pin Oscillator
A change of the capacitance of the touch pad (external capacitive load) has an effect on the pin oscillator
frequency. An approaching finger tip increases the capacitance of the touch pad thus leads to a lower self-
oscillation frequency due to the longer charging time. The oscillation frequency can directly be captured in a
built-in Timer channel. The typical sensitivity of a pin is shown in Figure 8-2.
1.50
VCC = 3.0 V
1.35
Typical Oscillation Frequency − MHz
1.20
1.05
0.90
0.75
0.60
0.45
0.30
Fosc − T
0.15
0.00
10 50 100
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 343
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Digital I/O www.ti.com
Note
PxIFG Flags When Changing PxOUT or PxDIR
Writing to P1OUT, P1DIR, P2OUT, or P2DIR can result in setting the corresponding P1IFG or P2IFG
flags.
Note
Writing to PxIESx
Writing to P1IES, or P2IES can result in setting the corresponding interrupt flags.
PxIESx PxINx PxIFGx
0→1 1 Unchanged
1→0 0 Unchanged
344 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Digital I/O
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 345
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Digital I/O www.ti.com
(1) If P2.6 and P2.7 are multiplexed with XIN and XOUT, respectively, the reset value of P2SEL is C0h. If XIN and XOUT have dedicated
pins, the reset value is 00h.
346 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Digital I/O
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 347
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Digital I/O www.ti.com
348 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Digital I/O
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 349
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Digital I/O www.ti.com
350 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Supply Voltage Supervisor (SVS)
Chapter 9
Supply Voltage Supervisor (SVS)
This chapter describes the operation of the SVS. The SVS is implemented in selected MSP430x2xx devices.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 351
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Supply Voltage Supervisor (SVS) www.ti.com
AVCC D Brownout
G S Reset
SVSIN ~ 50us
1111
0001 −
SVS_POR
+
0010
tReset ~ 50us
1011 SVSOUT
1100 1.2V
1101
D
G S
Set SVSFG
Reset
VLD PORON SVSON SVSOP SVSFG
SVSCTL Bits
352 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Supply Voltage Supervisor (SVS)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 353
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Supply Voltage Supervisor (SVS) www.ti.com
V(SVSstart)
Vhys(B_IT−)
V(B_IT−)
VCC(start)
Brownout Brown-
Region Out
Brownout Region
1
0
td(SVSon) t d(SVSR)
Set SVS_POR
1
undefined
354 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Supply Voltage Supervisor (SVS)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 355
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Supply Voltage Supervisor (SVS) www.ti.com
POR on. This bit enables the SVSFG flag to cause a POR device
reset.
3 PORON R/W 0h(1)
0b = SVSFG does not cause a POR
1b = SVSFG causes a POR
SVS on. This bit reports the status of SVS operation. This bit DOES
NOT turn on the SVS. The SVS is turned on by setting VLDx > 0.
2 SVSON R 0h(1)
0b = SVS is off
1b = SVS is on
SVS output. This bit reflects the output value of the SVS comparator.
1 SVSOP R 0h(1) 0b = SVS comparator output is low
1b = SVS comparator output is high
356 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Watchdog Timer+ (WDT+)
Chapter 10
Watchdog Timer+ (WDT+)
The watchdog timer+ (WDT+) is a 16-bit timer that can be used as a watchdog or as an interval timer. This
chapter describes the WDT+ The WDT+ is implemented in all MSP430x2xx devices.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 357
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Watchdog Timer+ (WDT+) www.ti.com
Note
Watchdog Timer+ Powers Up Active
After a PUC, the WDT+ module is automatically configured in the watchdog mode with an initial 32768
clock cycle reset interval using the DCOCLK. The user must setup or halt the WDT+ prior to the
expiration of the initial reset interval.
358 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Watchdog Timer+ (WDT+)
WDTCTL
MDB
Q6 MSB
3
0
WDTQn Q9
Int. 2
Y 1
Flag Q13
1
0
Q15
0 1
16−bit Password
Pulse Counter Compare
1
Generator A
B
0
Clear 1 16−bit
PUC
(Asyn) CLK 0
EQU
Write Enable
EQU Low Byte
Fail-Safe R/W
MCLK Logic
SMCLK 1 WDTHOLD
ACLK 1 WDTNMIES
WDTNMI
A EN
WDTTMSEL
WDTCNTCL
WDTSSEL
WDTIS1
WDTIS0 LSB
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 359
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Watchdog Timer+ (WDT+) www.ti.com
Note
Modifying the Watchdog Timer+
The WDT+ interval should be changed together with WDTCNTCL = 1 in a single instruction to avoid
an unexpected immediate PUC or interrupt.
The WDT+ should be halted before changing the clock source to avoid a possible incorrect interval.
360 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Watchdog Timer+ (WDT+)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 361
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Watchdog Timer+ (WDT+) www.ti.com
362 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Watchdog Timer+ (WDT+)
7 6 5 4 3 2 1 0
WDTHOLD WDTNMIES WDTNMI WDTTMSEL WDTCNTCL WDTSSEL WDTISx
rw-0 rw-0 rw-0 rw-0 r0(w) rw-0 rw-0 rw-0
Watchdog timer+ hold. This bit stops the watchdog timer+. Setting
WDTHOLD = 1 when the WDT+ is not in use conserves power.
7 WDTHOLD R/W 0h
0b = Watchdog timer+ is not stopped
1b = Watchdog timer+ is stopped
Watchdog timer+ NMI edge select. This bit selects the interrupt edge
for the NMI interrupt when WDTNMI = 1. Modifying this bit can
trigger an NMI. Modify this bit when WDTIE = 0 to avoid triggering an
6 WDTNMIES R/W 0h
accidental NMI.
0b = NMI on rising edge
1b = NMI on falling edge
Watchdog timer+ NMI select. This bit selects the function for the
RST/NMI pin.
5 WDTNMI R/W 0h
0b = Reset function
1b = NMI function
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 363
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Watchdog Timer+ (WDT+) www.ti.com
364 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Watchdog Timer+ (WDT+)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 365
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Watchdog Timer+ (WDT+) www.ti.com
366 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Hardware Multiplier
Chapter 11
Hardware Multiplier
This chapter describes the hardware multiplier. The hardware multiplier is implemented in some MSP430x2xx
devices.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 367
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Hardware Multiplier www.ti.com
15 rw 0
MPYS 132h
OP1 OP2 138h
MAC 134h
MACS 136h
16 x 16 Multipiler
Accessible
Register
368 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Hardware Multiplier
operation. Writing the second operand to the operand two register OP2 initiates the multiply operation. Writing
OP2 starts the selected operation with the values stored in OP1 and OP2. The result is written into the three
result registers RESLO, RESHI, and SUMEXT.
Repeated multiply operations may be performed without reloading OP1 if the OP1 value is used for successive
operations. It is not necessary to re-write the OP1 value to perform the operations.
Table 11-1. OP1 Addresses
OP1 Address Register Name Operation
0130h MPY Unsigned multiply
0132h MPYS Signed multiply
0134h MAC Unsigned multiply accumulate
0136h MACS Signed multiply accumulate
The sum extension registers SUMEXT contents depend on the multiply operation and are listed in Table 11-3.
Table 11-3. SUMEXT Contents
Mode SUMEXT
MPY SUMEXT is always 0000h
SUMEXT contains the extended sign of the result
MPYS 00000h = Result was positive or zero
0FFFFh = Result was negative
SUMEXT contains the carry of the result
MAC 0000h = No carry for result
0001h = Result has a carry
SUMEXT contains the extended sign of the result
MACS 00000h = Result was positive or zero
0FFFFh = Result was negative
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 369
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Hardware Multiplier www.ti.com
370 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Hardware Multiplier
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 371
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Hardware Multiplier www.ti.com
372 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_A
Chapter 12
Timer_A
Timer_A is a 16-bit timer/counter with multiple capture/compare registers. This chapter describes the operation
of the Timer_A of the MSP430x2xx device family.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 373
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_A www.ti.com
Note
Use of the Word Count
Count is used throughout this chapter. It means the counter must be in the process of counting for the
action to take place. If a particular value is directly written to the counter, then an associated action will
not take place.
374 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_A
Comparator 2
CCI
EQU2
CAP
A
SCCI Y
EN 0
Set TACCR2
1 CCIFG
OUT
Output
Unit2 D Set Q OUT2 Signal
EQU0
Timer Clock
Reset
POR
OUTMODx
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 375
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_A www.ti.com
Note
Modifying Timer_A Registers
It is recommended to stop the timer before modifying its operation (with exception of the interrupt
enable, and interrupt flag) to avoid errant operating conditions.
When the timer clock is asynchronous to the CPU clock, any read from TAR should occur while the
timer is not operating or the results may be unpredictable. Alternatively, the timer may be read multiple
times while operating, and a majority vote taken in software to determine the correct reading. Any
write to TAR will take effect immediately.
12.2.3.1 Up Mode
The up mode is used if the timer period must be different from 0FFFFh counts. The timer repeatedly counts up to
the value of compare register TACCR0, which defines the period, as shown in Figure 12-2. The number of timer
counts in the period is TACCR0+1. When the timer value equals TACCR0 the timer restarts counting from zero.
If up mode is selected when the timer value is greater than TACCR0, the timer immediately restarts counting
from zero.
0FFFFh
TACCR0
0h
The TACCR0 CCIFG interrupt flag is set when the timer counts to the TACCR0 value. The TAIFG interrupt flag is
set when the timer counts from TACCR0 to zero. Figure 12-3 shows the flag set cycle.
376 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_A
Timer Clock
Set TAIFG
0FFFFh
0h
The TAIFG interrupt flag is set when the timer counts from 0FFFFh to zero. Figure 12-5 shows the flag set cycle.
Timer Clock
Set TAIFG
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 377
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_A www.ti.com
TACCR1b TACCR1c
TACCR0d
TACCR0b TACCR0c
0FFFFh
TACCR1a TACCR1d
TACCR0a
t0 t0 t0
t1 t1 t1
Time intervals can be produced with other modes as well, where TACCR0 is used as the period register. Their
handling is more complex since the sum of the old TACCRx data and the new period can be higher than the
TACCR0 value. When the previous TACCRx value plus tx is greater than the TACCR0 data, TACCR0 + 1 must
be subtracted to obtain the correct time interval.
12.2.3.5 Up/Down Mode
The up/down mode is used if the timer period must be different from 0FFFFh counts, and if a symmetrical pulse
generation is needed. The timer repeatedly counts up to the value of compare register TACCR0 and back down
to zero, as shown in Figure 12-7. The period is twice the value in TACCR0.
0FFFFh
TACCR0
0h
The count direction is latched. This allows the timer to be stopped and then restarted in the same direction it
was counting before it was stopped. If this is not desired, the TACLR bit must be set to clear the direction. The
TACLR bit also clears the TAR value and the timer clock divider.
In up/down mode, the TACCR0 CCIFG interrupt flag and the TAIFG interrupt flag are set only once during a
period, separated by 1/2 the timer period. The TACCR0 CCIFG interrupt flag is set when the timer counts from
TACCR0 – 1 to TACCR0, and TAIFG is set when the timer completes counting down from 0001h to 0000h.
Figure 12-8 shows the flag set cycle.
378 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_A
Timer Clock
Up/Down
Set TAIFG
0FFFFh
TACCR0
TACCR1
TACCR2
0h
Dead Time
Output Mode 6:Toggle/Set
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 379
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_A www.ti.com
Timer Clock
CCI
Capture
Overflow logic is provided in each capture/compare register to indicate if a second capture was performed before
the value from the first capture was read. Bit COV is set when this occurs as shown in Figure 12-11. COV must
be reset with software.
380 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_A
Idle
No Read
Capture
Capture Taken
Taken
Taken Capture
Capture
Capture
Clear Bit COV
in Register TACCTLx
Second
Capture Idle
Taken
COV = 1
Capture
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 381
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_A www.ti.com
0FFFFh
TACCR0
TACCR1
0h
382 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_A
0FFFFh
TACCR0
TACCR1
0h
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 383
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_A www.ti.com
0FFFFh
TACCR0
TACCR2
0h
Note
Switching Between Output Modes
When switching between output modes, one of the OUTMODx bits should remain set during the
transition, unless switching to mode 0. Otherwise, output glitching can occur because a NOR gate
decodes output mode 0. A safe method for switching between output modes is to use output mode 7
as a transition state:
BIS #OUTMOD_7,&TACCTLx ; Set output mode=7
BIC #OUTMODx, &TACCTLx ; Clear unwanted bits
384 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_A
Set CCIE
EQU0 IRQ, Interrupt Service Requested
D Q
CAP
Timer Clock
Reset
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 385
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_A www.ti.com
386 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_A
(1) Not present on MSP430 devices with Timer_A2 such as MSP430F20xx and other devices.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 387
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_A www.ti.com
7 6 5 4 3 2 1 0
IDx MCx Unused TACLR TAIE TAIFG
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
Input divider. These bits select the divider for the input clock.
00b = /1
7-6 IDx R/W 0h 01b = /2
10b = /4
11b = /8
388 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_A
7 6 5 4 3 2 1 0
TARx
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 389
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_A www.ti.com
7 6 5 4 3 2 1 0
OUTMODx CCIE CCI OUT COV CCIFG
rw-(0) rw-(0) rw-(0) rw-(0) r rw-(0) rw-(0) rw-(0)
Capture mode
8 CAP R/W 0h 0b = Compare mode
1b = Capture mode
390 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_A
Output. For output mode 0, this bit directly controls the state of the
output.
2 OUT R/W 0h
0b = Output low
1b = Output high
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 391
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_A www.ti.com
7 6 5 4 3 2 1 0
TACCRx
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
392 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_A
7 6 5 4 3 2 1 0
TAIVx
r-0 r-0 r-0 r-0 r-(0) r-(0) r-(0) r-0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 393
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_A www.ti.com
394 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_B
Chapter 13
Timer_B
Timer_B is a 16-bit timer/counter with multiple capture/compare registers. This chapter describes the operation
of the Timer_B of the MSP430x2xx device family.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 395
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_B www.ti.com
Note
Use of the Word Count
Count is used throughout this chapter. It means the counter must be in the process of counting for the
action to take place. If a particular value is directly written to the counter, then an associated action
does not take place.
396 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_B
CCR0
CCR1
CCR2
CCR3
CCR4
CCR5
CCISx CCR6
CMx logic COV
SCS
CCI6A 00 Capture
Mode 15 0
CCI6B 01
0
GND 10 TBCCR6
Timer Clock Sync 1
VCC 11
CLLDx Load
CCI Group Compare Latch TBCL6
Load Logic
VCC 00
TBR=0 01 Comparator 6
CCR5
EQU0 10
CCR4 EQU6 CAP
UP/DOWN
11
CCR1
0
Set TBCCR6
1 CCIFG
OUT
Output
Unit6 D Set Q OUT6 Signal
EQU0
Timer Clock
Reset
POR
OUTMODx
A. INCLK is device-specific, often assigned to the inverted TBCLK, refer to device-specific data sheet.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 397
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_B www.ti.com
Note
Modifying Timer_B Registers
It is recommended to stop the timer before modifying its operation (with exception of the interrupt
enable, interrupt flag, and TBCLR) to avoid errant operating conditions.
When the timer clock is asynchronous to the CPU clock, any read from TBR should occur while the
timer is not operating or the results may be unpredictable. Alternatively, the timer may be read multiple
times while operating, and a majority vote taken in software to determine the correct reading. Any
write to TBR will take effect immediately.
398 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_B
13.2.3.1 Up Mode
The up mode is used if the timer period must be different from TBR(max) counts. The timer repeatedly counts up
to the value of compare latch TBCL0, which defines the period, as shown in Figure 13-2. The number of timer
counts in the period is TBCL0+1. When the timer value equals TBCL0 the timer restarts counting from zero. If up
mode is selected when the timer value is greater than TBCL0, the timer immediately restarts counting from zero.
TBR(max)
TBCL0
0h
The TBCCR0 CCIFG interrupt flag is set when the timer counts to the TBCL0 value. The TBIFG interrupt flag is
set when the timer counts from TBCL0 to zero. Figure 13-3 shows the flag set cycle.
Timer Clock
Set TBIFG
TBR(max)
0h
The TBIFG interrupt flag is set when the timer counts from TBR(max) to zero. Figure 13-5 shows the flag set
cycle.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 399
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_B www.ti.com
Timer Clock
Set TBIFG
TBCL1a TBCL1d
TBCL0a
0h
EQU0 Interrupt
t0 t0 t0
EQU1 Interrupt
t1 t1 t1
Time intervals can be produced with other modes as well, where TBCL0 is used as the period register. Their
handling is more complex since the sum of the old TBCLx data and the new period can be higher than the
TBCL0 value. When the sum of the previous TBCLx value plus tx is greater than the TBCL0 data, TBCL0 + 1
must be subtracted to obtain the correct time interval.
13.2.3.5 Up/Down Mode
The up/down mode is used if the timer period must be different from TBR(max) counts, and if a 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 13-7. The period is twice the value in TBCL0.
Note
TBCL0 > TBR(max)
If TBCL0 > TBR(max), the counter operates as if it were configured for continuous mode. It does not
count down from TBR(max) to zero.
400 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_B
TBCL0
0h
The count direction is latched. This allows the timer to be stopped and then restarted in the same direction it
was counting before it was stopped. If this is not desired, the TBCLR bit must be used to clear the direction. The
TBCLR bit also clears the TBR value and the clock divider.
In up/down mode, the TBCCR0 CCIFG interrupt flag and the TBIFG interrupt flag are set only once during the
period, separated by 1/2 the timer period. The TBCCR0 CCIFG interrupt flag is set when the timer counts from
TBCL0-1 to TBCL0, and TBIFG is set when the timer completes counting down from 0001h to 0000h. Figure
13-8 shows the flag set cycle.
Timer Clock
Up/Down
Set TBIFG
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 401
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_B www.ti.com
The ability to simultaneously load grouped compare latches assures the dead times.
TBR(max)
TBCL0
TBCL1
TBCL3
0h
Dead Time
Output Mode 6:Toggle/Set
Timer Clock
CCI
Capture
402 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_B
Overflow logic is provided in each capture/compare register to indicate if a second capture was performed before
the value from the first capture was read. Bit COV is set when this occurs as shown in Figure 13-11. COV must
be reset with software.
Idle
No Read
Capture
Capture Taken
Taken
Taken Capture
Capture
Capture
Clear Bit COV
in Register TBCCTLx
Second
Capture Idle
Taken
COV = 1
Capture
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 403
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_B www.ti.com
404 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_B
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 405
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_B www.ti.com
TBR(max)
TBCL0
TBCL1
0h
406 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_B
TBR(max)
TBCL0
TBCL1
0h
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 407
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_B www.ti.com
TBR(max)
TBCL0
TBCL3
0h
Note
Switching Between Output Modes
When switching between output modes, one of the OUTMODx bits should remain set during the
transition, unless switching to mode 0. Otherwise, output glitching can occur because a NOR gate
decodes output mode 0. A safe method for switching between output modes is to use output mode 7
as a transition state:
BIS #OUTMOD_7,&TBCCTLx ; Set output mode=7
BIC #OUTMODx, &TBCCTLx ; Clear unwanted bits
408 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_B
Set CCIE
EQU0 IRQ, Interrupt Service Requested
D Q
CAP
Timer Clock
Reset
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 409
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_B www.ti.com
410 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_B
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 411
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_B www.ti.com
7 6 5 4 3 2 1 0
IDx MCx Unused TBCLR TBIE TBIFG
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) w-(0) rw-(0) rw-(0)
Counter length
00b = 16 bit, TBR(max) = 0FFFFh
12-11 CNTLx R/W 0h 01b = 12 bit, TBR(max) = 0FFFh
10b = 10 bit, TBR(max) = 03FFh
11b = 8 bit, TBR(max) = 0FFh
10 Unused R/W 0h
Timer_B clock source select.
00b = TBCLK
01b = ACLK
9-8 TBSSELx R/W 0h
10b = SMCLK
11b = INCLK (INCLK is device-specific and is often assigned to the
inverted TBCLK) (see the device-specific data sheet)
Input divider. These bits select the divider for the input clock.
00b = /1
7-6 IDx R/W 0h 01b = /2
10b = /4
11b = /8
412 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_B
7 6 5 4 3 2 1 0
TBRx
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 413
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_B www.ti.com
7 6 5 4 3 2 1 0
OUTMODx CCIE CCI OUT COV CCIFG
rw-(0) rw-(0) rw-(0) rw-(0) r-(0) rw-(0) rw-(0) rw-(0)
Compare latch load. These bits select the compare latch load event.
00b = TBCLx loads on write to TBCCRx
01b = TBCLx loads when TBR counts to 0
10-9 CLLDx R/W 0h
10b = TBCLx loads when TBR counts to 0 (up or continuous mode)
TBCLx loads when TBR counts to TBCL0 or to 0 (up/down mode)
11b = TBCLx loads when TBR counts to TBCLx
Capture mode
8 CAP R/W 0h 0b = Compare mode
1b = Capture mode
414 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Timer_B
Output. For output mode 0, this bit directly controls the state of the
output.
2 OUT R/W 0h
0b = Output low
1b = Output high
7 6 5 4 3 2 1 0
TBCCRx
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 415
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Timer_B www.ti.com
7 6 5 4 3 2 1 0
TBIVx
r0 r0 r0 r0 r-(0) r-(0) r-(0) r0
416 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Interface (USI)
Chapter 14
Universal Serial Interface (USI)
The Universal Serial Interface (USI) module provides SPI and I2C serial communication with one hardware
module. This chapter discusses both modes.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 417
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Interface (USI) www.ti.com
418 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Interface (USI)
D Q SDO
USI16B USILSB
USIPE7
EN USISR
USICNTx USIIFGCC
Bit Counter
Set USIIFG
USISWRST EN
USICKPH
USICKPL
USIPE5
Shift Clock 1
SCLK
0
USISSELx
USIIFG
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 419
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Interface (USI) www.ti.com
USIOE
USII2C = 1
USICKPL = 1 Set USIAL,
USICKPH = 0 D Q
Clear USIOE
USILSB = 0
USI16B = 0
USIGE
D Q
G
USIPE7
MSB LSB
8−Bit Shift Register SDA
EN USISRL
USICNTx USIIFGCC
USISTTIFG
USIIFG SCL Hold
USISCLREL
USISSELx
USIMST
SCLK 000
USIDIVx
ACLK 001
SMCLK 010 HOLD 1
SMCLK 011 Clock Divider USICLK
0
SWCLK 100 /1/2/4/8... /128
TA0 101
TA1 110
TA2 111
420 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Interface (USI)
Note
If USIIE = 1 when the USI module is in software reset mode (USISWRST = 1), repeated USI counter
interrupts can occur, because the default value of USIIFG is 1.
To avoid these repeated interrupts, disable the USI counter interrupt (USIIE = 0) before placing the
USI module into software reset mode (USISWRST = 1).
When exiting software reset mode, do not set USIIE until after USISWRST is cleared.
To activate USI port functionality, the corresponding USIPEx bits in the USI control register must be set to select
the USI function for the pin and maintain the PxIN and PxIFG functions for the pin. With this feature, the port
input levels can be read by software in the PxIN register, and the incoming data stream can generate port
interrupts on data transitions. This is useful, for example, to generate a port interrupt on a START edge.
14.2.2 USI Clock Generation
The USI clock generator contains a clock selection multiplexer, a divider, and the ability to select the clock
polarity as shown in the block diagrams Figure 14-1 and Figure 14-2.
The clock source can be selected from the internal clocks ACLK or SMCLK, from an external clock SCLK, as
well as from the capture/compare outputs of Timer_A. In addition, it is possible to clock the module by software
using the USISWCLK bit when USISSELx = 100.
The USIDIVx bits can be used to divide the selected clock by a power of 2 up to 128. The generated clock,
USICLK, is stopped when USIIFG = 1 or when the module operates in slave mode.
The USICKPL bit is used to select the polarity of USICLK. When USICKPL = 0, the inactive level of USICLK is
low. When USICKPL = 1 the inactive level of USICLK is high.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 421
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Interface (USI) www.ti.com
0 1 SCLK
1 0 SCLK
1 1 SCLK
Load USICNTx
USIIFG
422 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Interface (USI)
TX TX
USISRL USISRL
RX RX
USISRL USISRL
When USI16B = 1, all 16 bits are used for data handling. When using USISR to access both USISRL and
USISRH, the data needs to be properly adjusted when < 16 bits are used in the same manner as shown in
Figure 14-4.
14.2.3.4 SPI Interrupts
There is one interrupt vector associated with the USI module, and one interrupt flag, USIIFG, relevant for SPI
operation. When USIIE and the GIE bit are set, the interrupt flag will generate an interrupt request.
USIIFG is set when USICNTx becomes zero, either by counting or by directly writing 0 to the USICNTx bits.
USIIFG is cleared by writing a value > 0 to the USICNTx bits when USIIFGCC = 0, or directly by software.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 423
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Interface (USI) www.ti.com
424 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Interface (USI)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 425
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Interface (USI) www.ti.com
426 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Interface (USI)
The USI registers can be accessed with word instructions as shown in Table 14-2.
Table 14-2. Word Access to USI Registers
Address Acronym Register Name High-Byte Register Low-Byte Register
078h USICTL USI control USICTL1 USICTL0
07Ah USICCTL USI clock and counter control USICNT USICKCTL
07Ch USISR USI shift USISRH USISRL
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 427
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Interface (USI) www.ti.com
USI SDO/SCL port enable. Output in SPI mode, input or open drain
output in I2C mode.
6 USIPE6 R/W 0h
0b = USI function disabled
1b = USI function enabled
USI SCLK port enable. Input in SPI slave mode, or I2C mode, output
in SPI master mode.
5 USIPE5 R/W 0h
0b = USI function disabled
1b = USI function enabled
LSB first select. This bit controls the direction of the receive and
transmit shift register.
4 USILSB R/W 0h
0b = MSB first
1b = LSB first
Master select
3 USIMST R/W 0h 0b = Slave mode
1b = Master mode
428 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Interface (USI)
Arbitration lost
3 USIAL R/W 0h 0b = No arbitration lost condition
1b = Arbitration lost
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 429
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Interface (USI) www.ti.com
Software clock
0 USISWCLK R/W 0h 0b = Input clock is low
1b = Input clock is high
430 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Interface (USI)
USI interrupt flag clear control. When USIIFGCC = 1 the USIIFG will
not be cleared automatically when USICNTx is written with a value >
5 USIIFGCC R/W 0h 0.
0b = USIIFG automatically cleared on USICNTx update
1b = USIIFG is not cleared automatically
USI bit count. The USICNTx bits set the number of bits to be
4-0 USICNTx R/W 0h
received or transmitted.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 431
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Interface (USI) www.ti.com
432 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
Chapter 15
Universal Serial Communication Interface, UART
Mode
The universal serial communication interface (USCI) supports multiple serial communication modes with one
hardware module. This chapter discusses the operation of the asynchronous UART mode.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 433
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
434 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
UCABEN
UCSSELx
Receive Baudrate Generator
UC0BRx
UC0CLK 00 16
ACLK 01 Receive Clock
Prescaler/Divider
SMCLK 10 BRCLK
SMCLK 11 Modulator Transmit Clock
4 3
UCBRFx UCBRSx UCOS16
2
UCMODEx UCSPB
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 435
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
Note
Initializing or Reconfiguring the USCI Module
The recommended USCI initialization or reconfiguration process is:
1. Set UCSWRST ( BIS.B #UCSWRST,&UCAxCTL1 )
2. Initialize all USCI registers with UCSWRST = 1 (including UCAxCTL1)
3. Configure ports.
4. Clear UCSWRST via software ( BIC.B #UCSWRST,&UCAxCTL1 )
5. Enable interrupts (optional) via UCAxRXIE and/or UCAxTXIE
436 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
Blocks of
Characters
UCAxTXD/RXD
First Character Within Block Character Within Block Character Within Block
Is Address. It Follows Idle
Period of 10 Bits or More Idle Period Less Than 10 Bits
The UCDORM bit is used to control data reception in the idle-line multiprocessor format. When UCDORM = 1,
all non-address characters are assembled but not transferred into the UCAxRXBUF, and interrupts are not
generated. When an address character is received, the character is transferred into UCAxRXBUF, UCAxRXIFG
is set, and any applicable error flag is set when UCRXEIE = 1. When UCRXEIE = 0 and an address character
is received but has a framing error or parity error, the character is not transferred into UCAxRXBUF and
UCAxRXIFG is not set.
If an address is received, user software can validate the address and must reset UCDORM to continue receiving
data. If UCDORM remains set, only address characters will be received. When UCDORM is cleared during the
reception of a character the receive interrupt flag will be set after the reception completed. The UCDORM bit is
not modified by the USCI hardware automatically.
For address transmission in idle-line multiprocessor format, a precise idle period can be generated by the USCI
to generate address character identifiers on UCAxTXD. The double-buffered UCTXADDR flag indicates if the
next character loaded into UCAxTXBUF is preceded by an idle line of 11 bits. UCTXADDR is automatically
cleared when the start bit is generated.
15.3.3.2 Transmitting an Idle Frame
The following procedure sends out an idle frame to indicate an address character followed by associated data:
1. Set UCTXADDR, then write the address character to UCAxTXBUF. UCAxTXBUF must be ready for new
data (UCAxTXIFG = 1).
This generates an idle period of exactly 11 bits followed by the address character. UCTXADDR is reset
automatically when the address character is transferred from UCAxTXBUF into the shift register.
2. Write desired data characters to UCAxTXBUF. UCAxTXBUF must be ready for new data (UCAxTXIFG = 1).
The data written to UCAxTXBUF is transferred to the shift register and transmitted as soon as the shift
register is ready for new data.
The idle-line time must not be exceeded between address and data transmission or between data
transmissions. Otherwise, the transmitted data will be misinterpreted as an address.
15.3.3.3 Address-Bit Multiprocessor Format
When UCMODEx = 10, the address-bit multiprocessor format is selected. Each processed character contains an
extra bit used as an address indicator shown in Figure 15-4. The first character in a block of characters carries a
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 437
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
set address bit which indicates that the character is an address. The USCI UCADDR bit is set when a received
character has its address bit set and is transferred to UCAxRXBUF.
The UCDORM bit is used to control data reception in the address-bit multiprocessor format. When UCDORM is
set, data characters with address bit = 0 are assembled by the receiver but are not transferred to UCAxRXBUF
and no interrupts are generated. When a character containing a set address bit is received, the character is
transferred into UCAxRXBUF, UCAxRXIFG is set, and any applicable error flag is set when UCRXEIE = 1. When
UCRXEIE = 0 and a character containing a set address bit is received, but has a framing error or parity error, the
character is not transferred into UCAxRXBUF and UCAxRXIFG is not set.
If an address is received, user software can validate the address and must reset UCDORM to continue receiving
data. If UCDORM remains set, only address characters with address bit = 1 will be received. The UCDORM bit
is not modified by the USCI hardware automatically.
When UCDORM = 0 all received characters will set the receive interrupt flag UCAxRXIFG. If UCDORM is
cleared during the reception of a character the receive interrupt flag will be set after the reception is completed.
For address transmission in address-bit multiprocessor mode, the address bit of a character is controlled by the
UCTXADDR bit. The value of the UCTXADDR bit is loaded into the address bit of the character transferred from
UCAxTXBUF to the transmit shift register. UCTXADDR is automatically cleared when the start bit is generated.
Blocks of
Characters
UCAxTXD/UCAxRXD
438 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
For LIN conformance the character format should be set to 8 data bits, LSB first, no parity and one stop bit. No
address bit is available.
The synch field consists of the data 055h inside a byte field as shown in Figure 15-6. The synchronization is
based on the time measurement between the first falling edge and the last falling edge of the pattern. The
transmit baud rate generator is used for the measurement if automatic baud rate detection is enabled by setting
UCABDEN. Otherwise, the pattern is received but not measured. The result of the measurement is transferred
into the baud rate control registers UCAxBR0, UCAxBR1, and UCAxMCTL. If the length of the synch field
exceeds the measurable time the synch timeout error flag UCSTOE is set.
Synch
8 Bit Times
Start Stop
0 1 2 3 4 5 6 7
Bit Bit
The UCDORM bit is used to control data reception in this mode. When UCDORM is set, all characters are
received but not transferred into the UCAxRXBUF, and interrupts are not generated. When a break/synch field
is detected the UCBRK flag is set. The character following the break/synch field is transferred into UCAxRXBUF
and the UCAxRXIFG interrupt flag is set. Any applicable error flag is also set. If the UCBRKIE bit is set,
reception of the break/synch sets the UCAxRXIFG. The UCBRK bit is reset by user software or by reading the
receive buffer UCAxRXBUF.
When a break/synch field is received, user software must reset UCDORM to continue receiving data. If
UCDORM remains set, only the character after the next reception of a break/synch field will be received. The
UCDORM bit is not modified by the USCI hardware automatically.
When UCDORM = 0 all received characters will set the receive interrupt flag UCAxRXIFG. If UCDORM is
cleared during the reception of a character the receive interrupt flag will be set after the reception is complete.
The automatic baud rate detection mode can be used in a full-duplex communication system with some
restrictions. The USCI can not transmit data while receiving the break/sync field and if a 0h byte with framing
error is received any data transmitted during this time gets corrupted. The latter case can be discovered by
checking the received data and the UCFE bit.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 439
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
UART
IrDA
To set the pulse time of 3/16 bit period required by the IrDA standard the BITCLK16 clock is selected with
UCIRTXCLK = 1 and the pulse length is set to 6 half clock cycles with UCIRTXPLx = 6 – 1 = 5.
When UCIRTXCLK = 0, the pulse length tPULSE is based on BRCLK and is calculated as follows:
UCIRTXPLx = tPULSE × 2 × fBRCLK − 1
When the pulse length is based on BRCLK the prescaler UCBRx must to be set to a value greater or equal to 5.
15.3.5.2 IrDA Decoding
The decoder detects high pulses when UCIRRXPL = 0. Otherwise it detects low pulses. In addition to the
analog deglitch filter an additional programmable digital filter stage can be enabled by setting UCIRRXFE.
When UCIRRXFE is set, only pulses longer than the programmed filter length are passed. Shorter pulses are
discarded. The equation to program the filter length UCIRRXFLx is:
UCIRRXFLx = (tPULSE − tWAKE) × 2 × fBRCLK − 4
Where,
tPULSE = Minimum receive pulse duration
tWAKE = Wake time from any low-power mode. Zero when MSP430 is in active mode.
440 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
Note
Reliable reception of IrDA signals
To receive incoming IrDA signals reliably, make sure that at least one of the following procedures are
implemented:
• Enable the digital filter stage with UCIRRXFE = 1.
• Use a parity bit to detect corrupted bytes.
• Check the correctness of received data frames using a checksum or CRC.
• With parity or CRC checks, use a protocol that acknowledges received data frame and resends
data if the sender does not receive an acknowledgment.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 441
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
When UCRXEIE = 0 and a framing error, or parity error is detected, no character is received into UCAxRXBUF.
When UCRXEIE = 1, characters are received into UCAxRXBUF and any applicable error bit is set.
When UCFE, UCPE, UCOE, UCBRK, or UCRXERR is set, the bit remains set until user software resets it or
UCAxRXBUF is read. UCOE must be reset by reading UCAxRXBUF. Otherwise it will not function properly.
To detect overflows reliably, the following flow is recommended. After a character is received and UCAxRXIFG
is set, first read UCAxSTAT to check the error flags including the overflow flag UCOE. Read UCAxRXBUF
next. This will clear all error flags except UCOE, if UCAxRXBUF was overwritten between the read access to
UCAxSTAT and to UCAxRXBUF. The UCOE flag should be checked after reading UCAxRXBUF to detect this
condition. Note that, in this case, the UCRXERR flag is not set.
15.3.7 USCI Receive Enable
The USCI module is enabled by clearing the UCSWRST bit and the receiver is ready and in an idle state. The
receive baud rate generator is in a ready state but is not clocked nor producing any clocks.
The falling edge of the start bit enables the baud rate generator and the UART state machine checks for a
valid start bit. If no valid start bit is detected the UART state machine returns to its idle state and the baud rate
generator is turned off again. If a valid start bit is detected a character will be received.
When the idle-line multiprocessor mode is selected with UCMODEx = 01 the UART state machine checks for an
idle line after receiving a character. If a start bit is detected another character is received. Otherwise the UCIDLE
flag is set after 10 ones are received and the UART state machine returns to its idle state and the baud rate
generator is turned off.
442 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
URXDx
URXS
tτ
When a glitch is longer than tτ or a valid start bit occurs on UCAxRXD, the USCI receive operation is started
and a majority vote is taken as shown in Figure 15-9. If the majority vote fails to detect a start bit the USCI halts
character reception.
Majority Vote Taken
URXDx
URXS
tτ
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 443
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
Timing for each bit is shown in Figure 15-10. For each bit received, a majority vote is taken to determine the
bit value. These samples occur at the N/2 - 1/2, N/2, and N/2 + 1/2 BRCLK periods, where N is the number of
BRCLKs per BITCLK.
BRCLK
BITCLK
Bit Period
m: corresponding modulation bit
R: Remainder from N/2 division
Modulation is based on the UCBRSx setting as shown in Table 15-2. A 1 in the table indicates that m = 1 and
the corresponding BITCLK period is one BRCLK period longer than a BITCLK period with m = 0. The modulation
wraps around after 8 bits but restarts with each new start bit.
Table 15-2. BITCLK Modulation Pattern
Bit 0
UCBRSx Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 Bit 7
(Start Bit)
0 0 0 0 0 0 0 0 0
1 0 1 0 0 0 0 0 0
2 0 1 0 0 0 1 0 0
3 0 1 0 1 0 1 0 0
4 0 1 0 1 0 1 0 1
5 0 1 1 1 0 1 0 1
6 0 1 1 1 0 1 1 1
7 0 1 1 1 1 1 1 1
444 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
The division factor N is often a non-integer value thus at least one divider and one modulator stage is used to
meet the factor as closely as possible.
If N is equal or greater than 16 the oversampling baud rate generation mode can be chosen by setting UCOS16.
15.3.10.1 Low-Frequency Baud Rate Mode Setting
In the low-frequency mode, the integer portion of the divisor is realized by the prescaler:
UCBRx = INT(N)
and the fractional portion is realized by the modulator with the following nominal formula:
UCBRSx = round( ( N – INT(N) ) × 8 )
Incrementing or decrementing the UCBRSx setting by one count may give a lower maximum bit error for any
given bit. To determine if this is the case, a detailed error calculation must be performed for each bit for each
UCBRSx setting.
15.3.10.2 Oversampling Baud Rate Mode Setting
In the oversampling mode the prescaler is set to:
N
UCBRx = INT( )
16
When greater accuracy is required, the UCBRSx modulator can also be implemented with values from 0 to 7. To
find the setting that gives the lowest maximum bit error rate for any given bit, a detailed error calculation must be
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 445
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
performed for all settings of UCBRSx from 0 to 7 with the initial UCBRFx setting and with the UCBRFx setting
incremented and decremented by one.
15.3.11 Transmit Bit Timing
The timing for each character is the sum of the individual bit timings. Using the modulation features of the baud
rate generator reduces the cumulative bit error. The individual bit error can be calculated using the following
steps.
15.3.11.1 Low-Frequency Baud Rate Mode Bit Timing
In low-frequency mode, calculate the length of bit i Tbit,TX[i] based on the UCBRx and UCBRSx settings:
1
Tbit,TX [i] = (UCBRx + mUCBRSx [i])
fBRCLK
Where,
mUCBRSx[i] = Modulation of bit i from Table 15-2
15.3.11.2 Oversampling Baud Rate Mode Bit Timing
In oversampling baud rate mode calculate the length of bit i Tbit,TX[i] based on the baud rate generator UCBRx,
UCBRFx and UCBRSx settings:
æ 15 ö
Tbit,TX [i] =
1 ç
fBRCLK çç
(16 + mUCBRSx )
[i] × UCBRx + å m [j]
UCBRFx ÷
÷
÷
è j=0 ø
Where,
15
åm UCBRFx [j]
j=0 = Sum of ones from the corresponding row in Table 15-3
mUCBRSx[i] = Modulation of bit i from Table 15-2
This results in an end-of-bit time tbit,TX[i] equal to the sum of all previous and the current bit times:
i
tbit,TX [i] = åT
j=0
bit,TX [j]
To calculate bit error, this time is compared to the ideal bit time tbit,ideal,TX[i]:
1
tbit,ideal,TX [i] = (i + 1)
Baud rate
This results in an error normalized to one ideal bit time (1 / baud rate):
ErrorTX[i] = (tbit,TX[i] – tbit,ideal,TX[i]) × baud rate × 100%
15.3.12 Receive Bit Timing
Receive timing error consists of two error sources. The first is the bit-to-bit timing error similar to the transmit bit
timing error. The second is the error between a start edge occurring and the start edge being accepted by the
USCI module. Figure 15-11 shows the asynchronous timing errors between data on the UCAxRXD pin and the
internal baud-rate clock. This results in an additional synchronization error. The synchronization error tSYNC is
between -0.5 BRCLKs and +0.5 BRCLKs independent of the selected baud rate generation mode.
446 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
i 0 1 2
tideal t0 t1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 5 6 7
BRCLK
UCAxRXD ST D0 D1
RXD synch. ST D0 D1
tactual t0 t1 t2
Synchronization Error ± 0.5x BRCLK
Sample
RXD synch.
The real sampling time is equal to the sum of all previous bits according to the formulas shown in the transmit
timing section, plus one half BITCLK for the current bit i, plus the synchronization error tSYNC.
This results in the following for the low-frequency baud rate mode:
i-1
æ ö
tbit,RX [i] = tSYNC + åT
j=0
bit,RX [j] +
1
fBRCLK è
æ1
è2
ö
çç INT ç UCBRx ÷ + mUCBRSx [i] ÷÷
ø ø
Where,
1
Tbit,RX [i] =
fBRCLK
(UCBRx + mUCBRSx [i])
Where,
æ 15 ö
Tbit,RX [i] =
1 ç
fBRCLK çç
(16 + mUCBRSx [i] ) × UCBRx + m [j]
UCBRFx ÷
÷
÷
å
è j=0 ø
7+mUCBRSx [i]
å mUCBRFx [j]
j=0 = Sum of ones from columns 0 - from the corresponding row in Table 15-3
mUCBRSx[i] = Modulation of bit i from Table 15-2
This results in an error normalized to one ideal bit time (1 / baud rate) according to the following formula:
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 447
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
448 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
Table 15-4. Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 0 (continued)
BRCLK
Baud Rate
Frequency UCBRx UCBRSx UCBRFx Maximum TX Error [%] Maximum RX Error [%]
[Baud]
[Hz]
12,000,000 19200 625 0 0 0 0 -0.2 0
12,000,000 38400 312 4 0 -0.2 0 -0.2 0.2
12,000,000 56000 214 2 0 -0.3 0.2 -0.4 0.5
12,000,000 115200 104 1 0 -0.5 0.6 -0.9 1.2
12,000,000 128000 93 6 0 -0.8 0 -1.5 0.4
12,000,000 256000 46 7 0 -1.9 0 -2.0 2.0
16,000,000 9600 1666 6 0 -0.05 0.05 -0.05 0.1
16,000,000 19200 833 2 0 -0.1 0.05 -0.2 0.1
16,000,000 38400 416 6 0 -0.2 0.2 -0.2 0.4
16,000,000 56000 285 6 0 -0.3 0.1 -0.5 0.2
16,000,000 115200 138 7 0 -0.7 0 -0.8 0.6
16,000,000 128000 125 0 0 0 0 -0.8 0
16,000,000 256000 62 4 0 -0.8 0 -1.2 1.2
Table 15-5. Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 1
BRCLK
Baud Rate
Frequency UCBRx UCBRSx UCBRFx Maximum TX Error [%] Maximum RX Error [%]
[Baud]
[Hz]
1,048,576 9600 6 0 13 -2.3 0 -2.2 0.8
1,048,576 19200 3 1 6 -4.6 3.2 -5.0 4.7
1,000,000 9600 6 0 8 -1.8 0 -2.2 0.4
1,000,000 19200 3 0 4 -1.8 0 -2.6 0.9
1,000,000 57600 1 7 0 -34.4 0 -33.4 0
4,000,000 9600 26 0 1 0 0.9 0 1.1
4,000,000 19200 13 0 0 -1.8 0 -1.9 0.2
4,000,000 38400 6 0 8 -1.8 0 -2.2 0.4
4,000,000 57600 4 5 3 -3.5 3.2 -1.8 6.4
4,000,000 115200 2 3 2 -2.1 4.8 -2.5 7.3
4,000,000 230400 1 7 0 -34.4 0 -33.4 0
8,000,000 9600 52 0 1 -0.4 0 -0.4 0.1
8,000,000 19200 26 0 1 0 0.9 0 1.1
8,000,000 38400 13 0 0 -1.8 0 -1.9 0.2
8,000,000 57600 8 0 11 0 0.88 0 1.6
8,000,000 115200 4 5 3 -3.5 3.2 -1.8 6.4
8,000,000 230400 2 3 2 -2.1 4.8 -2.5 7.3
8,000,000 460800 1 7 0 -34.4 0 -33.4 0
12,000,000 9600 78 0 2 0 0 -0.05 0.05
12,000,000 19200 39 0 1 0 0 0 0.2
12,000,000 38400 19 0 8 -1.8 0 -1.8 0.1
12,000,000 57600 13 0 0 -1.8 0 -1.9 0.2
12,000,000 115200 6 0 8 -1.8 0 -2.2 0.4
12,000,000 230400 3 0 4 -1.8 0 -2.6 0.9
16,000,000 9600 104 0 3 0 0.2 0 0.3
16,000,000 19200 52 0 1 -0.4 0 -0.4 0.1
16,000,000 38400 26 0 1 0 0.9 0 1.1
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 449
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
Table 15-5. Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 1 (continued)
BRCLK
Baud Rate
Frequency UCBRx UCBRSx UCBRFx Maximum TX Error [%] Maximum RX Error [%]
[Baud]
[Hz]
16,000,000 57600 17 0 6 0 0.9 -0.1 1.0
16,000,000 115200 8 0 11 0 0.9 0 1.6
16,000,000 230400 4 5 3 -3.5 3.2 -1.8 6.4
16,000,000 460800 2 3 2 -2.1 4.8 -2.5 7.3
15.3.14 Using the USCI Module in UART Mode with Low Power Modes
The USCI module provides automatic clock activation for SMCLK for use with low-power modes. When SMCLK
is the USCI clock source, and is inactive because the device is in a low-power mode, the USCI module
automatically activates it when needed, regardless of the control-bit settings for the clock source. The clock
remains active until the USCI module returns to its idle condition. After the USCI module returns to the idle
condition, control of the clock source reverts to the settings of its control bits. Automatic clock activation is not
provided for ACLK.
When the USCI module activates an inactive clock source, the clock source becomes active for the whole device
and any peripheral configured to use the clock source may be affected. For example, a timer using SMCLK will
increment while the USCI module forces SMCLK active.
15.3.15 USCI Interrupts
The USCI has one interrupt vector for transmission and one interrupt vector for reception.
15.3.15.1 USCI Transmit Interrupt Operation
The UCAxTXIFG interrupt flag is set by the transmitter to indicate that UCAxTXBUF is ready to accept another
character. An interrupt request is generated if UCAxTXIE and GIE are also set. UCAxTXIFG is automatically
reset if a character is written to UCAxTXBUF.
UCAxTXIFG is set after a PUC or when UCSWRST = 1. UCAxTXIE is reset after a PUC or when UCSWRST =
1.
15.3.15.2 USCI Receive Interrupt Operation
The UCAxRXIFG interrupt flag is set each time a character is received and loaded into UCAxRXBUF. An
interrupt request is generated if UCAxRXIE and GIE are also set. UCAxRXIFG and UCAxRXIE are reset by a
system reset PUC signal or when UCSWRST = 1. UCAxRXIFG is automatically reset when UCAxRXBUF is
read.
Additional interrupt control features include:
• When UCAxRXEIE = 0 erroneous characters will not set UCAxRXIFG.
• When UCDORM = 1, non-address characters will not set UCAxRXIFG in multiprocessor modes. In plain
UART mode, no characters will set UCAxRXIFG.
• When UCBRKIE = 1 a break condition will set the UCBRK bit and the UCAxRXIFG flag.
15.3.15.3 USCI Interrupt Usage
USCI_Ax and USCI_Bx share the same interrupt vectors. The receive interrupt flags UCAxRXIFG and
UCBxRXIFG are routed to one interrupt vector, the transmit interrupt flags UCAxTXIFG and UCBxTXIFG share
another interrupt vector.
Example 15-1 shows an extract of an interrupt service routine to handle data receive interrupts from USCI_A0 in
either UART or SPI mode and USCI_B0 in SPI mode.
450 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
USCIA0_RX_USCIB0_RX_ISR
BIT.B #UCA0RXIFG, &IFG2 ; USCI_A0 Receive Interrupt?
JNZ USCIA0_RX_ISR
USCIB0_RX_ISR?
; Read UCB0RXBUF (clears UCB0RXIFG)
...
RETI
USCIA0_RX_ISR
; Read UCA0RXBUF (clears UCA0RXIFG)
...
RETI
Example 15-2 shows an extract of an interrupt service routine to handle data transmit interrupts from USCI_A0 in
either UART or SPI mode and USCI_B0 in SPI mode.
Example 15-2. Shared Interrupt Vectors Software Example, Data Transmit
USCIA0_TX_USCIB0_TX_ISR
BIT.B #UCA0TXIFG, &IFG2 ; USCI_A0 Transmit Interrupt?
JNZ USCIA0_TX_ISR
USCIB0_TX_ISR
; Write UCB0TXBUF (clears UCB0TXIFG)
...
RETI
USCIA0_TX_ISR
; Write UCA0TXBUF (clears UCA0TXIFG)
...
RETI
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 451
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
D0h UCA1CTL0 USCI_A1 control 0 Read/write 00h with PUC Section 15.4.1
D1h UCA1CTL1 USCI_A1 control 1 Read/write 01h with PUC Section 15.4.2
D2h UCA1BR0 USCI_A1 baud-rate control 0 Read/write 00h with PUC Section 15.4.3
D3h UCA1BR1 USCI_A1 baud-rate control 1 Read/write 00h with PUC Section 15.4.3
D4h UCA1MCTL USCI_A1 modulation control Read/write 00h with PUC Section 15.4.5
D5h UCA1STAT USCI_A1 status Read/write 00h with PUC Section 15.4.6
D6h UCA1RXBUF USCI_A1 receive buffer Read 00h with PUC Section 15.4.7
D7h UCA1TXBUF USCI_A1 transmit buffer Read/write 00h with PUC Section 15.4.8
CDh UCA1ABCTL USCI_A1 auto baud control Read/write 00h with PUC Section 15.4.11
CEh UCA1IRTCTL USCI_A1 IrDA transmit control Read/write 00h with PUC Section 15.4.9
CFh UCA1IRRTCTL USCI_A1 IrDA receive control Read/write 00h with PUC Section 15.4.10
6h UC1IE USCI_A1/B1 interrupt enable Read/write 00h with PUC Section 15.4.14
7h UC1IFG USCI_A1/B1 interrupt flag Read/write 0Ah with PUC Section 15.4.15
Note
Modifying SFR bits
To avoid modifying control bits of other modules, TI recommends setting or clearing the IEx and IFGx
bits using BIS.B or BIC.B instructions, rather than MOV.B or CLR.B instructions.
452 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
MSB first select. Controls the direction of the receive and transmit
shift register.
5 UCMSB R/W 0h
0b = LSB first
1b = MSB first
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 453
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
Transmit break. Transmits a break with the next write to the transmit
buffer. In UART mode with automatic baud rate detection 055h must
be written into UCAxTXBUF to generate the required break/synch
1 UCTXBRK R/W 0h
fields. Otherwise 0h must be written into the transmit buffer.
0b = Next frame transmitted is not a break
1b = Next frame transmitted is a break or a break/synch
454 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 455
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
456 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
Receive error flag. This bit indicates a character was received with
errors. When UCRXERR = 1, one or more error flags (UCFE, UCPE,
2 UCRXERR R/W 0h UCOE) is also set. UCRXERR is cleared when UCAxRXBUF is read.
0b = No receive errors detected
1b = Receive error detected
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 457
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
458 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 459
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
460 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, UART Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 461
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, UART Mode www.ti.com
462 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, SPI Mode
Chapter 16
Universal Serial Communication Interface, SPI
Mode
The universal serial communication interface (USCI) supports multiple serial communication modes with one
hardware module. This chapter discusses the operation of the synchronous peripheral interface or SPI mode.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 463
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, SPI Mode www.ti.com
464 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, SPI Mode
UCLISTEN UCMST
Receive Buffer UC xRXBUF
UCxSOMI
1
0
Receive Shift Register 0
1
UCMSB UC7BIT
UCSSELx
Bit Clock Generator
UCxBRx UCCKPH UCCKPL
N/A 00 16
ACLK 01 UCxCLK
Clock Direction,
Prescaler/Divider
SMCLK 10 BRCLK Phase and Polarity
SMCLK 11
UCMSB UC7BIT
UCxSIMO
Transmit Shift Register
UCMODEx
2 UCxSTE
Transmit Buffer UC xTXBUF
Transmit Enable
Control Set UCFE
Transmit State Machine
Set UCxTXIFG
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 465
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, SPI Mode www.ti.com
Note
Initializing or Re-Configuring the USCI Module
The recommended USCI initialization/re-configuration process is:
1. Set UCSWRST (BIS.B #UCSWRST,&UCxCTL1)
2. Initialize all USCI registers with UCSWRST=1 (including UCxCTL1)
3. Configure ports
4. Clear UCSWRST via software (BIC.B #UCSWRST,&UCxCTL1)
5. Enable interrupts (optional) via UCxRXIE and/or UCxTXIE
466 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, SPI Mode
Note
Default Character Format
The default SPI character transmission is LSB first. For communication with other SPI interfaces it
MSB-first mode may be required.
Note
Character Format for Figures
Figures throughout this chapter use MSB first format.
Px.x STE
SS
UCxSTE
Port.x
UCx
SOMI SOMI
Receive Shift Register Transmit Shift Register Data Shift Register (DSR)
UCxCLK SCLK
MSP430 USCI COMMON SPI
A set transmit interrupt flag, UCxTXIFG, indicates that data has moved from UCxTXBUF to the TX shift register
and UCxTXBUF is ready for new data. It does not indicate RX/TX completion.
To receive data into the USCI in master mode, data must be written to UCxTXBUF because receive and transmit
operations operate concurrently.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 467
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, SPI Mode www.ti.com
Px.x UCxSTE
SS
STE
Port.x
UCx
SOMI SOMI
Data Shift Register DSR Transmit Shift Register Receive Shift Register
SCLK UCxCLK
COMMON SPI MSP430 USCI
468 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, SPI Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 469
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, SPI Mode www.ti.com
0 1 UCxCLK
1 0 UCxCLK
1 1 UCxCLK
UCxSTE
UCxSIMO
0 X MSB LSB
UCxSOMI
UCxSIMO
1 X MSB LSB
UCxSOMI
Move to UCxTXBUF
RX Sample Points
470 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, SPI Mode
Note
Writing to UCxTXBUF in SPI Mode
Data written to UCxTXBUF when UCxTXIFG = 0 may result in erroneous data transmission.
USCIA0_RX_USCIB0_RX_ISR
BIT.B #UCA0RXIFG, &IFG2 ; USCI_A0 Receive Interrupt?
JNZ USCIA0_RX_ISR
USCIB0_RX_ISR?
; Read UCB0RXBUF (clears UCB0RXIFG)
...
RETI
USCIA0_RX_ISR
; Read UCA0RXBUF (clears UCA0RXIFG)
...
RETI
USCIA0_TX_USCIB0_TX_ISR
BIT.B #UCA0TXIFG, &IFG2 ; USCI_A0 Transmit Interrupt?
JNZ USCIA0_TX_ISR
USCIB0_TX_ISR
; Write UCB0TXBUF (clears UCB0TXIFG)
...
RETI
USCIA0_TX_ISR
; Write UCA0TXBUF (clears UCA0TXIFG)
...
RETI
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 471
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, SPI Mode www.ti.com
68h UCB0CTL0 USCI_B0 control 0 Read/write 01h with PUC Section 16.4.1
69h UCB0CTL1 USCI_B0 control 1 Read/write 01h with PUC Section 16.4.1
6Ah UCB0BR0 USCI_B0 bit-rate control 0 Read/write 00h with PUC Section 16.4.3
6Bh UCB0BR1 USCI_B0 bit-rate control 1 Read/write 00h with PUC Section 16.4.3
6Dh UCB0STAT USCI_B0 status Read/write 00h with PUC Section 16.4.5
6Eh UCB0RXBUF USCI_B0 receive buffer Read 00h with PUC Section 16.4.6
6Fh UCB0TXBUF USCI_B0 transmit buffer Read/write 00h with PUC Section 16.4.7
1h IE2 SFR interrupt enable 2 Read/write 00h with PUC Section 16.4.8
3h IFG2 SFR interrupt flag 2 Read/write 0Ah with PUC Section 16.4.9
D0h UCA1CTL0 USCI_A1 control 0 Read/write 00h with PUC Section 16.4.1
D1h UCA1CTL1 USCI_A1 control 1 Read/write 01h with PUC Section 16.4.1
D2h UCA1BR0 USCI_A1 baud-rate control 0 Read/write 00h with PUC Section 16.4.3
D3h UCA1BR1 USCI_A1 baud-rate control 1 Read/write 00h with PUC Section 16.4.4
D5h UCA1STAT USCI_A1 status Read/write 00h with PUC Section 16.4.5
D6h UCA1RXBUF USCI_A1 receive buffer Read 00h with PUC Section 16.4.6
D7h UCA1TXBUF USCI_A1 transmit buffer Read/write 00h with PUC Section 16.4.7
D8h UCB1CTL0 USCI_B1 control 0 Read/write 01h with PUC Section 16.4.1
D9h UCB1CTL1 USCI_B1 control 1 Read/write 01h with PUC Section 16.4.1
DAh UCB1BR0 USCI_B1 bit-rate control 0 Read/write 00h with PUC Section 16.4.3
DBh UCB1BR1 USCI_B1 bit-rate control 1 Read/write 00h with PUC Section 16.4.4
DDh UCB1STAT USCI_B1 status Read/write 00h with PUC Section 16.4.5
DEh UCB1RXBUF USCI_B1 receive buffer Read 00h with PUC Section 16.4.6
DFh UCB1TXBUF USCI_B1 transmit buffer Read/write 00h with PUC Section 16.4.7
6h UC1IE USCI_A1/B1 interrupt enable Read/write 00h with PUC Section 16.4.10
7h UC1IFG USCI_A1/B1 interrupt flag Read/write 0Ah with PUC Section 16.4.11
Note
Modifying SFR bits
To avoid modifying control bits of other modules, TI recommends setting or clearing the IEx and IFGx
bits using BIS.B or BIC.B instructions, rather than MOV.B or CLR.B instructions.
472 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, SPI Mode
MSB first select. Controls the direction of the receive and transmit
shift register.
5 UCMSB R/W 0h
0b = LSB first
1b = MSB first
USCI mode. The UCMODEx bits select the synchronous mode when
UCSYNC = 1.
00b = 3-pin SPI
01b = 4-pin SPI with UCxSTE active high: slave enabled when
2-1 UCMODEx R/W 0h
UCxSTE = 1
10b = 4-pin SPI with UCxSTE active low: slave enabled when
UCxSTE = 0
11b = I2C mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 473
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, SPI Mode www.ti.com
474 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, SPI Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 475
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, SPI Mode www.ti.com
Framing error flag. This bit indicates a bus conflict in 4-wire master
mode. UCFE is not used in 3-wire master or any slave mode.
6 UCFE R/W 0h
0b = No error
1b = Bus error occured
476 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, SPI Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 477
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, SPI Mode www.ti.com
478 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, SPI Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 479
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, SPI Mode www.ti.com
480 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, SPI Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 481
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, SPI Mode www.ti.com
482 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
Chapter 17
Universal Serial Communication Interface, I2C
Mode
The universal serial communication interface (USCI) supports multiple serial communication modes with one
hardware module. This chapter discusses the operation of the I2C mode.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 483
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
484 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
UCA10 UCGCEN
UCxSDA
Receive Shift Register
UCSLA10
UCxSCL
UCSSELx
Bit Clock Generator
UCxBRx
UC1CLK 00 16
ACLK 01 UCMST
Prescaler/Divider
SMCLK 10 BRCLK
SMCLK 11
Note
SDA and SCL Levels
The MSP430 SDA and SCL pins must not be pulled up above the MSP430 VCC level.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 485
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
VCC
MSP430 Device A
Device B Device C
Note
Initializing or Reconfiguring the USCI Module
The recommended USCI initialization or reconfiguration process is:
1. Set UCSWRST (BIS.B #UCSWRST, &UCxCTL1)
2. Initialize all USCI registers with UCSWRST = 1 (including UCxCTL1)
3. Configure ports.
4. Clear UCSWRST by software (BIC.B #UCSWRST, &UCxCTL1)
5. Enable interrupts (optional) using UCxRXIE or UCxTXIE
486 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
SDA
MSB Acknowledgement Acknowledgement
Signal From Receiver Signal From Receiver
SCL
1 2 7 8 9 1 2 8 9
START STOP
Condition (S) R/W ACK ACK Condition (P)
START and STOP conditions are generated by the master and are shown in Figure 17-3. A START condition is a
high-to-low transition on the SDA line while SCL is high. A STOP condition is a low-to-high transition on the SDA
line while SCL is high. The bus busy bit, UCBBUSY, is set after a START and cleared after a STOP.
Data on SDA must be stable during the high period of SCL as shown in Figure 17-4. The high and low state of
SDA can only change when SCL is low, otherwise START or STOP conditions will be generated.
Data Line
Stable Data
SDA
SCL
S Slave Address 1st byte R/W ACK Slave Address 2nd byte ACK Data ACK P
1 1 1 1 0 X X
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 487
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
S Slave Address R/W ACK Data ACK S Slave Address R/W ACK Data ACK P
1 Any 1 Any Number
Number
Figure 17-7. I2C Module Addressing Format with Repeated START Condition
Other Master
Other Slave
USCI Master
USCI Slave
488 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
When a START condition is detected on the bus, the USCI module will receive the transmitted address and
compare it against its own address stored in UCBxI2COA. The UCSTTIFG flag is set when address received
matches the USCI slave address.
17.3.4.1.1 I2C Slave Transmitter Mode
Slave transmitter mode is entered when the slave address transmitted by the master is identical to its own
address with a set R/W bit. The slave transmitter shifts the serial data out on SDA with the clock pulses that are
generated by the master device. The slave device does not generate the clock, but it will hold SCL low while
intervention of the CPU is required after a byte has been transmitted.
If the master requests data from the slave the USCI module is automatically configured as a transmitter and
UCTR and UCBxTXIFG become set. The SCL line is held low until the first data to be sent is written into the
transmit buffer UCBxTXBUF. Then the address is acknowledged, the UCSTTIFG flag is cleared, and the data
is transmitted. As soon as the data is transferred into the shift register the UCBxTXIFG is set again. After the
data is acknowledged by the master the next data byte written into UCBxTXBUF is transmitted or if the buffer
is empty the bus is stalled during the acknowledge cycle by holding SCL low until new data is written into
UCBxTXBUF. If the master sends a NACK succeeded by a STOP condition the UCSTPIFG flag is set. If the
NACK is succeeded by a repeated START condition the USCI I2C state machine returns to its address-reception
state.
Figure 17-9 shows the slave transmitter operation.
Reception of own S SLA/R A A A P
A DATA DATA DATA
address and
transmission of data
bytes
UCTR=1 (Transmitter) Write data to UCBxTXBUF UCBxTXIFG=0
UCSTTIFG=1
UCBxTXIFG=1
UCSTPIFG=?0
UCBxTXBUF discarded UCBxTXIFG=1 UCSTPIFG=1
UCSTTIFG=0
UCBxTXIFG=0
UCTR=1 (Transmitter)
UCSTTIFG=1
UCBxTXIFG=1
UCBxTXBUF discarded
UCBxTXIFG=0
UCALIFG=1
UCMST=0
UCTR=1 (Transmitter)
UCSTTIFG=1
UCBxTXIFG=1
UCSTPIFG=0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 489
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
490 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
UCTXNACK=1 UCTXNACK=0
UCTR=0 (Receiver)
UCSTTIFG=1
UCGC=1
Arbitration lost as
A
master and
addressed as slave
UCALIFG=1
UCMST=0
UCTR=0 (Receiver)
UCSTTIFG=1
(UCGC=1 if general call)
UCBxTXIFG=0
UCSTPIFG=0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 491
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
Slave Transmitter
UCTR=1 (Transmitter)
UCSTTIFG=1
UCBxTXIFG=1
UCSTPIFG=0
492 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 493
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
Successful A A A A
S SLA/W DATA DATA DATA P
transmission to a
slave receiver
1) UCTR=1 (Transmitter)
2) UCTXSTT=1
UCTXSTT=0
UCNACKIFG=1 DATA A S SLA/R
UCBxTXIFG=0
UCBxTXBUF discarded
1) UCTR=0 (Receiver)
2) UCTXSTT=1
UCTXSTP=1 3) UCBxTXIFG=0
Not acknowledge A P
received after slave UCTXSTP=0
address
1) UCTR=1 (Transmitter)
2) UCTXSTT=1
S SLA/W
UCBxTXIFG=1
UCBxTXBUF discarded
UCNACKIFG=1
UCBxTXIFG=0
UCBxTXBUF discarded
UCALIFG=1
UCMST=0
(UCSTTIFG=0)
UCALIFG=1
UCMST=0
UCTR=0 (Receiver)
UCSTTIFG=1
(UCGC=1 if general call)
UCBxTXIFG=0
UCSTPIFG=0
USCI continues as Slave Receiver
494 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
The USCI module checks if the bus is available, generates the START condition, and transmits the slave
address. As soon as the slave acknowledges the address the UCTXSTT bit is cleared.
After the acknowledge of the address from the slave the first data byte from the slave is received and
acknowledged and the UCBxRXIFG flag is set. Data is received from the slave ss long as UCTXSTP or
UCTXSTT is not set. If UCBxRXBUF is not read the master holds the bus during reception of the last data bit
and until the UCBxRXBUF is read.
If the slave does not acknowledge the transmitted address the not-acknowledge interrupt flag UCNACKIFG is
set. The master must react with either a STOP condition or a repeated START condition.
Setting the UCTXSTP bit will generate a STOP condition. After setting UCTXSTP, a NACK followed by a STOP
condition is generated after reception of the data from the slave, or immediately if the USCI module is currently
waiting for UCBxRXBUF to be read.
If a master wants to receive a single byte only, the UCTXSTP bit must be set while the byte is being received.
For this case, the UCTXSTT may be polled to determine when it is cleared:
BIS.B #UCTXSTT,&UCBOCTL1 ;Transmit START cond.
POLL_STT BIT.B #UCTXSTT,&UCBOCTL1 ;Poll UCTXSTT bit
JC POLL_STT ;When cleared,
BIS.B #UCTXSTP,&UCB0CTL1 ;transmit STOP cond.
Setting UCTXSTT generates a repeated START condition. In this case, UCTR may be set or cleared to
configure transmitter or receiver, and a different slave address may be written into UCBxI2CSA if desired.
Figure 17-13 shows the I2C master receiver operation.
Note
Consecutive Master Transactions Without Repeated Start
When performing multiple consecutive I2C master transactions without the repeated start feature, the
current transaction must be completed before the next one is initiated. This can be done by ensuring
that the transmit stop condition flag UCTXSTP is cleared before the next I2C transaction is initiated
with setting UCTXSTT = 1. Otherwise, the current transaction might be affected.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 495
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
1) UCTR=1 (Transmitter)
2) UCTXSTT=1
DATA A S SLA/R
Not acknowledge A P
received after slave UCTXSTP=0
address
UCTXSTT=0
UCNACKIFG=1
1) UCTR=1 (Transmitter)
S SLA/W 2) UCTXSTT=1
UCBxTXIFG=1
UCALIFG=1
UCMST=0
(UCSTTIFG=0)
UCALIFG=1
UCMST=0
UCTR=1 (Transmitter)
UCSTTIFG=1
UCBxTXIFG=1
UCSTPIFG=0
USCI continues as Slave Transmitter
496 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
Successful A A A A
S 11110 xx/W SLA (2.) DATA DATA P
transmission to a
slave receiver
Master Receiver
UCTXSTP=1
17.3.4.2.4 Arbitration
If two or more master transmitters simultaneously start a transmission on the bus, an arbitration procedure is
invoked. Figure 17-15 shows the arbitration procedure between two devices. The arbitration procedure uses the
data presented on SDA by the competing transmitters. The first master transmitter that generates a logic high is
overruled by the opposing master generating a logic low. The arbitration procedure gives priority to the device
that transmits the serial data stream with the lowest binary value. The master transmitter that lost arbitration
switches to the slave receiver mode, and sets the arbitration lost flag UCALIFG. If two or more devices send
identical first bytes, arbitration continues on the subsequent bytes.
Bus Line
SCL
Device 1 Lost Arbitration
and Switches Off
n
Data From
Device 1
1
0 0 0
Data From
Device 2
1 1 1
0 0 0
Bus Line
SDA
1 1 1
If the arbitration procedure is in progress when a repeated START condition or STOP condition is transmitted on
SDA, the master transmitters involved in arbitration must send the repeated START condition or STOP condition
at the same position in the format frame. Arbitration is not allowed between:
• A repeated START condition and a data bit
• A STOP condition and a data bit
• A repeated START condition and a STOP condition
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 497
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
The minimum high and low periods of the generated SCL are
UCBRx / 2
tLOW,MIN = tHIGH,MIN =
fBRCLK when UCBRx is even and
(UCBRx – 1) / 2
tLOW,MIN = tHIGH,MIN =
fBRCLK when UCBRx is odd.
The USCI clock source frequency and the prescaler setting UCBRx must to be chosen such that the minimum
low and high period times of the I2C specification are met.
During the arbitration procedure the clocks from the different masters must be synchronized. A device that first
generates a low period on SCL overrules the other devices forcing them to start their own low periods. SCL is
then held low by the device with the longest low period. The other devices must wait for SCL to be released
before starting their high periods. Figure 17-16 shows the clock synchronization. This allows a slow slave to slow
down a fast master.
Wait Start HIGH
State
Period
SCL From
Device 1
SCL From
Device 2
Bus Line
SCL
Figure 17-16. Synchronization of Two I2C Clock Generators During Arbitration
498 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
17.3.6 Using the USCI Module in I2C Mode with Low-Power Modes
The USCI module provides automatic clock activation for SMCLK for use with low-power modes. When SMCLK
is the USCI clock source, and is inactive because the device is in a low-power mode, the USCI module
automatically activates it when needed, regardless of the control-bit settings for the clock source. The clock
remains active until the USCI module returns to its idle condition. After the USCI module returns to the idle
condition, control of the clock source reverts to the settings of its control bits. Automatic clock activation is not
provided for ACLK.
When the USCI module activates an inactive clock source, the clock source becomes active for the whole device
and any peripheral configured to use the clock source may be affected. For example, a timer using SMCLK will
increment while the USCI module forces SMCLK active.
In I2C slave mode no internal clock source is required because the clock is provided by the external master. It
is possible to operate the USCI in I2C slave mode while the device is in LPM4 and all internal clock sources are
disabled. The receive or transmit interrupts can wake up the CPU from any low power mode.
17.3.7 USCI Interrupts in I2C Mode
There are two interrupt vectors for the USCI module in I2C mode. One interrupt vector is associated with the
transmit and receive interrupt flags. The other interrupt vector is associated with the four state change interrupt
flags. 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. DMA transfers are controlled by the UCBxTXIFG and
UCBxRXIFG flags on devices with a DMA controller.
17.3.7.1 I2C Transmit Interrupt Operation
The UCBxTXIFG interrupt flag is set by the transmitter to indicate that UCBxTXBUF is ready to accept another
character. An interrupt request is generated if UCBxTXIE and GIE are also set. UCBxTXIFG is automatically
reset if a character is written to UCBxTXBUF or if a NACK is received. UCBxTXIFG is set when UCSWRST = 1
and the I2C mode is selected. UCBxTXIE is reset after a PUC or when UCSWRST = 1.
17.3.7.2 I2C Receive Interrupt Operation
The UCBxRXIFG interrupt flag is set when a character is received and loaded into UCBxRXBUF. An interrupt
request is generated if UCBxRXIE and GIE are also set. UCBxRXIFG and UCBxRXIE are reset after a PUC
signal or when UCSWRST = 1. UCxRXIFG is automatically reset when UCxRXBUF is read.
17.3.7.3 I2C State Change Interrupt Operation
Table 17-1 describes the I2C state change interrupt flags.
Table 17-1. State Change Interrupt Flags
Interrupt Flag Interrupt Condition
Arbitration-lost. Arbitration can be lost when two or more transmitters start a transmission simultaneously, or when
UCALIFG the USCI operates as master but is addressed as a slave by another master in the system. The UCALIFG flag is set
when arbitration is lost. When UCALIFG is set the UCMST bit is cleared and the I2C controller becomes a slave.
Not-acknowledge interrupt. This flag is set when an acknowledge is expected but is not received. UCNACKIFG is
UCNACKIFG
automatically cleared when a START condition is received.
Start condition detected interrupt. This flag is set when the I2C module detects a START condition together with its
UCSTTIFG own address while in slave mode. UCSTTIFG is used in slave mode only and is automatically cleared when a STOP
condition is received.
Stop condition detected interrupt. This flag is set when the I2C module detects a STOP condition while in slave
UCSTPIFG
mode. UCSTPIFG is used in slave mode only and is automatically cleared when a START condition is received.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 499
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
Example 17-1 shows an extract of the interrupt service routine to handle data receive interrupts from USCI_A0 in
either UART or SPI mode and state change interrupts from USCI_B0 in I2C mode.
Example 17-1. Shared Receive Interrupt Vectors Software Example
USCIA0_RX_USCIB0_I2C_STATE_ISR
BIT.B #UCA0RXIFG, &IFG2 ; USCI_A0 Receive Interrupt?
JNZ USCIA0_RX_ISR
USCIB0_I2C_STATE_ISR
; Decode I2C state changes ...
; Decode I2C state changes ...
...
RETI
USCIA0_RX_ISR
; Read UCA0RXBUF ... - clears UCA0RXIFG
...
RETI
USCIA0_TX_USCIB0_I2C_DATA_ISR
BIT.B #UCA0TXIFG, &IFG2 ; USCI_A0 Transmit Interrupt?
JNZ USCIA0_TX_ISR
USCIB0_I2C_DATA_ISR
BIT.B #UCB0RXIFG, &IFG2
JNZ USCIB0_I2C_RX
USCIB0_I2C_TX
; Write UCB0TXBUF... - clears UCB0TXIFG
...
RETI
USCIB0_I2C_RX
; Read UCB0RXBUF... - clears UCB0RXIFG
...
RETI
USCIA0_TX_ISR
; Write UCA0TXBUF ... - clears UCA0TXIFG
...
RETI
500 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
0D8h UCB1CTL0 USCI_B1 control 0 Read/write 01h with PUC Section 17.4.1
0D9h UCB1CTL1 USCI_B1 control 1 Read/write 01h with PUC Section 17.4.1
0DAh UCB1BR0 USCI_B1 bit rate control 0 Read/write 00h with PUC Section 17.4.3
0DBh UCB1BR1 USCI_B1 bit rate control 1 Read/write 00h with PUC Section 17.4.3
0DCh UCB1I2CIE USCI_B1 I2C interrupt enable Read/write 00h with PUC Section 17.4.10
0DDh UCB1STAT USCI_B1 status Read/write 00h with PUC Section 17.4.5
0DEh UCB1RXBUF USCI_B1 receive buffer Read 00h with PUC Section 17.4.6
0DFh UCB1TXBUF USCI_B1 transmit buffer Read/write 00h with PUC Section 17.4.7
17Ch UCB1I2COA USCI_B1 I2C own address Read/write 00h with PUC Section 17.4.8
17Eh UCB1I2CSA USCI_B1 I2C slave address Read/write 00h with PUC Section 17.4.9
6h UC1IE USCI_A1/B1 interrupt enable Read/write 00h with PUC Section 17.4.13
7h UC1IFG USCI_A1/B1 interrupt flag Read/write 0Ah with PUC Section 17.4.14
Note
Modifying SFR bits
To avoid modifying control bits of other modules, TI recommends setting or clearing the IEx and IFGx
bits using BIS.B or BIC.B instructions, rather than MOV.B or CLR.B instructions.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 501
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
USCI Mode. The UCMODEx bits select the synchronous mode when
UCSYNC = 1.
00b = 3-pin SPI
2-1 UCMODEx R/W 0h
01b = 4-pin SPI (master/slave enabled if STE = 1)
10b = 4-pin SPI (master/slave enabled if STE = 0)
11b = I2C mode
502 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
5 Unused R 0h Unused
Transmitter or receiver
4 UCTR R/W 0h 0b = Receiver
1b = Transmitter
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 503
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
504 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
SCL low
6 UCSCLLOW R 0h 0b = SCL is not held low
1b = SCL is held low
Bus busy
4 UCBBUSY R 0h 0b = Bus inactive
1b = Bus busy
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 505
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
506 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
7 6 5 4 3 2 1 0
I2COAx
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
I2CSAx
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 507
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
508 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Universal Serial Communication Interface, I2C Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 509
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Universal Serial Communication Interface, I2C Mode www.ti.com
These bits may be used by other USCI modules (see the device-
1-0
specific data sheet).
These bits may be used by other USCI modules (see the device-
1-0
specific data sheet).
510 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
Chapter 18
USART Peripheral Interface, UART 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.
USART0 is implemented on the MSP430AFE2xx devices.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 511
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
0 1
RXWAKE 1 SOMI
RXERR Receiver Shift Register
1 0
0
SSEL1 SSEL0 SPB CHAR PEV PENA 1 URXD
UCLKS
UCLKI 00 Baud−Rate Generator 0
STE
ACLK 01
Prescaler/Divider UxBRx
SMCLK 10
SMCLK 11 Modulator UxMCTL
UTXD
1
WUT Transmit Shift Register 1 SIMO
0
TXWAKE 0
Transmit Buffer UxTXBUF
UTXIFGx*
Transmit Control
512 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
Note
Initializing or Reconfiguring the USART Module
The required USART initialization/reconfiguration process is:
1. Set SWRST (BIS.B #SWRST,&UxCTL)
2. Initialize all USART registers with SWRST = 1 (including UxCTL)
3. Enable USART module via the MEx SFRs (URXEx and/or UTXEx)
4. Clear SWRST via software (BIC.B #SWRST,&UxCTL)
5. Enable interrupts (optional) via the IEx SFRs (URXIEx and/or UTXIEx)
Failure to follow this process may result in unpredictable USART behavior.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 513
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
Blocks of
Characters
UTXDx/URXDx
UTXDx/URXDx
ST Address SP ST Data SP ST Data SP
First Character Within Block Character Within Block Character Within Block
Is Address. It Follows Idle
Period of 10 Bits or More Idle Period Less Than 10 Bits
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 receiver is temporarily activated to transfer the character
to UxRXBUF and sets the URXIFGx interrupt flag. Any applicable error flag is also set. The user can then
validate the received address.
If an address is received, user software can validate the address and must reset URXWIE to continue receiving
data. If URXWIE remains set, only address characters are received. The URXWIE bit is not modified by the
USART hardware automatically.
For address transmission in idle-line multiprocessor format, a precise idle period can be generated by the
USART to generate address character identifiers on UTXDx. The wake-up temporary (WUT) flag is an internal
flag double-buffered with the user-accessible TXWAKE bit. When the transmitter is loaded from UxTXBUF, WUT
is also loaded from TXWAKE resetting the TXWAKE bit.
The following procedure sends out an idle frame to indicate an address character follows:
1. Set TXWAKE, then write any character to UxTXBUF. UxTXBUF must be ready for new data (UTXIFGx = 1).
The TXWAKE value is shifted to WUT and the contents of UxTXBUF are shifted to the transmit shift register
when the shift register is ready for new data. This sets WUT, which suppresses the start, data, and parity
bits of a normal transmission, then transmits an idle period of exactly 11 bits. When two stop bits are used
for the idle line, the second stop bit is counted as the first mark bit of the idle period. TXWAKE is reset
automatically.
2. Write desired address character to UxTXBUF. UxTXBUF must be ready for new data (UTXIFGx = 1).
The new character representing the specified address is shifted out following the address-identifying idle
period on UTXDx. Writing the first "don't care" character to UxTXBUF is necessary in order to shift the
TXWAKE bit to WUT and generate an idle-line condition. This data is discarded and does not appear on
UTXDx.
18.2.3.2 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 18-4. The first character in a block of characters carries a set
address bit which indicates that the character is an address. The USART RXWAKE bit is set when a received
character is a valid address character and is transferred to UxRXBUF.
514 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
The URXWIE bit is used to control data reception in the address-bit multiprocessor format. If URXWIE is set,
data characters (address bit = 0) are assembled by the receiver but are not transferred to UxRXBUF and no
interrupts are generated. When a character containing a set address bit is received, the receiver is temporarily
activated to transfer the character to UxRXBUF and set URXIFGx. All applicable error status flags are also set.
If an address is received, user software must reset URXWIE to continue receiving data. If URXWIE remains set,
only address characters (address bit = 1) are received. The URXWIE bit is not modified by the USART hardware
automatically.
Blocks of
Characters
UTXDx/URXDx
UTXDx/URXDx
ST Address 1 SP ST Data 0 SP ST Data 0 SP
For address transmission in address-bit multiprocessor mode, the address bit of a character can be controlled
by writing to the TXWAKE bit. The value of the TXWAKE bit is loaded into the address bit of the character
transferred from UxTXBUF to the transmit shift register, automatically clearing the TXWAKE bit. TXWAKE must
not be cleared by software. It is cleared by USART hardware after it is transferred to WUT or by setting SWRST.
18.2.3.3 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) is ignored. See the device-specific data sheet for parameters.
When a low period on URXDx exceeds tτ a majority vote is taken for the start bit. If the majority vote fails to
detect a valid start bit the USART halts character reception and waits for the next low period on URXDx. The
majority vote is also used for each bit in a character to prevent bit errors.
The USART module automatically detects framing errors, parity errors, overrun errors, and break conditions
when receiving characters. The bits FE, PE, OE, and BRK are set when their respective condition is detected.
When any of these error flags are set, RXERR is also set. The error conditions are described in Table 18-1.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 515
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
When URXEIE = 0 and a framing error, parity error, or break condition is detected, no character is received into
UxRXBUF. When URXEIE = 1, characters are received into UxRXBUF and any applicable error bit is set.
When any of the FE, PE, OE, BRK, or RXERR bits are set, the bit remains set until user software resets it or
UxRXBUF is read.
18.2.4 USART Receive Enable
The receive enable bit, URXEx, enables or disables data reception on URXDx as shown in Figure 18-5.
Disabling the USART receiver stops the receive operation following completion of any character currently being
received or immediately if no receive operation is active. The receive-data buffer, UxRXBUF, contains the
character moved from the RX shift register after the character is received.
No Valid Start Bit
URXEx = 0 Not Completed
URXEx = 1
URXEx = 1
Idle State Valid Start Bit Receiver
Receive Handle Interrupt
(Receiver Collects
Disable Conditions
Enabled) Character
URXEx = 0
Character
URXEx = 1 Received
URXEx = 0
Note
Re-Enabling the Receiver (Setting URXEx): UART Mode
When the receiver is disabled (URXEx = 0), re-enabling the receiver (URXEx = 1) is asynchronous
to any data stream that may be present on URXDx at the time. Synchronization can be performed by
testing for an idle line condition before receiving a valid character (see URXWIE).
516 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
UTXEx = 1
UTXEx = 1 Data Written to
Idle State Transmit Buffer
Transmit Transmission Handle Interrupt
(Transmitter
Disable Active Conditions
Enabled)
UTXEx = 0
Character
UTXEx = 1 Transmitted
When the transmitter is enabled (UTXEx = 1), data should not be written to UxTXBUF unless it is ready for new
data indicated by UTXIFGx = 1. Violation can result in an erroneous transmission if data in UxTXBUF is modified
as it is being moved into the TX shift register.
It is recommended that the transmitter be disabled (UTXEx = 0) only after any active transmission is complete.
This is indicated by a set transmitter empty bit (TXEPT = 1). Any data written to UxTXBUF while the transmitter
is disabled are held in the buffer but are not moved to the transmit shift register or transmitted. Once UTXEx
is set, the data in the transmit buffer is immediately loaded into the transmit shift register and character
transmission resumes.
18.2.6 USART 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 18-7. This
combination supports fractional divisors for baud rate generation. The maximum USART baud rate is one-third
the UART source clock frequency BRCLK.
UxBR1 UxBR0
UCLKI 00 8 8
ACLK 01 BRCLK
16−Bit Counter R
SMCLK 10
Q15 ............ Q0
SMCLK 11
+0 or 1 Compare (0 or 1) Toggle
BITCLK
FF
R
mX 8
m7 m0
UxMCTL Bit Start
Timing for each bit is shown in Figure 18-8. For each bit received, a majority vote is taken to determine the bit
value. These samples occur at the N/2-1, N/2, and N/2+1 BRCLK periods, where N is the number of BRCLKs
per BITCLK.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 517
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
BRCLK
BITCLK
Bit Period
m: corresponding modulation bit
R: Remainder from N/2 division
The division factor N is often a non-integer value of which the integer portion can be realized by the prescaler/
divider. The second stage of the baud rate generator, the modulator, is used to meet the fractional part as closely
as possible. The factor N is then defined as:
n–1
1
N = UxBR +
n åm
i=0
i
Where,
N = Target division factor
UxBR = 16-bit representation of registers UxBR0 and UxBR1
i = Bit position in the character
n = Total number of bits in the character
mi = Data of each corresponding modulation bit (1 or 0)
BRCLK BRCLK
Baud rate = +
N n–1
1
UxBR +
n åm
i=0
i
The BITCLK can be adjusted from bit to bit with the modulator to meet timing requirements when a non-integer
divisor is needed. Timing of each bit is expanded by one BRCLK clock cycle if the modulator bit mi is set. Each
time a bit is received or transmitted, the next bit in the modulation control register determines the timing for that
bit. A set modulation bit increases the division factor by one while a cleared modulation bit maintains the division
factor given by UxBR.
The timing for the start bit is determined by UxBR plus m0, the next bit is determined by UxBR plus m1, and so
on. The modulation sequence begins with the LSB. When the character is greater than 8 bits, the modulation
sequence restarts with m0 and continues until all bits are processed.
518 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
Where,
baud rate = Desired baud rate
BRCLK = Input frequency - UCLKI, ACLK, or SMCLK
j = Bit position - 0 for the start bit, 1 for data bit D0, and so on
UxBR = Division factor in registers UxBR1 and UxBR0
For example, the transmit 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 = 6Bh: m7 = 0, m6 = 1, m5 = 1, m4 = 0, m3 = 1, m2 = 0, m1 = 1, and m0 = 1. The LSB of UxMCTL is
used first.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 519
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
The results show the maximum per-bit error to be 5.08% of a BITCLK period.
520 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
i 0 1 2
tideal t0 t1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 5 6 7
BRCLK
URXDx ST D0 D1
URXDS ST D0 D1
tactual t0 t1 t2
Synchronization Error ± 0.5x BRCLK
Sample
URXDS
Int(UxBR/2)+m0 = UxBR +m1 = 13+1 = 14 UxBR +m2 = 13+0 = 13
Int (13/2)+1 = 6+1 = 7
Majority Vote Taken Majority Vote Taken Majority Vote Taken
The ideal start bit timing tideal(0) is half the baud-rate timing tbaudrate, because the bit is tested in the middle of
its period. The ideal baud-rate timing tideal(i) for the remaining character bits is the baud rate timing tbaudrate. The
individual bit errors can be calculated by:
ì æ é j ùö ü
é æ UxBR ö ù
ï baud rate
Error [%] = í
ï BRCLK
ç
× ç2 ×
ç
ê
ë
m0 + int ç
è 2 øû
÷ú + êi × UxBR +
ê å m ú ÷ – 1 – jï × 100%
iú÷
÷
ý
ï
î è ëê i=1 ûú ø þ
Where,
baud rate = the required baud rate
BRCLK = the input frequency; selected for UCLK, ACLK, or SMCLK
j = 0 for the start bit, 1 for data bit D0, and so on
UxBR = the division factor in registers UxBR1 and UxBR0
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 first.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 521
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
The results show the maximum per-bit error to be 5.08% of a BITCLK period.
18.2.6.5 Typical Baud Rates and Errors
Standard baud rate frequency data for UxBRx and UxMCTL are listed in Table 18-2 for a 32 768-Hz watch
crystal (ACLK) and a typical 1 048 576-Hz SMCLK.
The receive error is the accumulated time versus the ideal scanning time in the middle of each bit. The transmit
error is the accumulated timing error versus the ideal time of the bit period.
Table 18-2. Commonly Used Baud Rates, Baud Rate Data, and Errors
Divide by A: BRCLK = 32 768 Hz B: BRCLK = 1 048 576 Hz
Baud Rate Max TX Max RX Synch RX Max TX Max RX
A: B: UxBR1 UxBR0 UxMCTL UxBR1 UxBR0 UxMCTL
Error % Error % Error % Error % Error %
1200 27.31 873.81 0 1B 03 -4/3 -4/3 ±2 03 69 FF 0/0.3 ±2
2400 13.65 436.91 0 0D 6B -6/3 -6/3 ±4 01 B4 FF 0/0.3 ±2
4800 6.83 218.45 0 06 6F -9/11 -9/11 ±7 0 DA 55 0/0.4 ±2
9600 3.41 109.23 0 03 4A -21/12 -21/12 ±15 0 6D 03 -0.4/1 ±2
19 200 54.61 0 36 6B -0.2/2 ±2
38 400 27.31 0 1B 03 -4/3 ±2
76 800 13.65 0 0D 6B -6/3 ±4
115 200 9.1 0 09 08 -5/7 ±7
522 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
Clear
PUC or SWRST
URXWIE Clear
RXWAKE SWRST
Character Received PUC
Non-Address Character Rejection UxRXBUF Read
or
Break Detected URXSE
IRQA
URXEIE is used to enable or disable erroneous characters from setting URXIFGx. When using multiprocessor
addressing modes, URXWIE is used to auto-detect valid address characters and reject unwanted data
characters.
Two types of characters do not set URXIFGx:
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 523
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
Note
Break Detect With Halted UART Clock
When using the receive start-edge detect feature, a break condition cannot be detected when the
BRCLK source is off.
524 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
URXDx
URXS
tτ
When a glitch is longer than tτ or a valid start bit occurs on URXDx, the USART receive operation is started and
a majority vote is taken as shown in Figure 18-13. If the majority vote fails to detect a start bit, the USART halts
character reception.
If character reception is halted, an active BRCLK is not necessary. A time-out period longer than the character
receive duration can be used by software to indicate that a character was not received in the expected time, and
the software can disable BRCLK.
Majority Vote Taken
URXDx
URXS
tτ
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 525
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
78h U1CTL USART1 control Read/write 01h with PUC Section 18.3.1
79h U1TCTL USART1 transmit control Read/write 01h with PUC Section 18.3.2
7Ah U1RCTL USART1 receive control Read/write 00h with PUC Section 18.3.3
7Bh U1MCTL USART1 modulation control Read/write Unchanged Section 18.3.4
7Ch U1BR0 USART1 baud-rate control 0 Read/write Unchanged Section 18.3.5
7Dh U1BR1 USART1 baud-rate control 1 Read/write Unchanged Section 18.3.5
7Eh U1RXBUF USART1 receive buffer Read Unchanged Section 18.3.7
7Fh U1TXBUF USART1 transmit buffer Read/write Unchanged Section 18.3.8
1h IE2 SFR interrupt enable 2 Read/write 00h with PUC Section 18.3.10
3h IFG2 SFR interrupt flag 2 Read/write 20h with PUC Section 18.3.12
Note
Modifying SFR bits
To avoid modifying control bits of other modules, TI recommends setting or clearing the IEx and IFGx
bits using BIS.B or BIC.B instructions, rather than MOV.B or CLR.B instructions.
526 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
Stop bit select. Number of stop bits transmitted. The receiver always
checks for one stop bit.
5 SPB R/W 0h
0b = One stop bit
1b = Two stop bits
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 527
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
UART receive start-edge. The bit enables the UART receive start-
edge feature.
3 URXSE R/W 0h
0b = Disabled
1b = Enabled
Transmitter wake
2 TXWAKE R/W 0h 0b = Next frame transmitted is data
1b = Next frame transmitted is an address
1 Unused R/W 0h Unused
Transmitter empty flag.
0b = UART is transmitting data and/or data is waiting in UxTXBUF
0 TXEPT R/W 1h
1b = Transmitter shift register and UxTXBUF are empty or SWRST =
1
528 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
Overrun error flag. This bit is set when a character is transferred into
UxRXBUF before the previous character was read.
5 OE R/W 0h
0b = No error
1b = Overrun error occurred
Receive error flag. This bit indicates a character was received with
errors. When RXERR = 1, one or more error flags (FE, PE, OE,
0 RXERR R/W 0h BRK) is also set. RXERR is cleared when UxRXBUF is read.
0b = No receive errors detected
1b = Receive error detected
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 529
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
530 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 531
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
532 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, UART Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 533
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, UART Mode www.ti.com
534 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, SPI Mode
Chapter 19
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 peripheral interface
or SPI mode. USART0 is implemented on the MSP430AFE2xx devices.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 535
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, SPI Mode www.ti.com
0 1
RXWAKE 1 SOMI
RXERR Receiver Shift Register
1 0
0
SSEL1 SSEL0 SPB CHAR PEV PENA 1 URXD
UCLKS
UCLKI 00 Baud−Rate Generator 0
STE
ACLK 01
Prescaler/Divider UxBRx
SMCLK 10
SMCLK 11 Modulator UxMCTL
UTXD
1
WUT Transmit Shift Register 1 SIMO
0
0
TXWAKE Transmit Buffer UxTXBUF
UTXIFGx*
Transmit Control
536 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, SPI Mode
Note
Initializing or Reconfiguring the USART Module
The required USART initialization/reconfiguration process is:
1. Set SWRST (BIS.B #SWRST,&UxCTL)
2. Initialize all USART registers with SWRST=1 (including UxCTL)
3. Enable USART module via the MEx SFRs (USPIEx)
4. Clear SWRST via software (BIC.B #SWRST,&UxCTL)
5. Enable interrupts (optional) via the IEx SFRs (URXIEx and/or UTXIEx)
Failure to follow this process may result in unpredictable USART behavior.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 537
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, SPI Mode www.ti.com
Px.x STE
SS
STE
Port.x
SOMI SOMI
Receive Shift Register Transmit Shift Register Data Shift Register (DSR)
UCLK SCLK
MSP430 USART COMMON SPI
A set transmit interrupt flag, UTXIFGx, indicates that data has moved from UxTXBUF to the TX shift register and
UxTXBUF is ready for new data. It does not indicate RX/TX completion. In master mode, the completion of an
active transmission is indicated by a set transmitter empty bit TXEPT = 1.
To receive data into the USART in master mode, data must be written to UxTXBUF because receive and
transmit operations operate concurrently.
19.2.2.1 Four-Pin SPI Master Mode
In 4-pin master mode, STE is used to prevent conflicts with another master. The master operates normally when
STE is high. When STE is low:
• SIMO and UCLK are set to inputs and no longer drive the bus
• The error bit FE is set indicating a communication integrity violation to be handled by the user
A low STE signal does not reset the USART module. The STE input signal is not used in 3-pin master mode.
19.2.3 Slave Mode
Figure 19-3 shows the USART as a slave in both 3-pin and 4-pin configurations. UCLK is used as the input for
the SPI clock and must be supplied by the external master. The data transfer rate is determined by this clock
and not by the internal baud rate generator. Data written to UxTXBUF and moved to the TX shift register before
the start of UCLK is transmitted on SOMI. Data on SIMO is shifted into the receive shift register on the opposite
edge of UCLK and moved to UxRXBUF when the set number of bits are received. When data is moved from
the RX shift register to UxRXBUF, the URXIFGx interrupt flag is set, indicating that data has been received. The
overrun error bit, OE, is set when the previously received data is not read from UxRXBUF before new data is
moved to UxRXBUF.
538 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, SPI Mode
Px.x STE
SS
STE
Port.x
SOMI SOMI
Data Shift Register DSR Transmit Shift Register Receive Shift Register
USPIEx = 1,
USPIEx = 1 Data Written to
Idle State Transmit Buffer
Transmit Transmission Handle Interrupt
(Transmitter Conditions
Disable Active
Enabled)
USPIEx = 0
Character
SWRST USPIEx = 1 Transmitted
PUC
USPIEx = 0 And Last Buffer USPIEx = 0
Entry Is Transmitted
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 539
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, SPI Mode www.ti.com
USPIEx = 1
Idle State USPIEx = 1
Transmit Transmission Handle Interrupt
(Transmitter
Disable Active Conditions
Enabled) External Clock
USPIEx = 0 Present
Character
SWRST USPIEx = 1 Transmitted
PUC
USPIEx = 0
USPIEx = 1
Idle State USPIEx = 1 Receiver
Receive Handle Interrupt
(Receiver Collects
Disable Conditions
Enabled) Data Written Character
USPIEx = 0 to UxTXBUF
Character
SWRST Received
PUC USPIEx = 1
USPIEx = 0
USPIEx = 1
Idle State USPIEx = 1 Receiver
Receive Handle Interrupt
(Receive Collects
Disable Conditions
Enabled) External Clock Character
USPIEx = 0 Present
Character
SWRST USPIEx = 1 Received
PUC
USPIEx = 0
540 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, SPI Mode
UxBR1 UxBR0
UCLKI 00 8 8
ACLK 01 BRCLK
16−Bit Counter R
SMCLK 10
Q15 ............ Q0
SMCLK 11
Compare (0 or 1) Toggle
BITCLK
FF
R
mX m7 8 m0
UxMCTL Bit Start
The 16-bit value of UxBR0+UxBR1 is the division factor of the USART clock source, BRCLK. The maximum
baud rate that can be generated in master mode is BRCLK/2. The maximum baud rate that can be generated
in slave mode is BRCLK The modulator in the USART baud rate generator is not used for SPI mode and is
recommended to be set to 000h. The UCLK frequency is given by:
BRCLK
Baud rate = with UxBR= [UxBR1, UxBR0]
UxBR
Cycle# 1 2 3 4 5 6 7 8
CKPH CKPL
0 0 UCLK
0 1 UCLK
1 0 UCLK
1 1 UCLK
STE
SIMO/
0 X MSB LSB
SOMI
SIMO/
1 X MSB LSB
SOMI
Move to UxTXBUF
RX Sample Points
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 541
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, SPI Mode www.ti.com
Clear
PUC or SWRST
Note
Writing to UxTXBUF in SPI Mode
Data written to UxTXBUF when UTXIFGx = 0 and USPIEx = 1 may result in erroneous data
transmission.
542 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, SPI Mode
URXWIE
Clear
RXWAKE
SWRST
Character Received PUC
UxRXBUF Read
URXSE
IRQA
SWRST = 1
Receive Interrupt
USPIEx = 1 USPIEx = 1 and Service Started,
Character URXIFGx = 1
Completed URXIEx = 1 and GIE = 0
GIE = 1 and URXIFGx = 0
Priority Priority Valid
Too GIE = 0
Low
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 543
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, SPI Mode www.ti.com
78h U1CTL USART1 control Read/write 01h with PUC Section 19.3.2
79h U1TCTL USART1 transmit control Read/write 01h with PUC Section 19.3.2
7Ah U1RCTL USART1 receive control Read/write 00h with PUC Section 19.3.3
7Bh U1MCTL USART1 modulation control Read/write Unchanged Section 19.3.6
7Ch U1BR0 USART1 baud-rate control 0 Read/write Unchanged Section 19.3.4
7Dh U1BR1 USART1 baud-rate control 1 Read/write Unchanged Section 19.3.5
7Eh U1RXBUF USART1 receive buffer Read Unchanged Section 19.3.7
7Fh U1TXBUF USART1 transmit buffer Read/write Unchanged Section 19.3.8
5h ME2 SFR module enable 2 Read/write 00h with PUC Section 19.3.10
1h IE2 SFR interrupt enable 2 Read/write 00h with PUC Section 19.3.12
3h IFG2 SFR interrupt flag 2 Read/write 20h with PUC Section 19.3.14
Note
Modifying the SFR bits
To avoid modifying control bits for other modules, TI recommends setting or clearing the IEx and IFGx
bits using BIS.B or BIC.B instructions, rather than MOV.B or CLR.B instructions.
544 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, SPI Mode
I2C mode enable. This bit selects I2C or SPI operation when SYNC =
1.
5 I2C R/W 0h
0b = SPI mode
1b = I2C mode
Character length
4 CHAR R/W 0h 0b = 7-bit data
1b = 8-bit data
Master mode
1 MM R/W 0h 0b = USART is slave
1b = USART is master
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 545
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, SPI Mode www.ti.com
Transmitter empty flag. The TXEPT flag is not used in slave mode.
0 TXEPT R/W 1h 0b = Transmission active and/or data waiting in UxTXBUF
1b = UxTXBUF and TX shift register are empty
546 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, SPI Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 547
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, SPI Mode www.ti.com
548 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, SPI Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 549
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, SPI Mode www.ti.com
550 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com USART Peripheral Interface, SPI Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 551
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
USART Peripheral Interface, SPI Mode www.ti.com
552 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com OA
Chapter 20
OA
The OA is a general purpose operational amplifier. This chapter describes the OA. Two OA modules are
implemented in the MSP430x22x4 devices.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 553
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
OA www.ti.com
20.1 OA Introduction
The OA operational amplifiers support front-end analog signal conditioning prior to analog-to-digital conversion.
Features of the OA include:
• Single supply, low-current operation
• Rail-to-rail output
• Programmable settling time vs. power consumption
• Software selectable configurations
• Software selectable feedback resistor ladder for PGA implementations
Note
Multiple OA Modules
Some devices may integrate more than one OA module. If more than one OA is present on a device,
the multiple OA modules operate identically.
Throughout this chapter, nomenclature appears such as OAxCTL0 to describe register names. When
this occurs, the x is used to indicate which OA module is being discussed. In cases where operation is
identical, the register is simply referred to as OAxCTL0.
554 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com OA
OAPx
OAPx = 3
OAxI0 00 OAFCx = 6
01 OANx = 3
OA0I1
0 OAPMx
OAxIA 10 OA1TAP (OA0)
OAxIB 11 OA2TAP (OA1) 1
OA0TAP (OA2) +
OA2OUT (OA0) 0
OAx
OA0OUT (OA1) 1
OA1OUT (OA2) −
OAFCx = 6
OAFCx = 5 OANx OANEXT
OAxI0 00 1
A1 (OA0)
OAxI1 01
000 A3 (OA1)
OAxIA 10 A5 (OA2)
OAxRBOTTOM 001
OAxIB 11 OAFCx
else A1/OA0O
A3/OA1O
3
A5/OA2O
OARRIP
OAxI0 00 111
OAxI1 01
OAxIA 10
OAxFB
OA2OUT (OA0) 11
OA0OUT (OA1)
OA1OUT (OA2)
20.2 OA Operation
The OA module is configured with user software. The setup and operation of the OA is discussed in the following
sections.
20.2.1 OA Amplifier
The OA is a configurable, low-current, rail-to-rail output operational amplifier. It can be configured as an inverting
amplifier, or a non-inverting amplifier, or can be combined with other OA modules to form differential amplifiers.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 555
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
OA www.ti.com
The output slew rate of the OA can be configured for optimized settling time vs power consumption with the
OAPMx bits. When OAPMx = 00 the OA is off and the output is high-impedance. When OAPMx > 0, the OA is
on. See the device-specific data sheet for parameters.
20.2.2 OA Input
The OA has configurable input selection. The signals for the + and - inputs are individually selected with the
OANx and OAPx bits and can be selected as external signals or internal signals. OAxI0 and OAxI1 are external
signals provided for each OA module. OA0I1 provides a non-inverting input that is tied together internally for
all OA modules. OAxIA and OAxIB provide device-dependent inputs. See the device data sheet for signal
connections.
When the external inverting input is not needed for a mode, setting the OANEXT bit makes the internal inverting
input externally available.
20.2.3 OA Output and Feedback Routing
The OA has configurable output selection controlled by the OAADCx bits and the OAFCx bits. The OA output
signals can be routed to ADC inputs A12 (OA0), A13 (OA1), or A14 (OA2) internally, or can be routed to these
ADC inputs and their external pins. The OA output signals can also be routed to ADC inputs A1 (OA0), A3
(OA1), or A5 (OA2) and the corresponding external pin. The OA output is also connected to an internal R-ladder
with the OAFCx bits. The R-ladder tap is selected with the OAFBRx bits to provide programmable gain amplifier
functionality.
Table 20-1 shows the OA output and feedback routing configurations. When OAFCx = 0 the OA is in general-
purpose mode and feedback is achieved externally to the device. When OAFCx > 0 and when OAADCx = 00 or
11, the output of the OA is kept internal to the device. When OAFCx > 0 and OAADCx = 01 or 10, the OA output
is routed both internally and externally.
Table 20-1. OA Output Configurations
OAFCx OAADCx OA Output and Feedback Routing
=0 x0 OAxOUT connected to external pins and ADC input A1, A3, or A5.
=0 x1 OAxOUT connected to external pins and ADC input A12, A13, or A14.
>0 00 OAxOUT used for internal routing only.
>0 01 OAxOUT connected to external pins and ADC input A12, A13, or A14.
>0 10 OAxOUT connected to external pins and ADC input A1, A3, or A5.
OAxOUT connected internally to ADC input A12, A13 , or A14. External A12, A13, or A14 pin
>0 11
connections are disconnected from the ADC.
20.2.4 OA Configurations
The OA can be configured for different amplifier functions with the OAFCx bits as listed in Table 20-2.
Table 20-2. OA Mode Select
OAFCx OA Mode
000 General-purpose opamp
001 Unity gain buffer for three-opamp differential amplifier
010 Unity gain buffer
011 Comparator
100 Non-inverting PGA amplifier
101 Cascaded non-inverting PGA amplifier
110 Inverting PGA amplifier
111 Differential amplifier
556 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com OA
Note
Using OAx Negative Input Simultaneously as ADC Input
When the pin connected to the negative input multiplexer is also used as an input to the ADC,
conversion errors up to 5 mV may be observed due to internal wiring voltage drops.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 557
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
OA www.ti.com
V2 +
OA1
−
(V2 − V1) × R2
V1 + Vdiff =
R1
OA0
− R1 R2
558 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com OA
OAPx
OAxI0 00
OA0I1 01
0 OAPMx
OAxIA 10
OAxIB 11 1
+
0
OA1
1
−
OAPx
OAxI0 00
OA0I1 01
OAPMx 000
OAxIA 10 0
001
OAxIB 11 1
+ else
0
OA0
1
−
000
001 OAFBRx
000 000
010 3
001 001
011 OAxRTOP
010 OAxRTOP else 000
100 4R
011 001
000 101
100 4R
110 010
101 001
111 2R 2
110 011
010
2R OAADCx
111 100
011 3
R
101
100
000 R
110
101 001 R
010 111
110
R
011
111
100
00
101
01
110
10
111
11
OAxFB
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 559
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
OA www.ti.com
Figure 20-4 shows an example of a three-opamp differential amplifier using OA0, OA1 and OA2 (Three opamps
are not available on all devices. See device-specific data sheet for implementation.). The control register settings
are shown in Table 20-5. The gain for the amplifier is selected by the OAFBRx bits of OA0 and OA2. The
OAFBRx settings for both OA0 and OA2 must be equal. The gain settings are shown in Table 20-6. The OAx
interconnections are shown in Figure 20-5.
Table 20-5. Three-Opamp Differential Amplifier
Control Register Settings
Settings
Register
(binary)
OA0CTL0 xx xx xx 0 0
OA0CTL1 xxx 001 0 x
OA1CTL0 xx xx xx 0 0
OA1CTL1 000 111 0 x
OA2CTL0 11 11 xx x x
OA2CTL1 xxx 110 0 x
V2 + R1 R2
OA0
−
+
OA2
− (V2 − V1) × R2
Vdiff =
V1 + R1
OA1
− R1 R2
560 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com OA
OAPx
OAxI0
00
OA0I1 OAPMx
01
OAxIA 0
10 +
11 1
OAxIB 000 OA0
0 OAFBRx
001 − OAPMx
1 3
010 000
0
011 001 OA0TAP (OA2) +
000 1
100 4R else OA2
001
101 −
4R 000
OAFBRx 000
110 010
001
2R 3 001
111
011 010
2R OAxRTOP else
011 000
100
4R
R 100
001
101
101 4R
000 R
010
110 110
001 2R
R
111 011
010 111
2R
R
011 100
R
100 101
000
101 R
001 110
110 R
010
111 111
011 R
OAPx
100
00
OAxI0 101
00 01
OA0I1 110 2
01 10
OAxIA 111
10 11 OAADCx
OAxIB 11 OAxFB
000
0
001
1 0
010 OAxR
TOP 1
011
000 OAPMx
100
001 +
101
000 OA1
110 010
001 −
111
011 else
100
101
110
111
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 561
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
OA www.ti.com
20.3 OA Registers
Table 20-7 lists the memory-mapped registers for the OA.
Table 20-7. OA Registers
Address Acronym Register Name Type Reset Section
C0h OA0CTL0 OA0 control 0 Read/write 00h with POR Section 20.3.1
C1h OA0CTL1 OA0 control 1 Read/write 00h with POR Section 20.3.2
C2h OA1CTL0 OA1 control 0 Read/write 00h with POR Section 20.3.1
C3h OA1CTL1 OA1 control 1 Read/write 00h with POR Section 20.3.2
C4h OA2CTL0 OA2 control 0 Read/write 00h with POR Section 20.3.1
C5h OA2CTL1 OA2 control 1 Read/write 00h with POR Section 20.3.2
562 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com OA
Noninverting input select. These bits select the input signal for the
OA noninverting input.
00b = OAxI0
01b = OA0I1
5-4 OAPx R/W 0h
10b = OAxIA (see the device-specific data sheet for connected
signal)
11b = OAxIB (see the device-specific data sheet for connected
signal)
Slew rate select. These bits select the slew rate vs. current
consumption for the OA.
00b = Off, output high Z
3-2 OAPMx R/W 0h
01b = Slow
10b = Medium
11b = Fast
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 563
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
OA www.ti.com
00b = OAxOUT connected to external pins and ADC input A1, A3, or
A5
01b = OAxOUT connected to external pins and ADC input A12, A13,
or A14
10b = OAxOUT connected to external pins and ADC input A1, A3, or
A5
11b = OAxOUT connected to external pins and ADC input A12, A13,
1-0 OAADCx R/W 0h or A14
01b = OAxOUT connected to external pins and ADC input A12, A13,
or A14
10b = OAxOUT connected to external pins and ADC input A1, A3, or
A5
564 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com OA
OAx inverting input externally available. This bit, when set, connects
the inverting OAx input to the external pin when the integrated
1 OANEXT R/W 0h resistor network is used.
0b = OAx inverting input not externally available
1b = OAx inverting input externally available
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 565
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
OA www.ti.com
566 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Comparator_A+
Chapter 21
Comparator_A+
Comparator_A+ is an analog voltage comparator. This chapter describes the operation of the Comparator_A+ of
the 2xx family.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 567
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Comparator_A+ www.ti.com
00
VCC 0V
CA0 01
CA1 10
CAEX 1 0 CAON
CA2 11
0 CAF
1
CCI1B
CASHORT ++
0 0
−− 1 1 CAOUT
000 0
CA1 001 1 Set_CAIFG
CA2 010 Tau ~ 2.0ns
CA3 011
CA4 100
0V
CA5 101
CA6 110
CA7 111 1 0
CAREFx
P2CA3
P2CA2
P2CA1 CARSEL
0.5xVCC
00
V CAREF
0 01
1 10 0.25xVCC
11
D
G S
Note
MSP430G2210: Channels 2, 5, 6, and 7 are available. Other channels should not be enabled.
568 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Comparator_A+
Note
Comparator Input Connection
When the comparator is on, the input terminals should be connected to a signal, power, or ground.
Otherwise, floating levels may cause unexpected interrupts and increased current consumption.
Note
MSP430G2210: Comparator channels 0, 1, 3, and 4 are implemented but not available at the device
pins. To avoid floating inputs, these comparator inputs should not be enabled.
The CAEX bit controls the input multiplexer, exchanging which input signals are connected to the comparator’s
+ and – terminals. Additionally, when the comparator terminals are exchanged, the output signal from the
comparator is inverted. This allows the user to determine or compensate for the comparator input offset voltage.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 569
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Comparator_A+ www.ti.com
Sampling Capacitor, Cs
CASHORT
Analog Inputs
The required sampling time is proportional to the size of the sampling capacitor (CS), the resistance of the input
switches in series with the short switch (Ri), and the resistance of the external source (RS). The total internal
resistance (RI) is typically in the range of 2 to 10 kΩ. The sampling capacitor CS should be greater than 100 pF.
The time constant, Tau, to charge the sampling capacitor CS can be calculated with the following equation:
Tau = (RI + RS) x CS
Depending on the required accuracy, 3 to 10 Tau should be used as a sampling time. With 3 Tau, the sampling
capacitor is charged to approximately 95% of the input signal's voltage level. With 5 Tau, the sampling capacitor
is charge to more than 99%. With 10 Tau, the sampled voltage is sufficient for 12-bit accuracy.
21.2.4 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 effects and cross coupling on and between signal lines, power supply lines, and other parts of
the system are responsible for this behavior as shown in Figure 21-3. The comparator output oscillation reduces
accuracy and resolution of the comparison result. Selecting the output filter can reduce errors associated with
comparator oscillation.
570 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Comparator_A+
+ Terminal
Comparator Output
Unfiltered at CAOUT
Comparator Output
Filtered at CAOUT
VI VO ICC
ICC
VI
VCC
0 VCC
CAPD.x = 1 VSS
Note
MSP430G2210:The channels 0, 1, 3, an 4 are implemented by not available at pins. To avoid floating
inputs these inputs should not be used.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 571
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Comparator_A+ www.ti.com
CAIES
IRQ, Interrupt Service Requested
D Q
0
SET_CAIFG
Reset
1
IRACC, Interrupt RequestAccepted
POR
Note
Changing the value of the CAIES bit might set the comparator interrupt flag CAIFG. This can happen
even when the comparator is disabled (CAON = 0). TI recommends clearing CAIFG after configuring
the comparator for proper interrupt behavior during operation.
Rref
Px.x
Rmeas
Px.y
CA0 CCI1B
++ Capture
Input
−− Of Timer_A
0.25xVCC
The MSP430 resources used to calculate the temperature sensed by Rmeas are:
• Two digital I/O pins to charge and discharge the capacitor.
• I/O set to output high (VCC) to charge capacitor, reset to discharge.
• I/O switched to high-impedance input with CAPDx set when not in use.
• One output charges and discharges the capacitor through Rref.
• One output discharges capacitor through Rmeas.
• The + terminal is connected to the positive terminal of the capacitor.
• The – terminal is connected to a reference level, for example 0.25 × VCC.
• The output filter should be used to minimize switching noise.
• CAOUT used to gate Timer_A CCI1B, capturing capacitor discharge time.
572 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Comparator_A+
More than one resistive element can be measured. Additional elements are connected to CA0 with available I/O
pins and switched to high impedance when not being measured.
The thermistor measurement is based on a ratiometric conversion principle. The ratio of two capacitor discharge
times is calculated as shown in Figure 21-7.
VC
VCC
Rmeas
0.25 × VCC
Rref
tref tmeas
The VCC voltage and the capacitor value should remain constant during the conversion, but are not critical since
they cancel in the ratio:
V
Nmeas –Rmeas × C × ln ref
VCC
=
Nref Vref
–Rref × C × ln
VCC
Nmeas R
= meas
Nref Rref
N
Rmeas = Rref × meas
Nref
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 573
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Comparator_A+ www.ti.com
574 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Comparator_A+
When CAEX = 1:
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 575
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Comparator_A+ www.ti.com
Input select. This bit together with P2CA0 selects the positive
6 P2CA4 R/W 0h terminal input when CAEX = 0 and the negative terminal input when
CAEX = 1.
5 P2CA3 R/W 0h Input select. These bits select the negative terminal input when
4 P2CA2 R/W 0h CAEX = 0 and the positive terminal input when CAEX = 1.
MSP430G2210: Only channels 2, 5, 6, and 7 are available. Other
channels should not be selected.
000b = No connection
001b = CA1
010b = CA2
3 P2CA1 R/W 0h
011b = CA3
100b = CA4
101b = CA5
110b = CA6
111b = CA7
Input select. This bit, together with P2CA4, selects the positive
terminal input when CAEX = 0 and the negative terminal input when
CAEX = 1.
2 P2CA0 R/W 0h 00b = No connection
01b = CA0
10b = CA1
11b = CA2
576 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Comparator_A+
(1) MSP430G2210: Channels 2, 5, 6, and 7 are available. Other channels should not be disabled.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 577
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Comparator_A+ www.ti.com
578 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
Chapter 22
ADC10
The ADC10 module is a high-performance 10-bit analog-to-digital converter. This chapter describes the
operation of the ADC10 module of the 2xx family in general. There are device with less than eight external
input channels.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 579
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
580 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
Ve REF+
REFBURST
ADC10SR
REFOUT
SREF1
2_5V REFON
INCHx=0Ah
0
VREF+ 1 on
1
0 1.5V or 2.5V AVCC
Reference
VREF−/VeREF−
Ref_x
AVCC
INCHx
SREF1
4 11 10 01 00
SREF0
Auto CONSEQx
AVSS ADC10OSC
INCHx=0Bh
ADC10MEM
Ref_x
R Data Transfer
n RAM, Flash, Peripherials
Controller
ADC10SA
R
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 581
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
The ADC10 core is configured by two control registers, ADC10CTL0 and ADC10CTL1. The core is enabled with
the ADC10ON bit. With few exceptions the ADC10 control bits can only be modified when ENC = 0. ENC must
be set to 1 before any conversion can take place.
22.2.1.1 Conversion Clock Selection
The ADC10CLK is used both as the conversion clock and to generate the sampling period. The ADC10 source
clock is selected using the ADC10SSELx bits and can be divided from 1 to 8 using the ADC10DIVx bits.
Possible ADC10CLK sources are SMCLK, MCLK, ACLK, and internal oscillator ADC10OSC .
The ADC10OSC, generated internally, is in the 5-MHz range, but varies with individual devices, supply voltage,
and temperature. See the device-specific data sheet for the ADC10OSC specification.
The user must ensure that the clock chosen for ADC10CLK remains active until the end of a conversion. If the
clock is removed during a conversion, the operation does not complete, and any result is invalid.
22.2.2 ADC10 Inputs and Multiplexer
The 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 that
can result from channel switching (see Figure 22-2). The input multiplexer is also a T-switch to minimize the
coupling between channels. Channels that are not selected are isolated from the A/D, and the intermediate node
is connected to analog ground (VSS) so that the stray capacitance is grounded to help eliminate crosstalk.
The ADC10 uses the charge redistribution method. When the inputs are internally switched, the switching action
may cause transients on the input signal. These transients decay and settle before causing errant conversion.
R ~ 100Ohm INCHx
Input
Ax
ESD Protection
582 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
gates, parasitic current can flow from VCC to GND. This parasitic current occurs if the input voltage is near
the transition level of the gate. Disabling the port pin buffer eliminates the parasitic current flow and therefore
reduces overall current consumption. The ADC10AEx bits provide the ability to disable the port pin input and
output buffers.
; P2.3 on MSP430F22xx device configured for analog input
BIS.B #08h,&ADC10AE0 ; P2.3 ADC10 function and enable
Devices that do not have all the ADC10 external inputs channels Ax or VeREF+/VREF+ and VeREF-/VREF- available
at device pins must not alter the default register bit configuration of the not available pins. See device specific
data sheet.
22.2.3 Voltage 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 internally (REFOUT = 0) and, when REFOUT =
1, externally on pin VREF+. REFOUT = 1 should only be used if the pins VREF+ and VREF- are available as device
pins.
External references may be supplied for VR+ and VR- through pins A4 and A3 respectively. When external
references are used, or when VCC is used as the reference, the internal reference may be turned off to save
power.
An external positive reference VeREF+ can be buffered by setting SREF0 = 1 and SREF1 = 1 (only devices
with VeREF+ pin). This allows using an external reference with a large internal resistance at the cost of the
buffer current. When REFBURST = 1 the increased current consumption is limited to the sample and conversion
period.
External storage capacitance is not required for the ADC10 reference source as on the ADC12.
22.2.3.1 Internal Reference Low-Power Features
The ADC10 internal reference generator is designed for low power applications. The reference generator
includes a band-gap voltage source and a separate buffer. The current consumption of each is specified
separately in the device-specific data sheet. When REFON = 1, both are enabled and when REFON = 0 both are
disabled. The total settling time when REFON becomes set is approximately 30 µs.
When REFON = 1, but no conversion is active, the buffer is automatically disabled and automatically re-enabled
when needed. When the buffer is disabled, it consumes no current. In this case, the bandgap voltage source
remains enabled.
When REFOUT = 1, the REFBURST bit controls the operation of the internal reference buffer. When
REFBURST = 0, the buffer is on continuously, allowing the reference voltage to be present outside the device
continuously. When REFBURST = 1, the buffer is automatically disabled when the ADC10 is not actively
converting and is automatically re-enabled when needed.
The internal reference buffer also has selectable speed versus power settings. When the maximum conversion
rate is below 50 ksps, setting ADC10SR = 1 reduces the current consumption of the buffer approximately 50%.
22.2.4 Auto Power-Down
The ADC10 is designed for low power applications. When the ADC10 is not actively converting, the core is
automatically disabled and is automatically re-enabled when needed. The ADC10OSC is also automatically
enabled when needed and disabled when not needed. When the core or oscillator is disabled, it consumes no
current.
22.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
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 583
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
SHI
SAMPCON 13 x ADC10CLKs
tsample tconvert
tsync
ADC10CLK
MSP430
VI = Input voltage at pin Ax
RS RI VS = External source voltage
VI RS = External source resistance
VS VC
RI = Internal MUX-on input resistance
CI = Input capacitance
CI VC = Capacitance-charging voltage
The resistance of the source RS and RI affect tsample.The following equations can be used to calculate the
minimum sampling time for a 10-bit conversion.
tsample > (RS + RI) × ln(211) × CI
Substituting the values for RI and CI given above, the equation becomes:
tsample > (RS + 2 kΩ) × 7.625 × 27 pF
For example, if RS is 10 kΩ, tsample must be greater than 2.47 µs.
When the reference buffer is used in burst mode, the sampling time must be greater than the sampling time
calculated and the settling time of the buffer, tREFBURST:
584 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
11
tsample >
{ (RS + RI) × ln(2 ) × CI
tREFBURST
For example, if VRef is 1.5 V and RS is 10 kΩ, tsample must be greater than 2.47 µs when ADC10SR = 0, or 2.5 µs
when ADC10SR = 1. See the device-specific data sheet for parameters.
To calculate the buffer settling time when using an external reference, the formula is:
tREFBURST = SR × VRef − 0.5 µs
Where:
SR = Buffer slew rate (~1 µs/V when ADC10SR = 0 and ~2 µs/V when ADC10SR = 1)
VRef = External reference voltage
22.2.6 Conversion Modes
The ADC10 has four operating modes selected by the CONSEQx bits as discussed in Table 22-1.
Table 22-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 Repeat single channel A single channel is converted repeatedly.
11 Repeat sequence-of-channels A sequence of channels is converted repeatedly.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 585
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
CONSEQx = 00
ADC10
Off
ENC =
ADC10ON = 1
x = INCHx
Wait for Enable
ENC =
SHS = 0
and ENC =
ENC = 1 or
and
ADC10SC = Wait for Trigger
SAMPCON =
ENC = 0
(4/8/16/64) x ADC10CLK
Sample, Input
Channel
ENC = 0†
12 x ADC10CLK
Convert
ENC = 0†
1 x ADC10CLK
Conversion
Completed,
Result to
ADC10MEM,
ADC10IFG is Set
x = input channel Ax
†Conversion result is unpredictable
586 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
CONSEQx = 01 ADC10
Off
ADC10ON = 1
ENC =
x = INCHx
Wait for Enable
ENC =
SHS = 0
and ENC =
ENC = 1 or
and
ADC10SC = Wait for Trigger
SAMPCON = x=0
(4/8/16/64) x ADC10CLK
Sample,
Input Channel Ax
If x > 0 then x = x −1
If x > 0 then x = x −1
12 x ADC10CLK
MSC = 1
and Convert MSC = 0
x≠0 and
x ≠0
1 x ADC10CLK
Conversion
Completed,
Result to ADC10MEM,
ADC10IFG is Set
x = input channel Ax
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 587
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
CONSEQx = 10 ADC10
Off
ADC10ON = 1
ENC =
x = INCHx
Wait for Enable
ENC =
SHS = 0
and ENC =
ENC = 1 or
and
ADC10SC = Wait for Trigger
SAMPCON =
ENC = 0
(4/8/16/64) × ADC10CLK
Sample,
Input Channel Ax
12 x ADC10CLK
MSC = 1 MSC = 0
Convert
and and
ENC = 1 ENC = 1
1 x ADC10CLK
Conversion
Completed,
Result to ADC10MEM,
ADC10IFG is Set
x = input channel Ax
588 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
CONSEQx = 11 ADC10
Off
ADC10ON = 1
ENC =
x = INCHx
Wait for Enable
ENC =
SHS = 0
and ENC =
ENC = 1 or
and
ADC10SC = Wait for Trigger
SAMPCON =
(4/8/16/64) x ADC10CLK
Sample
Input Channel Ax If x = 0 then x = INCH
else x = x −1
If x = 0 then x = INCH
else x = x −1 12 x ADC10CLK ENC = 0
and
MSC = 0 x=0
Convert
and
MSC = 1 (ENC = 1
and or
(ENC = 1 1 x ADC10CLK x ≠ 0)
or
x ≠ 0) Conversion
Completed,
Result to ADC10MEM,
ADC10IFG is Set
x = input channel Ax
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 589
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
590 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
ADC10SA+2n−4
DTC
The internal address pointer is initially equal to ADC10SA and the internal transfer counter is initially equal to 'n'.
The internal pointer and counter are not visible to software. The DTC transfers the word-value of ADC10MEM to
the address pointer ADC10SA. After each DTC transfer, the internal address pointer is incremented by two and
the internal transfer counter is decremented by one.
The DTC transfers continue with each loading of ADC10MEM, until the internal transfer counter becomes equal
to zero. No additional DTC transfers occur until a write to ADC10SA. When using the DTC in the one-block
mode, the ADC10IFG flag is set only after a complete block has been transferred. Figure 22-10 shows a state
diagram of the one-block mode.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 591
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
n=0 (ADC10DTC1)
DTC reset
n ≠0
Write to
ADC10SA
x=n
n is latched
AD = SA in counter ’x’
Write to ADC10SA
or Wait until ADC10MEM
n=0 is written
DTC idle
Write to ADC10MEM
completed
Write to ADC10SA
Wait
for Synchronize
with MCLK x>0
CPU ready
DTC
operation
Write to ADC10SA
1 x MCLK cycle
Transfer data to
Address AD
AD = AD + 2
x=x−1
ADC10TB = 0
and
x=0 ADC10CT = 1
ADC10TB = 0
and
ADC10IFG=1
ADC10CT = 0
Figure 22-10. State Diagram for Data Transfer Control in One-Block Transfer Mode
592 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
ADC10SA+4n−4
ADC10SA+2n−4
The internal address pointer is initially equal to ADC10SA and the internal transfer counter is initially equal to 'n'.
The internal pointer and counter are not visible to software. The DTC transfers the word-value of ADC10MEM to
the address pointer ADC10SA. After each DTC transfer the internal address pointer is incremented by two and
the internal transfer counter is decremented by one.
The DTC transfers continue, with each loading of ADC10MEM, until the internal transfer counter becomes equal
to zero. At this point, block one is full and both the ADC10IFG flag the ADC10B1 bit are set. The user can test
the ADC10B1 bit to determine that block one is full.
The DTC continues with block two. The internal transfer counter is automatically reloaded with 'n'. At the next
load of the ADC10MEM, the DTC begins transferring conversion results to block two. After n transfers have
completed, block two is full. The ADC10IFG flag is set and the ADC10B1 bit is cleared. User software can test
the cleared ADC10B1 bit to determine that block two is full. Figure 22-12 shows a state diagram of the two-block
mode.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 593
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
n=0 (ADC10DTC1)
DTC reset
ADC10B1 = 0
ADC10TB = 1
n ≠0
n=0
Wait for write to
ADC10SA
Initialize Prepare
DTC init Start Address in ADC10SA DTC
Write to
ADC10SA
x=n
If ADC10B1 = 0
then AD = SA n is latched
in counter ’x’
Write to ADC10SA
or Wait until ADC10MEM
n=0 is written
DTC idle
Write to ADC10MEM
completed
Write to ADC10SA
Wait
for Synchronize
with MCLK x>0
CPU ready
DTC
operation
Write to ADC10SA
1 x MCLK cycle
Transfer data to
Address AD
AD = AD + 2
x=x−1
ADC10B1 = 1
x=0 or
ADC10CT=1
ADC10IFG=1 ADC10CT = 0
and
Toggle ADC10B1 = 0
ADC10B1
Figure 22-12. State Diagram for Data Transfer Control in Two-Block Transfer Mode
594 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
(1) The additional 2 µs are needed to start the DCOCLK. See the device-specific data sheet for
parameters.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 595
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
Volts
1.300
1.200
1.100
1.000
0.900
VTEMP=0.00355(TEMPC)+0.986
0.800
0.700
Celsius
−50 0 50 100
DVCC
Digital
Power Supply
Decoupling
DVSS
10uF 100nF
AVCC
Analog
Power Supply
Decoupling
(if available)
AVSS
10uF 100nF
596 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
DVCC
Digital
Power Supply
Decoupling
DVSS
10uF 100nF
Analog AVCC
Power Supply
Decoupling
(if available)
AVSS
10uF 100nF
VREF+ /VeREF+
Using an External
Positive Reference
VREF- /VeREF-
Using an External
Negative Reference
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 597
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
598 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
7 6 5 4 3 2 1 0
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)
Reference output.
Can be modified only when ENC = 0.
9 REFOUT R/W 0h
0b = Reference output off
1b = Reference output on. Devices with VeREF+ / VREF+ pin only.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 599
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
ADC10 on.
Can be modified only when ENC = 0.
4 ADC10ON R/W 0h
0b = ADC10 off
1b = ADC10 on
Enable conversion
1 ENC R/W 0h 0b = ADC10 disabled
1b = ADC10 enabled
Start conversion.
Software-controlled sample-and-conversion start. ADC10SC and
ENC may be set together with one instruction. ADC10SC is reset
0 ADC10SC R/W 0h automatically.
0b = No sample-and-conversion start
1b = Start sample-and-conversion
600 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
7 6 5 4 3 2 1 0
ADC10DIVx ADC10SSELx CONSEQx ADC10BUSY
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) r-0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 601
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
(1) Timer triggers are from Timer0_Ax if more than one timer module exists on the device.
602 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 603
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
7 6 5 4 3 2 1 0
Conversion_Results
r r r r r r r r
604 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC10
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 605
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC10 www.ti.com
7 6 5 4 3 2 1 0
ADC10SAx Unused
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) r-0
606 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
Chapter 23
ADC12
The ADC12 module is a high-performance 12-bit analog-to-digital converter. This chapter describes the ADC12
of the MSP430x2xx device family.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 607
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
608 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
REF2_5V REFON
INCHx=0Ah
VeREF+
VREF+ on
1.5 V or 2.5 V AVCC
VREF−/VeREF− Reference
AVCC Ref_x
INCHx SREF1
11 10 01 00
AVSS SREF0 ADC12OSC
4
ADC12MEM15 ADC12MCTL15
AVSS
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 609
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
The ADC12 core is configured by two control registers, ADC12CTL0 and ADC12CTL1. The core is enabled
with the ADC12ON bit. The ADC12 can be turned off when not in use to save power. With few exceptions, the
ADC12 control bits can only be modified when ENC = 0. ENC must be set to 1 before any conversion can take
place.
23.2.1.1 Conversion Clock Selection
The ADC12CLK is used both as the conversion clock and to generate the sampling period when the pulse
sampling mode is selected. The ADC12 source clock is selected using the ADC12SSELx bits and can be divided
from 1 through 8 using the ADC12DIVx bits. Possible ADC12CLK sources are SMCLK, MCLK, ACLK, and an
internal oscillator ADC12OSC.
The ADC12OSC is generated internally and is in the 5-MHz range, but the frequency varies with individual
devices, supply voltage, and temperature. See the device-specific data sheet for the ADC12OSC specification.
The application must ensure that the clock chosen for ADC12CLK remains active until the end of a conversion. If
the clock is removed during a conversion, the operation does not complete and any result is invalid.
23.2.2 ADC12 Inputs and Multiplexer
The 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 that
can result from channel switching (see Figure 23-2). The input multiplexer is also a T-switch to minimize the
coupling between channels. Channels that are not selected are isolated from the A/D, and the intermediate node
is connected to analog ground (AVSS) so that the stray capacitance is grounded to help eliminate crosstalk.
The ADC12 uses the charge redistribution method. When the inputs are internally switched, the switching action
may cause transients on the input signal. These transients decay and settle before causing errant conversion.
R ~ 100 Ohm ADC12MCTLx.0−3
Input
Ax
ESD Protection
610 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
Note
Reference Decoupling
Approximately 200 µA is required from any reference used by the ADC12 while the two LSBs
are being resolved during a conversion. A parallel combination of 10-µF and 0.1-µF capacitors is
recommended for any reference as shown in Figure 23-11.
External references may be supplied for VR+ and VR- through pins VeREF+ and VREF-/VeREF- respectively.
23.2.4 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 Timer_A Output Unit 1
• The Timer_B Output Unit 0
• The Timer_B Output Unit 1
The polarity of the SHI signal source can be inverted with the ISSH bit. The SAMPCON signal controls the
sample period and start of conversion. When SAMPCON is high, sampling is active. The high-to-low SAMPCON
transition starts the analog-to-digital conversion, which requires 13 ADC12CLK cycles. Two different sample-
timing methods are defined by control bit SHP, extended sample mode and pulse mode.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 611
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
SHI
SAMPCON 13 x ADC12CLK
tsample tconvert
t sync
ADC12CLK
SHI
SAMPCON 13 x ADC12CLK
tsample tconvert
tsync
ADC12CLK
612 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
MSP430
VI = Input voltage at pin Ax
RS RI VS = External source voltage
VI RS = External source resistance
VS VC
RI = Internal MUX-on input resistance
CI = Input capacitance
CI VC = Capacitance-charging voltage
The resistance of the source RS and RI affect tsample. The following equation can be used to calculate the
minimum sampling time tsample for a 12-bit conversion:
tsample > (RS + RI) × ln(213) × CI + 800 ns
Substituting the values for RI and CI given above, the equation becomes:
tsample > (RS + 2 kΩ) × 9.011 × 40 pF + 800 ns
For example, if RS is 10 kΩ, tsample must be greater than 5.13 µs.
23.2.5 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 sequential conversion
mode is used. A sequence rolls over from ADC12MEM15 to ADC12MEM0 when the EOS bit in ADC12MCTL15
is not set.
The CSTARTADDx bits define the first ADC12MCTLx used for any conversion. If the conversion mode is
single-channel or repeat-single-channel the CSTARTADDx points to the single ADC12MCTLx to be used.
If the conversion mode selected is either sequence-of-channels or repeat-sequence-of-channels, CSTARTADDx
points to the first ADC12MCTLx location to be used in a sequence. A pointer, not visible to software, is
incremented automatically to the next ADC12MCTLx in a sequence when each conversion completes. The
sequence continues until an EOS bit in ADC12MCTLx is processed; this is the last control byte processed.
When conversion results are written to a selected ADC12MEMx, the corresponding flag in the ADC12IFGx
register is set.
23.2.6 ADC12 Conversion Modes
The ADC12 has four operating modes selected by the CONSEQx bits as shown in Table 23-1.
Table 23-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 Repeat-single-channel A single channel is converted repeatedly.
11 Repeat-sequence-of-channels A sequence of channels is converted repeatedly.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 613
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
CONSEQx = 00
ADC12
ADC12ON = 1
off
ENC =
x = CSTARTADDx
Wait for Enable
ENC =
SHSx = 0
ENC =
and
ENC = 1 or
and
ADC12SC = Wait for Trigger
SAMPCON =
ENC = 0
SAMPCON = 1
Sample, Input
Channel Defined in
ADC12MCTLx
ENC = 0†
SAMPCON =
12 x ADC12CLK
Convert
ENC = 0†
1 x ADC12CLK
Conversion
Completed,
Result Stored Into
ADC12MEMx,
ADC12IFG.x is Set
x = pointer to ADC12MCTLx
† Conversion result is unpredictable
614 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
CONSEQx = 01 ADC12
off
ADC12ON = 1
ENC =
x = CSTARTADDx
Wait for Enable
ENC =
SHSx = 0
and ENC =
ENC = 1 or
and
ADC12SC = Wait for Trigger
SAMPCON = EOS.x = 1
SAMPCON = 1
Sample, Input
Channel Defined in
If x < 15 then x = x + 1 ADC12MCTLx If x < 15 then x = x + 1
else x = 0 else x = 0
SAMPCON =
12 x ADC12CLK
MSC = 1
and (MSC = 0
Convert or
SHP = 1
and SHP = 0)
EOS.x = 0 and
1 x ADC12CLK EOS.x = 0
Conversion
Completed,
Result Stored Into
ADC12MEMx,
ADC12IFG.x is Set
x = pointer to ADC12MCTLx
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 615
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
CONSEQx = 10 ADC12
off
ADC12ON = 1
ENC =
x = CSTARTADDx
Wait for Enable
ENC =
SHSx = 0
and ENC =
ENC = 1 or
and
ADC12SC = Wait for Trigger
SAMPCON = ENC = 0
SAMPCON = 1
Sample, Input
Channel Defined in
ADC12MCTLx
SAMPCON =
12 x ADC12CLK
MSC = 1
and (MSC = 0
Convert or
SHP = 1
and SHP = 0)
ENC = 1 and
1 x ADC12CLK ENC = 1
Conversion
Completed,
Result Stored Into
ADC12MEMx,
ADC12IFG.x is Set
x = pointer to ADC12MCTLx
616 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
CONSEQx = 11 ADC12
off
ADC12ON = 1
ENC =
x = CSTARTADDx
Wait for Enable
ENC =
SHSx = 0
and ENC =
ENC = 1 or
and
ADC12SC = Wait for Trigger
SAMPCON = ENC = 0
and
SAMPCON = 1 EOS.x = 1
Sample, Input
Channel Defined in If EOS.x = 1 then x =
ADC12MCTLx CSTARTADDx
else {if x < 15 then x = x + 1 else
SAMPCON = x = 0}
If EOS.x = 1 then x =
12 x ADC12CLK
CSTARTADDx
else {if x < 15 then x = x + 1 else (MSC = 0
Convert or
x = 0}
SHP = 0)
MSC = 1
and
and
1 x ADC12CLK (ENC = 1
SHP = 1
Conversion or
and
Completed, EOS.x = 0)
(ENC = 1
or Result Stored Into
EOS.x = 0) ADC12MEMx,
ADC12IFG.x is Set
x = pointer to ADC12MCTLx
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 617
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
Note
No EOS Bit Set For Sequence
If no EOS bit is set and a sequence mode is selected, resetting the ENC bit does not stop the
sequence. To stop the sequence, first select a single-channel mode and then reset ENC.
618 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
Volts
1.300
1.200
1.100
1.000
0.900
VTEMP=0.00355(TEMPC)+0.986
0.800
0.700
Celsius
−50 0 50 100
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 619
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
DVCC
Digital
+
Power Supply
Decoupling
DVSS
10 uF 100 nF
Analog AV CC
+
Power Supply
Decoupling AV SS
10 uF 100 nF
620 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 621
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
622 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
7 6 5 4 3 2 1 0
MSC REF2_5V REFON ADC120N ADC12OVIE ADC12TOVIE ENC ADC12SC
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 623
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
624 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
7 6 5 4 3 2 1 0
ADC12DIVx ADC12SSELx CONSEQx ADC12BUSY
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 625
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
626 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
7 6 5 4 3 2 1 0
ADC12IFG7 ADC12IFG6 ADC12IFG5 ADC12IFG4 ADC12IFG3 ADC12IFG2 ADC12IFG1 ADC12IFG0
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
7 6 5 4 3 2 1 0
ADC12IE7 ADC12IE6 ADC12IE5 ADC12IE4 ADC12IE3 ADC12IE2 ADC12IE1 ADC12IE0
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 627
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
7 6 5 4 3 2 1 0
ADC12IVx
r-0 r-0 r-(0) r-(0) r-(0) r-(0) r-(0) r-0
628 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com ADC12
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 629
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
ADC12 www.ti.com
7 6 5 4 3 2 1 0
Conversion_Results
rw rw rw rw rw rw rw rw
630 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com TLV Structure
Chapter 24
TLV Structure
The Tag-Length-Value (TLV) structure is used in selected MSP430x2xx devices to provide device-specific
information in the device's flash memory SegmentA, such as calibration data. For the device-dependent
implementation, see the device-specific data sheet.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 631
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
TLV Structure www.ti.com
The first two bytes of SegmentA (0x10C0 and 0x10C1) hold the checksum of the remainder of the segment
(addresses 0x10C2 to 0x10FF).
The first tag is located at address 0x10C2 and, in this example, is the TAG_EMPTY tag. The following byte
(0x10C3) holds the length of the following structure. The length of this TAG_EMPTY structure is 0x16 and,
therefore, the next tag, TAG_ADC12_1, is found at address 0x10DA. Again, the following byte holds the length
of the TAG_ADC12_1 structure.
The TLV structure maps the entire address range 0x10C2 to 0x10FF of the SegmentA. A program routine
looking for tags starting at the SegmentA address 0x10C2 can extract all information even if it is stored at a
different (device-specific) absolute address.
632 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com TLV Structure
The calibration data for the DCO is available in all 2xx devices and is stored at the same absolute addresses.
The device-specific SegmentA content is applied using the absolute addressing mode if the sample code shown
in Example 24-1 is used.
Example 24-1. Code Example Using Absolute Addressing Mode
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 633
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
TLV Structure www.ti.com
The temperature coefficient, TCSENSORin mV/°C, represents the slope of the equation. VSENSOR, in mV,
represents the y-intercept of the equation. Temp, in °C, is the temperature of interest.
The temperature (Temp, °C) can be computed as follows for each of the reference voltages used in the ADC
measurement:
æ 85 – 30 ö
Temp = (ADC(raw) – CAL_ADC_15T30) × çç ÷÷ + 30
è CAL_ADC_15T85 – CAL_ADC_15T30 ø
æ 85 – 30 ö
Temp = (ADC(raw) – CAL_ADC_25T30) × çç ÷÷ + 30
è CAL_ADC_25T85 – CAL_ADC_25T30 ø (2)
634 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com TLV Structure
3. Divide the result by 216 (use the upper word of the 32-bit multiplication result RESHI).
In the example:
1. 0x0100 × 0x0002 = 0x0200
2. 0x0200 × 0x7BBB = 0x00F7_7600
3. 0x00F7_7600 ÷ 0x0001_0000 = 0x0000_00F7 (= 247)
The code example using the hardware multiplier follows.
; The ADC conversion result is stored in ADC12MEM0
; It is assumed that R9 contains the address of the
; TAG_ADC12_1.
; The corrected value is available in ADC_COR
MOV.W &ADC12MEM0,R10 ; move result to R10
RLA.W R10 ; R10 x 2
MOV.W R10,&MPY ; unsigned multiply OP1
MOV.W CAL_ADC_15VREF_FACTOR(R9),&OP2
; calibration value OP2
MOV.W &RESHI,&ADC_COR ; result: upper 16-bit MPY
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 635
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
TLV Structure www.ti.com
636 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DAC12
Chapter 25
DAC12
The DAC12 module is a 12-bit voltage-output digital-to-analog converter (DAC). This chapter describes the
operation of the DAC12 module of the MSP430x2xx device family.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 637
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DAC12 www.ti.com
Note
Multiple DAC12 Modules
Some devices may integrate more than one DAC12 module. If more than one DAC12 is present on a
device, the multiple DAC12 modules operate identically.
Throughout this chapter, nomenclature appears such as DAC12_xDAT or DAC12_xCTL to describe
register names. When this occurs, the x is used to indicate which DAC12 module is being discussed.
In cases where operation is identical, the register is simply referred to as DAC12_xCTL.
638 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DAC12
Ve REF+
To ADC12 module
VREF+
2.5V or 1.5V reference fromADC12
DAC12SREFx
DAC12AMPx
DAC12IR
3
00
01
/3
10
11 AV SS
VR− VR+
DAC12LSELx DAC12_0OUT
DAC12_0 x3
Latch Bypass
00
01
0
TA1 10 1 DAC12RES
1 DAC12_0Latch
TB2 11 0 DAC12DF
DAC12GRP
DAC12ENC DAC12_0DAT
DAC12_0DAT Updated
Group
Load
Logic DAC12SREFx
DAC12AMPx
DAC12IR
00 3
01
/3
10
11 AV SS
VR− VR+
DAC12LSELx DAC12_1OUT
DAC12_1 x3
Latch Bypass
00
01
0
TA1 10 1 DAC12RES
1 DAC12_1Latch
TB2 11 0 DAC12DF
DAC12GRP
DAC12ENC DAC12_1DAT
DAC12_1DAT Updated
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 639
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DAC12 www.ti.com
DAC12_xDAT
12 bit 0 1 VOUT = VREF ×
4096
DAC12_xDAT
8 bit 1 0 VOUT = VREF × 3 ×
256
DAC12_xDAT
8 bit 1 1 VOUT = VREF ×
256
In 8-bit mode, the maximum useable value for DAC12_xDAT is 0FFh. In 12-bit mode, the maximum useable
value for DAC12_xDAT is 0FFFh. Values greater than these may be written to the register, but all leading bits
are ignored.
25.2.1.1 DAC12 Port Selection
The DAC12 outputs are multiplexed with the port P6 pins and ADC12 analog inputs, and also the VeREF+ pins.
When DAC12AMPx > 0, the DAC12 function is automatically selected for the pin, regardless of the state of
the associated PxSELx and PxDIRx bits. The DAC12OPS bit selects between the P6 pins and the VeREF+ pins
for the DAC outputs. For example, when DAC12OPS = 0, DAC12_0 outputs on P6.6 and DAC12_1 outputs
on P6.7. When DAC12OPS = 1, DAC12_0 outputs on VeREF+ and DAC12_1 outputs on P6.5. See the port pin
schematic in the device-specific data sheet for more details.
25.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 VREF+ signal is
used as the reference and when DAC12SREFx = {2,3} the VeREF+ signal is used as the reference.
To use the ADC12 internal reference, it must be enabled and configured via the applicable ADC12 control bits.
25.2.2.1 DAC12 Reference Input and Voltage Output Buffers
The reference input and voltage output buffers of the DAC12 can be configured for optimized settling time vs
power consumption. Eight combinations are selected using the DAC12AMPx bits. In the low/low setting, the
settling time is the slowest, and the current consumption of both buffers is the lowest. The medium and high
settings have faster settling times, but the current consumption increases. See the device-specific data sheet for
parameters.
25.2.3 Updating the DAC12 Voltage Output
The DAC12_xDAT register can be connected directly to the DAC12 core or double buffered. The trigger for
updating the DAC12 voltage output is selected with the DAC12LSELx bits.
640 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DAC12
When DAC12LSELx = 0 the data latch is transparent and the DAC12_xDAT register is applied directly to the
DAC12 core. the DAC12 output updates immediately when new DAC12 data is written to the DAC12_xDAT
register, regardless of the state of the DAC12ENC bit.
When DAC12LSELx = 1, DAC12 data is latched and applied to the DAC12 core after new data is written to
DAC12_xDAT. When DAC12LSELx = 2 or 3, data is latched on the rising edge from the Timer_A CCR1 output or
Timer_B CCR2 output respectively. DAC12ENC must be set to latch the new data when DAC12LSELx > 0.
25.2.4 DAC12_xDAT Data Format
The DAC12 supports both straight binary and 2s 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 25-2.
Output Voltage
Full-Scale Output
0 DAC Data
0 0FFFh
Figure 25-2. Output Voltage vs DAC12 Data, 12-Bit, Straight Binary Mode
When using 2s-compliment data format, the range is shifted such that a DAC12_xDAT value of 0800h (0080h in
8-bit mode) results in a zero output voltage, 0000h is the mid-scale output voltage, and 07FFh (007Fh for 8-bit
mode) is the full-scale voltage output (see Figure 25-3).
Output Voltage
Full-Scale Output
Mid-Scale Output
DAC Data
0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 641
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DAC12 www.ti.com
Output Voltage
When the output amplifier has a positive offset, a digital input of zero does not result in a zero output voltage.
The DAC12 output voltage reaches the maximum output level before the DAC12 data reaches the maximum
code. This is shown in Figure 25-5.
Vcc
Output Voltage
0
DAC Data Full-Scale Code
The DAC12 has the capability to calibrate the offset voltage of the output amplifier. Setting the DAC12CALON
bit initiates the offset calibration. The calibration should complete before using the DAC12. When the calibration
is complete, the DAC12CALON bit is automatically reset. The DAC12AMPx bits should be configured before
calibration. For best calibration results, port and CPU activity should be minimized during calibration.
25.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.
DAC12_0 and DAC12_1 are grouped by setting the DAC12GRP bit of DAC12_0. The DAC12GRP bit of
DAC12_1 is don’t care. When DAC12_0 and DAC12_1 are grouped:
• The DAC12_1 DAC12LSELx bits select the update trigger for both DACs
• The DAC12LSELx bits for both DACs must be > 0
• The DAC12ENC bits of both DACs must be set to 1
When DAC12_0 and DAC12_1 are grouped, both DAC12_xDAT registers must be written to before the outputs
update, even if data for one or both of the DACs is not changed. Figure 25-6 shows a latch-update timing
example for grouped DAC12_0 and DAC12_1.
When DAC12_0 DAC12GRP = 1 and both DAC12_x DAC12LSELx > 0 and either DAC12ENC = 0, neither
DAC12 updates.
642 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DAC12
DAC12_0
DAC12_0 and DAC12_1
DAC12GRP
Updated Simultaneously
DAC12_0
DAC12ENC
TimerA_OUT1
DAC12_0DAT
New Data
DAC12_1DAT DAC12_0 Updated
New Data
DAC12_0
Latch Trigger
Note
DAC12 Settling Time
The DMA controller is capable of transferring data to the DAC12 faster than the DAC12 output can
settle. The user must assure the DAC12 settling time is not violated when using the DMA controller.
See the device-specific data sheet for parameters.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 643
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DAC12 www.ti.com
644 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DAC12
7 6 5 4 3 2 1 0
DAC12AMPx DAC12DF DAC12IE DAC12IFG DAC12ENC DAC12GRP
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
DAC12 load select. Selects the load trigger for the DAC12 latch.
DAC12ENC must be set for the DAC to update, except when
DAC12LSELx = 0. Can be modified only when DAC12ENC = 0.
00b = DAC12 latch loads when DAC12_xDAT written (DAC12ENC is
ignored)
11-10 DAC12LSELx R/W 0h
01b = DAC12 latch loads when DAC12_xDAT written, or, when
grouped, when all DAC12_xDAT registers in the group have been
written.
10b = Rising edge of Timer_A.OUT1 (TA1)
11b = Rising edge of Timer_B.OUT2 (TB2)
DAC12 calibration on. This bit initiates the DAC12 offset calibration
sequence and is automatically reset when the calibration completes.
9 DAC12CALON R/W 0h
0b = Calibration is not active
1b = Initiate calibration or calibration in progress
DAC12 input range. This bit sets the reference input and voltage
output range. Can be modified only when DAC12ENC = 0.
8 DAC12IR R/W 0h
0b = DAC12 full-scale output = 3x reference voltage
1b = DAC12 full-scale output = 1x reference voltage
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 645
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DAC12 www.ti.com
DAC12 enable conversion. This bit enables the DAC12 module when
DAC12LSELx > 0. When DAC12LSELx = 0, DAC12ENC is ignored.
1 DAC12ENC R/W 0h
0b = DAC12 disabled
1b = DAC12 enabled
DAC12 group. Groups DAC12_x with the next higher DAC12_x. Not
used for DAC12_1.
0 DAC12GRP R/W 0h
0b = Not grouped
1b = Grouped
646 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com DAC12
7 6 5 4 3 2 1 0
DAC12 Data
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 647
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
DAC12 www.ti.com
648 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD16_A
Chapter 26
SD16_A
The SD16_A module is a single-converter 16-bit sigma-delta analog-to-digital conversion module with high
impedance input buffer. This chapter describes the SD16_A. The SD16_A module is implemented in the
MSP430x20x3 devices.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 649
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD16_A www.ti.com
650 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD16_A
SD16REFON
1 00 MCLK
AV SS Divider 01 SMCLK
Divider
Reference fM 1/3/16/48 1/2/4/8 10 ACLK
11 TACLK
SD16VMIDON
A0 + 000
− SD16BUFx†
A1 + 001
− SD16OSRx
SD16GAINx
A2 + 010
− 15 0
A3 +
− 011 PGA 2ndOrder
+ BUF SD16MEM0
A4 100 1..32 Σ∆ Modulator
−
A5 + 101
−
+ SD16UNI SD16DF
A6 110 SD16XOSR
−
+ Reference SD16LP
A7 111
−
AVCC
1
Temp.
sensor SD16INCHx=101
5R
5R
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 651
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD16_A www.ti.com
For a 1.2-V reference, the maximum full-scale input range for a gain of 1 is:
1.2 V
±VFSR = 2 = ±0.6 V
1
652 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD16_A
During conversion any modification to the SD16INCHx and SD16GAINx bits will become effective with the next
decimation step of the digital filter. After these bits are modified, the next three conversions may be invalid
due to the settling time of the digital filter. This can be handled automatically with the SD16INTDLYx bits.
When SD16INTDLY = 00h, conversion interrupt requests will not begin until the fourth conversion after a start
condition.
On devices implementing the high impedance input buffer it can be enabled using the SD16BUFx bits. The
speed settings are selected based on the SD16_A modulator frequency as shown in Table 26-1.
Table 26-1. High Input Impedance Buffer
SD16BUFx Buffer SD16 Modulator Frequency fM
00 Buffer disabled
01 Low speed/current fM < 200 kHz
10 Medium speed/current 200 kHz < fM < 700 kHz
11 High speed/current 700 kHz < fM < 1.1 MHz
An external RC anti-aliasing filter is recommended for the SD16_A to prevent aliasing of the input signal. The
cutoff frequency should be < 10 kHz for a 1-MHz modulator clock and OSR = 256. The cutoff frequency may set
to a lower frequency for applications that have lower bandwidth requirements.
26.2.6 Analog Input Characteristics
The SD16_A uses a switched-capacitor input stage that appears as an impedance to external circuitry as shown
in Figure 26-2.
MSP430
VS+ = Positive external source voltage
RS 1k VS− = Negative external source voltage
RS = External source resistance
VS+ †
CS = Sampling capacitance
CS
AVCC / 2
CS
RS 1k
VS− †
When the buffers are used, RS does not affect the sampling frequency fS. However, when the buffers are not
used or are not present on the device, the maximum sampling frequency fS may be calculated from the minimum
settling time tSettling of the sampling circuit given by:
æ GAIN × 217 × V ö
tSettling ³ (RS + 1 kW) × CS × ln ç Ax ÷
ç VREF ÷
è ø
where
1 æ AVCC AVCC ö
fS = and VAx = max çç – VS+ , – VS– ÷÷
2 × tSettling è 2 2 ø
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 653
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD16_A www.ti.com
where the oversampling rate, OSR, is the ratio of the modulator frequency fM to the sample frequency fS. Figure
26-3 shows the filter's frequency response for an OSR of 32. The first filter notch is at fS = fM/OSR. The notch's
frequency can be adjusted by changing the modulator's frequency, fM, using SD16SSELx and SD16DIVx and the
oversampling rate using the SD16OSRx and SD16XOSR bits.
The digital filter for each enabled ADC channel completes the decimation of the digital bit-stream and outputs
new conversion results to the SD16MEM0 register at the sample frequency fS.
−20
−40
GAIN [dB]
−60
−80
−100
−120
−140
fS fM
Frequency
Figure 26-4 shows the digital filter step response and conversion points. For step changes at the input after start
of conversion a settling time must be allowed before a valid conversion result is available. The SD16INTDLYx
bits can provide sufficient filter settling time for a full-scale change at the ADC input. If the step occurs
synchronously to the decimation of the digital filter the valid data will be available on the third conversion.
An asynchronous step will require one additional conversion before valid data is available.
654 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD16_A
100 100
80 80
60 60
% VFSR
% VFSR
40 40
20 20
0 0
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Conversions Conversions
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 655
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD16_A www.ti.com
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
656 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD16_A
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 657
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD16_A www.ti.com
Note
Offset Measurements and Data Format
Any offset measurement done either externally or using the internal differential pair A7 would be
appropriate only when the channel is operating under bipolar mode with SD16UNI = 0.
Figure 26-6 shows the relationship between the full-scale input voltage range from -VFSR to +VFSR and the
conversion result. The data formats are illustrated.
Bipolar Output: Offset Binary Bipolar Output: 2’s complement Unipolar Output
SD16MEMx SD16MEMx SD16MEMx
Input Input
−VFSR Voltage
8000h Voltage
0000h 0000h
+V FSR −VFSR +V FSR
Input
Voltage
0000h 8000h
−V FSR +V FSR
658 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD16_A
Conversion
SD16SNGL = 1
SD16SC Set by SW Auto−clear
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 659
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD16_A www.ti.com
Volts
0.500
0.450
0.400
0.350
0.250
0.200
Celsius
−50 0 50 100
660 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD16_A
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 661
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD16_A www.ti.com
662 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD16_A
7 6 5 4 3 2 1 0
SD16DIVx SD16SSELx SD16VMIDON SD16REFON SD16OVIE Reserved
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 r0
VMID buffer on
3 SD16VMIDON R/W 0h 0b = Off
1b = On
Reference generator on
2 SD16REFON R/W 0h 0b = Reference off
1b = Reference on
SD16_A overflow interrupt enable. The GIE bit must also be set to
enable the interrupt.
1 SD16OVIE R/W 0h
0b = Overflow interrupt disabled
1b = Overflow interrupt enabled
0 Reserved R 0h
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 663
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD16_A www.ti.com
7 6 5 4 3 2 1 0
SD16LSBTOG SD16LSBACC SD16OVIFG SD16DF SD16IE SD16IFG SD16SC Reserved
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 r-0
Oversampling ratio
When SD16XOSR = 0
00b = 256
01b = 128
10b = 64
When SD16XOSR = 1
00b = 512
01b = 1024
10b = Reserved
11b = Reserved
664 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD16_A
LSB access. This bit allows access to the upper or lower 16-bits of
the SD16_A conversion result.
0b = SD16MEMx contains the most significant 16-bits of the
6 SD16LSBACC R/W 0h
conversion.
1b = SD16MEMx contains the least significant 16-bits of the
conversion.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 665
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD16_A www.ti.com
7 6 5 4 3 2 1 0
Conversion_Results
r-0 r-0 r-0 r-0 r-0 r-0 r-0 r-0
666 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD16_A
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 667
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD16_A www.ti.com
668 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD16_A
7 6 5 4 3 2 1 0
SD16IVx
r-0 r-0 r-0 r-0 r-0 r-0 r-0 r-0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 669
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD16_A www.ti.com
670 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
Chapter 27
SD24_A
The SD24_A module is a multichannel 24-bit sigma-delta analog-to-digital converter (ADC). This chapter
describes the SD24_A of the MSP430x2xx family.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 671
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
672 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
Channel 0
SD24GRP
Group/Start
SD24SC
SD24INCHx Conversion Logic
SD24SGNL
Conversion Control
A1.0 + 000 (from next channel)
−
A1.1 + 001 SD24OSRx
− SD24GAINx
A1.2 + 010
− 15 0
+
A1.3
− 011 PGA 2ndOrder
+ SD24MEM1
A1.4 100 1..32 Σ∆ Modulator
−
A1.5 + 101
−
+ SD24UNI SD24DF
A1.6 − 110 SD24XOSR
+ SD24LP
A1.7 111 SD24PRE1
−
Channel 2
Channel 3 ( up to Channel 6)
AVCC
1
Temp.
sensor SD24INCHx=101
5R
5R
A. Ax.1 to Ax.4 not available on all devices. See device-specific data sheet.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 673
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
For a 1.2-V reference, the maximum full-scale input range for a gain of 1 is:
1.2 V
±VFSR = 2 = ±0.6 V
1
674 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
On some devices SD24AEx bits are available to enable or disable the analog input pin. Setting any SD24AEx
bit disables the multiplexed digital circuitry for the associated pin. See the device-specific data sheet for pin
diagrams.
During conversion any modification to the SD24INCHx and SD24GAINx bits will become effective with the next
decimation step of the digital filter. After these bits are modified, the next three conversions may be invalid
due to the settling time of the digital filter. This can be handled automatically with the SD24INTDLYx bits.
When SD24INTDLY = 00h, conversion interrupt requests will not begin until the fourth conversion after a start
condition.
On devices implementing the high impedance input buffer it can be enabled using the SD24BUFx bits. The
speed settings are selected based on the SD24_A modulator frequency as shown in Table 27-1.
Table 27-1. High Input Impedance Buffer
SD24BUFx Buffer SD24 Modulator Frequency, fM
00 Buffer disabled
01 Low speed/current fM < 200 kHz
10 Medium speed/current 200 kHz < fM < 700 kHz
11 High speed/current 700 kHz < fM < 1.1 MHz
An external RC anti-aliasing filter is recommended for the SD24_A to prevent aliasing of the input signal. The
cutoff frequency should be less than 10 kHz for a 1-MHz modulator clock and OSR = 256. The cutoff frequency
may set to a lower frequency for applications that have lower bandwidth requirements.
27.2.6 Analog Input Characteristics
The SD24_A uses a switched-capacitor input stage that appears as an impedance to external circuitry as shown
in Figure 27-2.
MSP430
VS+ = Positive external source voltage
RS 1k VS− = Negative external source voltage
RS = External source resistance
VS+ †
CS = Sampling capacitance
CS
AVCC / 2
CS
RS 1k
VS− †
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 675
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
When the buffers are used, RS does not affect the sampling frequency fS. However, when the buffers are
not used or are not present on the device, the maximum modulator frequency fM may be calculated from the
minimum settling time tSettling of the sampling circuit given by:
æ GAIN × 217 × V ö
tSettling ³ (RS + 1 kW) × CS × ln ç Ax ÷
ç VREF ÷
è ø
Where,
1 æ AVCC AVCC ö
fM = and VAx = max çç – VS+ , – VS– ÷÷
2 × tSettling è 2 2 ø
where the oversampling rate, OSR, is the ratio of the modulator frequency fM to the sample frequency fS. Figure
27-3 shows the filter's frequency response for an OSR of 32. The first filter notch is at fS = fM/OSR. The notch
frequency can be adjusted by changing the modulator frequency, fM, using SD24SSELx and SD24DIVx and the
oversampling rate using the SD24OSRx and SD24XOSR bits.
The digital filter for each enabled ADC channel completes the decimation of the digital bit-stream and outputs
new conversion results to the corresponding SD24MEMx register at the sample frequency fS.
676 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
−20
−60
−80
−100
−120
−140
fS fM
Frequency
Figure 27-4 shows the digital filter step response and conversion points. For step changes at the input after start
of conversion a settling time must be allowed before a valid conversion result is available. The SD24INTDLYx
bits can provide sufficient filter settling time for a full-scale change at the ADC input. If the step occurs
synchronously to the decimation of the digital filter the valid data will be available on the third conversion.
An asynchronous step will require one additional conversion before valid data is available.
Asynchronous Step Synchronous Step
100 100
80 80
60 60
% VFSR
% VFSR
40 40
20 20
0 0
0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
Conversions Conversions
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 677
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
678 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 679
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
Note
Offset Measurements and Data Format
Any offset measurement done either externally or using the internal differential pair A7 would be
appropriate only when the channel is operating under bipolar mode with SD24UNI = 0.
If the measured value is to be used in the unipolar mode for offset correction it needs to be multiplied
by two.
Figure 27-6 shows the relationship between the full-scale input voltage range from -VFSR to +VFSR and the
conversion result. The data formats are illustrated.
Bipolar Output: Offset Binary Bipolar Output: 2’s complement Unipolar Output
SD24MEMx SD24MEMx SD24MEMx
Input
−VFSR Voltage
8000h 0000h
+V FSR
Input Input
Voltage Voltage
0000h 8000h 0000h
−V FSR +V FSR −VFSR +V FSR
680 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
(1) A channel is grouped and is the master channel of the group when SD24GRP = 0 if SD24GRP for the prior channel(s) is set.
Channel 0 Conversion
SD24SNGL = 1
SD24GRP = 0 SD24SC Set by SW Auto−clear
Conversion Conversion
Channel 1
SD24SNGL = 1
SD24GRP = 0 SD24SC Set by SW Auto−clear Set by SW Auto−clear
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 681
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
682 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
The SD24PREx delay is applied to the beginning of the next conversion cycle after being written. The delay is
used on the first conversion after SD24SC is set and on the conversion cycle following each write to SD24PREx.
Following conversions are not delayed. After modifying SD24PREx, the next write to SD24PREx should not
occur until the next conversion cycle is completed, otherwise the conversion results may be incorrect.
The accuracy of the result for the delayed conversion cycle using SD24PREx is dependent on the length of
the delay and the frequency of the analog signal being sampled. For example, when measuring a DC signal,
SD24PREx delay has no effect on the conversion result regardless of the duration. The user must determine
when the delayed conversion result is useful in their application.
Figure 27-10 shows the operation of grouped channels 0 and 1. The preload register of channel 1 is loaded
with zero resulting in immediate conversion whereas the conversion cycle of channel 0 is delayed by setting
SD24PRE0 = 8. The first channel 0 conversion uses SD24PREx = 8, shifting all subsequent conversions by
eight fM clock cycles.
SD24OSRx = 32
f M cycles: 40 32 32
SD24PRE0 = 8 Delayed Conversion Conversion Conversion
When channels are grouped, care must be taken when a channel or channels operate in single conversion
mode or are disabled in software while the master channel remains active. Each time channels in the group are
re-enabled and re-synchronize with the master channel, the preload delay for that channel will be reintroduced.
Figure 27-11 shows the re-synchronization and preload delays for channels in a group. It is recommended
that SD24PREx = 0 for the master channel to maintain a consistent delay between the master and remaining
channels in the group when they are re-enabled.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 683
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
(syncronized to master)
0.500
0.450
0.400
0.350
0.250
0.200
Celsius
−50 0 50 100
684 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 685
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
686 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
(1) Not implemented on all devices; see the device-specific data sheet.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 687
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
7 6 5 4 3 2 1 0
SD24DIVx SD24SSELx SD24VMIDON SD24REFON SD24OVIE Reserved
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 r-0
VMID buffer on
3 SD24VMIDON R/W 0h 0b = Off
1b = On
Reference generator on
2 SD24REFON R/W 0h 0b = Reference off
1b = Reference on
SD24_A overflow interrupt enable. The GIE bit must also be set to
enable the interrupt.
1 SD24OVIE R/W 0h
0b = Overflow interrupt disabled
1b = Overflow interrupt enabled
0 Reserved R 0h
688 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
7 6 5 4 3 2 1 0
SD24IVx
r-0 r-0 r-0 r-0 r-0 r-0 r-0 r-0
(1) When an SD24_A overflow occurs, the user must check all SD24CCTLx SD24OVIFG flags to
determine which channel overflowed.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 689
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
690 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
7 6 5 4 3 2 1 0
SD24LSBTOG SD24LSBACC SD24OVIFG SD24DF SD24IE SD24IFG SD24SC SD24GRP
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 r(w)-0
Oversampling ratio
When SD24XOSR = 0
00b = 256
01b = 128
10b = 64
When SD24XOSR = 1
00b = 512
01b = 1024
10b = Reserved
11b = Reserved
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 691
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
LSB access. This bit allows access to the upper or lower 16-bits of
the SD24_A conversion result.
0b = SD24MEMx contains the most significant 16-bits of the
6 SD24LSBACC R/W 0h
conversion.
1b = SD24MEMx contains the least significant 16-bits of the
conversion.
692 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
7 6 5 4 3 2 1 0
Conversion_Results
r-0 r-0 r-0 r-0 r-0 r-0 r-0 r-0
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 693
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
694 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com SD24_A
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 695
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
SD24_A www.ti.com
696 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Embedded Emulation Module (EEM)
Chapter 28
Embedded Emulation Module (EEM)
This chapter describes the Embedded Emulation Module (EEM) that is implemented in all MSP430 flash
devices.
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 697
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Embedded Emulation Module (EEM) www.ti.com
698 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Embedded Emulation Module (EEM)
MB1
MB2
MB3
MB4
MB5
MB6
MB7
CPU0
CPU1
Trigger Sequencer
OR CPU Stop
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 699
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Embedded Emulation Module (EEM) www.ti.com
700 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
www.ti.com Embedded Emulation Module (EEM)
SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022 MSP430F2xx, MSP430G2xx Family 701
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
Revision History www.ti.com
Revision History
NOTE: Page numbers for previous revisions may differ from page numbers in the current version.
Changes from July 1, 2013 to August 25, 2022 Page
• Corrected the descriptions of the N and Z status bits in Section 3.4.6.14, CMP ............................................. 78
• Corrected the descriptions of the N and Z status bits in Section 4.6.2.14, CMP ........................................... 180
• Added MSP430G2x55 to "Device-Specific Clock Variations" note................................................................. 276
• Added ACLK_request, MCLK_request, and SMCLK_request to the paragraph that starts "Software can
disable LFXT1 by setting OSCOFF..." ........................................................................................................... 279
• Correct name of SELM1 bit (changed from XSELM1) in Figure 5-3, Off Signals for the LFXT1 Oscillator ... 279
• Added MCLK_request and SMCLK_request to the first paragraph of Section 5.2.4, XT2 Oscillator ............ 280
• Correct name of SELM1 bit (changed from XSELM1) in Figure 5-4, Off Signals for Oscillator XT2 ............. 280
• Correct name of SELM1 bit (changed from XSELM1) in Figure 5-5, On and Off Control of DCO ................ 281
• Updated description of segment and block sizes in Section 7.2, Flash Memory Segmentation ....................318
• Corrected address on main memory boundary (changed 0x0F000 to 0x08000) in Figure 7-2, Flash Memory
Segments, 32KB Example .............................................................................................................................318
• Corrected the access type (read only) of the BUSY bit.................................................................................. 332
• Added note to P2SEL reset value in Table 8-2, Digital I/O Registers ............................................................ 345
• Added description sections for Digital I/O registers (Section 8.3.1 through Section 8.3.9)............................ 347
• Changed TACCTLx to TACCRx in the comment in the second line of the code example in Section 12.2.4.1,
Capture Initiated by Software ........................................................................................................................ 381
• Corrected formatting of IDx values in Table 13-6, TBCTL Register Field Descriptions ................................. 411
• Added the note that begins "If USIIE = 1 when the USI module is in software reset mode..." in Section 14.2.1,
USI Initialization ............................................................................................................................................. 421
• Added the paragraph that starts "For examples of using the USI in I2C mode...".......................................... 424
• Added the note "Reliable reception of IrDA signals" in Section 15.3.5.2, IrDA Decoding ............................. 440
• Updated Figure 17-3, I2C Module Data Transfer, to clarify SDA transitions when SCL is low....................... 486
• Corrected bit field name in Figure 18-20, UxRXBUF Register ...................................................................... 526
• Corrected bit field name in Figure 18-21, UxTXBUF Register .......................................................................526
• Corrected bit field name in Figure 19-19, UxRXBUF Register ...................................................................... 544
• Corrected bit field name in Figure 19-20, UxTXBUF Register .......................................................................544
• Added note that starts "Changing the value of the CAIES bit...".................................................................... 572
• Added MSP430G2x44 and MSP430G2x55 to the list item that starts "Up to eight external input channels..."....
580
• Added MSP430G2x44 and MSP430G2x55 to the first note on Figure 22-1, ADC10 Block Diagram ........... 580
• Added MSP430G2x44 and MSP430G2x55 to enums 1100b through 1111b in the INCHx bit description..... 598
• Changed TAG_ADC10_1 value to be device dependent............................................................................... 633
• Changed Figure 26-4 .....................................................................................................................................654
• Changed Figure 27-4 .....................................................................................................................................676
702 MSP430F2xx, MSP430G2xx Family SLAU144K – DECEMBER 2004 – REVISED AUGUST 2022
Submit Document Feedback
Copyright © 2022 Texas Instruments Incorporated
IMPORTANT NOTICE AND DISCLAIMER
TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATA SHEETS), DESIGN RESOURCES (INCLUDING REFERENCE
DESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES “AS IS”
AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANY
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRD
PARTY INTELLECTUAL PROPERTY RIGHTS.
These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate
TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicable
standards, and any other safety, security, regulatory or other requirements.
These resources are subject to change without notice. TI grants you permission to use these resources only for development of an
application that uses the TI products described in the resource. Other reproduction and display of these resources is prohibited. No license
is granted to any other TI intellectual property right or to any third party intellectual property right. TI disclaims responsibility for, and you
will fully indemnify TI and its representatives against, any claims, damages, costs, losses, and liabilities arising out of your use of these
resources.
TI’s products are provided subject to TI’s Terms of Sale or other applicable terms available either on ti.com or provided in conjunction with
such TI products. TI’s provision of these resources does not expand or otherwise alter TI’s applicable warranties or warranty disclaimers for
TI products.
TI objects to and rejects any additional or different terms you may have proposed. IMPORTANT NOTICE
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2022, Texas Instruments Incorporated