CC430 User's Guide
CC430 User's Guide
CC430 User's Guide
CC430 Family
User's Guide
Preface.............................................................................................................................. 19
1 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) ............. 21
1.1 System Control Module (SYS) Introduction ............................................................................ 22
1.2 System Reset and Initialization ........................................................................................... 22
1.2.1 Device Initial Conditions After System Reset .................................................................. 24
1.3 Interrupts .................................................................................................................... 24
1.3.1 (Non)Maskable Interrupts (NMIs) ............................................................................... 25
1.3.2 SNMI Timing ....................................................................................................... 25
1.3.3 Maskable Interrupts ............................................................................................... 27
Interrupt Processing............................................................................................... 27
1.3.5 Interrupt Vectors ................................................................................................... 28
1.3.6 SYS Interrupt Vector Generators ................................................................................ 29
1.3.7 Interrupt Nesting ................................................................................................... 30
1.4 Operating Modes ........................................................................................................... 31
1.4.1 Entering and Exiting Low-Power Modes LPM0 Through LPM4 ............................................. 34
1.4.2 Entering and Exiting Low-Power Mode LPM5 ................................................................. 34
1.4.3 Extended Time in Low-Power Modes .......................................................................... 35
1.5 Principles for Low-Power Applications .................................................................................. 36
1.6 Connection of Unused Pins ............................................................................................... 36
1.7 Boot Code ................................................................................................................... 36
1.8 Bootstrap Loader (BSL) ................................................................................................... 36
1.9 Memory Map – Uses and Abilities ....................................................................................... 37
1.9.1 Vacant Memory Space ........................................................................................... 37
1.9.2 JTAG Lock Mechanism via the Electronic Fuse .............................................................. 37
10-2 JTAG Mailbox (JMB) System ............................................................................................ 38
1.10.1 JMB Configuration ............................................................................................... 38
1.10.2 JMBOUT0 and JMBOUT1 Outgoing Mailbox................................................................. 38
1.10.3 JMBIN0 and JMBIN1 Incoming Mailbox....................................................................... 38
1.10.4 JMB NMI Usage .................................................................................................. 38
1.11 Device Descriptor Table ................................................................................................... 39
1.11.1 Identifying Device Type.......................................................................................... 39
1.11.2 TLV Descriptors .................................................................................................. 40
1.11.3 Peripheral discovery descriptor................................................................................. 40
1.12 Special Function Registers (SFRs) ..................................................................................... 44
1.13 SYS Configuration Registers ............................................................................................. 48
www.ti.com
www.ti.com
www.ti.com
www.ti.com
www.ti.com
www.ti.com
www.ti.com
www.ti.com
List of Figures
1-1 BOR/POR/PUC Reset Circuit............................................................................................. 23
1-2 Interrupt Priority............................................................................................................. 24
1-3 NMIs With Reentrance Protection........................................................................................ 26
1-4 Interrupt Processing........................................................................................................ 27
1-5 Return From Interrupt ...................................................................................................... 28
1-6 Operation Modes ........................................................................................................... 32
1-7 Devices Descriptor Table.................................................................................................. 39
2-1 Watchdog Timer Block Diagram.......................................................................................... 59
3-1 UCS Block Diagram ........................................................................................................ 67
3-2 Modulator Patterns ......................................................................................................... 71
3-3 Module Request Clock System ........................................................................................... 73
3-4 Oscillator Fault Logic ...................................................................................................... 75
3-5 Switch MCLK from DCOCLK to XT1CLK ............................................................................... 76
4-1 System Frequency and Supply/Core Voltages ......................................................................... 88
4-2 PMM Block Diagram ....................................................................................................... 89
4-3 High-Side and Low-Side Voltage Failure and Resulting PMM Actions ............................................. 91
4-4 High-Side SVS and SVM .................................................................................................. 92
4-5 Low-Side SVS and SVM .................................................................................................. 93
4-6 PMM Action at Device Power-Up ........................................................................................ 94
4-7 Changing VCORE and SVML and SVSL Levels .......................................................................... 95
5-1 MSP430X CPU Block Diagram ......................................................................................... 107
5-2 PC Storage on the Stack for Interrupts ................................................................................ 108
5-3 Program Counter.......................................................................................................... 109
5-4 PC Storage on the Stack for CALLA ................................................................................... 109
5-5 Stack Pointer .............................................................................................................. 110
5-6 Stack Usage ............................................................................................................... 110
5-7 PUSHX.A Format on the Stack ......................................................................................... 110
5-8 PUSH SP, POP SP Sequence .......................................................................................... 110
5-9 SR Bits ..................................................................................................................... 111
5-10 Register-Byte/Byte-Register Operation ................................................................................ 113
5-11 Register-Word Operation ................................................................................................ 113
5-12 Word-Register Operation ................................................................................................ 114
5-13 Register – Address-Word Operation ................................................................................... 114
5-14 Address-Word – Register Operation ................................................................................... 115
5-15 Indexed Mode in Lower 64 KB .......................................................................................... 117
5-16 Indexed Mode in Upper Memory ....................................................................................... 118
5-17 Overflow and Underflow for Indexed Mode ........................................................................... 119
5-18 Example for Indexed Mode .............................................................................................. 120
5-19 Symbolic Mode Running in Lower 64 KB .............................................................................. 122
5-20 Symbolic Mode Running in Upper Memory ........................................................................... 123
5-21 Overflow and Underflow for Symbolic Mode .......................................................................... 124
5-22 MSP430 Double-Operand Instruction Format......................................................................... 133
5-23 MSP430 Single-Operand Instructions .................................................................................. 134
5-24 Format of Conditional Jump Instructions .............................................................................. 135
5-25 Extension Word for Register Modes ................................................................................... 138
5-26 Extension Word for Non-Register Modes .............................................................................. 138
5-27 Example for Extended Register/Register Instruction ................................................................. 139
5-28 Example for Extended Immediate/Indexed Instruction ............................................................... 140
5-29 Extended Format I Instruction Formats ................................................................................ 141
5-30 20-Bit Addresses in Memory ............................................................................................ 141
5-31 Extended Format II Instruction Format ................................................................................. 142
5-32 PUSHM/POPM Instruction Format ..................................................................................... 143
www.ti.com
5-33 RRCM, RRAM, RRUM, and RLAM Instruction Format .............................................................. 143
5-34 BRA Instruction Format .................................................................................................. 143
5-35 CALLA Instruction Format ............................................................................................... 143
5-36 Decrement Overlap ....................................................................................................... 168
5-37 Stack After a RET Instruction ........................................................................................... 187
5-38 Destination Operand—Arithmetic Shift Left ........................................................................... 189
5-39 Destination Operand—Carry Left Shift ................................................................................. 190
5-40 Rotate Right Arithmetically RRA.B and RRA.W ...................................................................... 191
5-41 Rotate Right Through Carry RRC.B and RRC.W .................................................................... 192
5-42 Swap Bytes in Memory................................................................................................... 199
5-43 Swap Bytes in a Register ................................................................................................ 199
5-44 Rotate Left Arithmetically—RLAM[.W] and RLAM.A ................................................................. 226
5-45 Destination Operand-Arithmetic Shift Left ............................................................................. 227
5-46 Destination Operand-Carry Left Shift .................................................................................. 228
5-47 Rotate Right Arithmetically RRAM[.W] and RRAM.A ................................................................ 229
5-48 Rotate Right Arithmetically RRAX(.B,.A) – Register Mode .......................................................... 231
5-49 Rotate Right Arithmetically RRAX(.B,.A) – Non-Register Mode .................................................... 231
5-50 Rotate Right Through Carry RRCM[.W] and RRCM.A .............................................................. 232
5-51 Rotate Right Through Carry RRCX(.B,.A) – Register Mode ........................................................ 234
5-52 Rotate Right Through Carry RRCX(.B,.A) – Non-Register Mode .................................................. 234
5-53 Rotate Right Unsigned RRUM[.W] and RRUM.A..................................................................... 235
5-54 Rotate Right Unsigned RRUX(.B,.A) – Register Mode .............................................................. 236
5-55 Swap Bytes SWPBX.A Register Mode ................................................................................ 240
5-56 Swap Bytes SWPBX.A In Memory ..................................................................................... 240
5-57 Swap Bytes SWPBX[.W] Register Mode .............................................................................. 241
5-58 Swap Bytes SWPBX[.W] In Memory ................................................................................... 241
5-59 Sign Extend SXTX.A ..................................................................................................... 242
5-60 Sign Extend SXTX[.W] ................................................................................................... 242
6-1 Flash Memory Module Block Diagram ................................................................................. 260
6-2 256-KB Flash Memory Segments Example ........................................................................... 261
6-3 Erase Cycle Timing ....................................................................................................... 264
6-4 Erase Cycle From Flash ................................................................................................. 265
6-5 Erase Cycle From RAM .................................................................................................. 266
6-6 Byte/Word/Long-Word Write Timing.................................................................................... 267
6-7 Initiating a Byte/Word Write From Flash ............................................................................... 268
6-8 Initiating a Byte/Word Write From RAM ............................................................................... 269
6-9 Initiating Long-Word Write From Flash ................................................................................ 270
6-10 Initiating Long-Word Write from RAM .................................................................................. 271
6-11 Block-Write Cycle Timing ................................................................................................ 272
6-12 Block Write Flow .......................................................................................................... 273
6-13 User-Developed Programming Solution ............................................................................... 276
10-1 DMA Controller Block Diagram ......................................................................................... 307
10-2 DMA Addressing Modes ................................................................................................. 308
10-3 DMA Single Transfer State Diagram ................................................................................... 310
10-4 DMA Block Transfer State Diagram .................................................................................... 311
10-5 DMA Burst-Block Transfer State Diagram ............................................................................. 313
11-1 MPY32 Block Diagram ................................................................................................... 331
11-2 Q15 Format Representation ............................................................................................. 336
11-3 Q14 Format Representation ............................................................................................. 337
11-4 Saturation Flow Chart .................................................................................................... 339
11-5 Multiplication Flow Chart ................................................................................................. 341
12-1 LFSR Implementation of CRC-CCITT Standard, Bit 0 is the MSB of the Result ................................. 350
12-2 Implementation of CRC-CCITT using the CRCDI and CRCINIRES registers .................................... 352
www.ti.com
www.ti.com
www.ti.com
List of Tables
1-1 Interrupt Sources, Flags, and Vectors ................................................................................... 28
1-2 Connection of Unused Pins ............................................................................................... 36
1-3 Tag Values .................................................................................................................. 40
1-4 Peripheral Discovery Descriptor .......................................................................................... 40
1-5 Values for Memory Entry .................................................................................................. 41
1-6 Values for Peripheral Entry ............................................................................................... 42
1-7 Peripheral IDs ............................................................................................................... 42
1-8 Sample Peripheral Discovery Descriptor ................................................................................ 43
1-9 SFR Base Address ......................................................................................................... 44
1-10 Special Function Registers................................................................................................ 44
1-14 SYS Base Address ......................................................................................................... 48
1-15 SYS Configuration Registers ............................................................................................. 48
2-1 Watchdog Timer Registers ................................................................................................ 62
3-1 Unified Clock System Registers .......................................................................................... 78
4-1 SVS/SVM Thresholds ...................................................................................................... 90
4-2 PMM Voltage Reference per Operational Mode ....................................................................... 96
4-3 SVS/SVM Performance Control Modes -- Manual ..................................................................... 97
4-4 SVS/SVM Performance Control Modes -- Automatic .................................................................. 97
4-5 PMM Registers ............................................................................................................. 98
5-1 SR Bit Description ........................................................................................................ 111
5-2 Values of Constant Generators CG1, CG2............................................................................ 112
5-3 Source/Destination Addressing ......................................................................................... 115
5-4 MSP430 Double-Operand Instructions................................................................................. 134
5-5 MSP430 Single-Operand Instructions .................................................................................. 134
5-6 Conditional Jump Instructions ........................................................................................... 135
5-7 Emulated Instructions .................................................................................................... 135
5-8 Interrupt, Return, and Reset Cycles and Length ..................................................................... 136
5-9 MSP430 Format II Instruction Cycles and Length .................................................................... 136
5-10 MSP430 Format I Instructions Cycles and Length ................................................................... 137
5-11 Description of the Extension Word Bits for Register Mode.......................................................... 138
5-12 Description of Extension Word Bits for Non-Register Modes ....................................................... 139
5-13 Extended Double-Operand Instructions................................................................................ 140
5-14 Extended Single-Operand Instructions................................................................................. 142
5-15 Extended Emulated Instructions ........................................................................................ 144
5-16 Address Instructions, Operate on 20-Bit Register Data ............................................................. 145
5-17 MSP430X Format II Instruction Cycles and Length .................................................................. 146
5-18 MSP430X Format I Instruction Cycles and Length ................................................................... 147
5-19 Address Instruction Cycles and Length ................................................................................ 148
5-20 Instruction Map of MSP430X ............................................................................................ 149
6-1 Erase Modes .............................................................................................................. 263
6-2 Write Modes ............................................................................................................... 267
6-3 Flash Access While Flash is Dusy (BUSY = 1) ....................................................................... 274
6-4 Flash Controller Registers ............................................................................................... 277
7-1 RAMCTL Module Register ............................................................................................... 283
8-1 I/O Configuration .......................................................................................................... 287
8-2 Digital I/O Registers ...................................................................................................... 291
9-1 Examples for Port Mapping Mnemonics and Functions ............................................................. 299
9-2 Port Mapping Control Registers ........................................................................................ 302
9-3 Port Mapping Registers for Port Px – Byte Access .................................................................. 302
www.ti.com
9-4 Port Mapping Registers for Port Px – Word Access ................................................................. 302
10-1 DMA Transfer Modes..................................................................................................... 309
10-2 DMA Trigger Operation .................................................................................................. 315
10-3 Maximum Single-Transfer DMA Cycle Time .......................................................................... 316
10-4 DMA Registers ............................................................................................................ 319
11-1 Result Availability (MPYFRAC = 0, MPYSAT = 0) ................................................................... 332
11-2 OP1 Registers ............................................................................................................. 334
11-3 OP2 Registers ............................................................................................................. 334
11-4 SUMEXT and MPYC Contents.......................................................................................... 335
11-5 Result Availability in Fractional Mode (MPYFRAC = 1, MPYSAT = 0) ............................................ 337
11-6 Result Availability in Saturation Mode (MPYSAT = 1) ............................................................... 338
11-7 MPY32 Registers ......................................................................................................... 345
11-8 Alternative Registers ..................................................................................................... 347
12-1 CRC Module Registers................................................................................................... 354
13-1 AES Accelerator Registers .............................................................................................. 364
14-1 Timer Modes .............................................................................................................. 372
14-2 Output Modes ............................................................................................................. 378
14-3 Timer_A Registers ........................................................................................................ 384
15-1 Real-Time Clock Registers .............................................................................................. 397
16-1 Receive Error Conditions ................................................................................................ 418
16-2 BITCLK Modulation Pattern ............................................................................................. 420
16-3 BITCLK16 Modulation Pattern .......................................................................................... 421
16-4 Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 0 ................................................. 424
16-5 Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 1 ................................................. 426
16-6 USCI_Ax Registers ....................................................................................................... 429
17-1 UCxSTE Operation ....................................................................................................... 441
17-2 USCI_Ax Registers ....................................................................................................... 446
17-3 USCI_Bx Registers ....................................................................................................... 446
18-1 I2C State Change Interrupt Flags ....................................................................................... 471
18-2 USCI_Bx Registers ....................................................................................................... 473
19-1 One-Byte Auto-Read Registers ......................................................................................... 487
19-2 Two-Byte/One-Word Auto-Read Registers ............................................................................ 487
19-3 Radio Interface Error Conditions........................................................................................ 488
19-4 Radio Interface Interrupt Flags .......................................................................................... 489
19-5 CC1101 Radio Core Interrupt Mapping ................................................................................ 490
19-6 CC1101-Based Radio Core Instruction Set – Command Strobes.................................................. 495
19-7 CC1101-Based Radio Core Instruction Set ........................................................................... 496
19-8 Radio Core Status Byte Summary...................................................................................... 497
19-9 Data Rate Step Size ...................................................................................................... 498
19-10 Channel Filter Bandwidths (kHz) (Assuming a 26-MHz Crystal) .................................................. 498
19-11 Received Packet Status Byte 1 (First Byte Appended After Data) ................................................. 500
19-12 Received Packet Status Byte 2 (Second Byte Appended After Data) ............................................. 500
19-13 Symbol Encoding for 2-FSK/2-GFSK Modulation .................................................................... 505
19-14 Sync Word Qualifier Mode ............................................................................................... 506
19-15 Typical RSSI_offset Values ............................................................................................. 507
19-16 Typical RSSI Value in dBm at CS Threshold With Default MAGN_TARGET at 2.4 kBaud, 868 MHz ........ 509
19-17 Typical RSSI Value in dBm at CS Threshold With Default MAGN_TARGET at 250 kBaud, 868 MHz ....... 510
19-18 State Transition Timing .................................................................................................. 514
19-19 FIFO_THR Settings and the Corresponding FIFO Thresholds ..................................................... 515
19-20 Configuration Registers .................................................................................................. 523
19-21 Status Registers .......................................................................................................... 524
www.ti.com
Preface
SLAU259 – May 2009
FCC Warning
This equipment is intended for use in a laboratory test environment only. It generates, uses, and can
radiate radio frequency energy and has not been tested for compliance with the limits of computing
devices pursuant to subpart J of part 15 of FCC rules, which are designed to provide reasonable
protection against radio frequency interference. Operation of this equipment in other environments may
cause interference with radio communications, in which case the user at his own expense will be required
to take whatever measures may be required to correct this interference.
Notational Conventions
Program examples, are shown in a special typeface.
Glossary
ACLK Auxiliary Clock
ADC Analog-to-Digital Converter
BOR Brown-Out Reset; see System Resets, Interrupts, and Operating Modes
BSL Bootstrap Loader; see www.ti.com/msp430 for application reports
CPU Central Processing Unit See RISC 16-Bit CPU
DAC Digital-to-Analog Converter
DCO Digitally Controlled Oscillator; see FLL+ Module
dst Destination; see RISC 16-Bit CPU
FLL Frequency Locked Loop; see FLL+ Module
GIE Modes General Interrupt Enable; see System Resets Interrupts and Operating
INT(N/2) Integer portion of N/2
I/O Input/Output; see Digital I/O
ISR Interrupt Service Routine
www.ti.com
Chapter 1
SLAU259 – May 2009
The system control module (SYS) is available on all devices. The following list shows the basic feature set
of SYS.
• Brownout reset/power on reset (BOR/POR) handling
• Power up clear (PUC) handling
• (Non)maskable interrupt (SNMI/UNMI) event source selection and management
• Address decoding
• Providing an user data-exchange mechanism via the JTAG mailbox (JMB)
• Bootstrap loader (BSL) entry mechanism
• Configuration management (device descriptors)
• Providing interrupt vector generators for reset and NMIs
• Watchdog timer (WDT_A)
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 21
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Note: The number and type of resets available may vary from device to device. See the
device-specific data sheet for all reset sources available.
22 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
BOR shadow
s
Delay
brownout circuit
SVMHVLRIFG
s
from SVMH
SVMHVLRPE
SVMHLVLRIFG
s
from SVML
SVMLVLRPE
PMMPORIFG
s
PMMSWPOR event
WDTIFG
s
Watchdog Timer MCLK Module
PUCs
… .
PUC Logic
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 23
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Interrupts www.ti.com
1.3 Interrupts
The interrupt priorities are fixed and defined by the arrangement of the modules in the connection chain as
shown in Figure 1-2. 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
• Maskable
BOR
RST/NMI CPU
BOR/POR/PUC POR
...
circuit PUC
KEYV
daisy chain
and vectors
Note: The types of Interrupt sources available and their respective priorities can change from
device to device. Please see the device specific datasheet for all interrupt sources and their
priorities.
24 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
www.ti.com Interrupts
1.3.1 (Non)Maskable Interrupts (NMIs)
In general, NMIs are not masked by the general interrupt enable (GIE) bit. The family supports two levels
of NMIs — system NMI (SNMI) and user NMI (UNMI). The NMI sources are enabled by individual interrupt
enable bits. When an NMI interrupt is accepted, other NMIs of that level are automatically disabled to
prevent nesting of consecutive NMIs of the same level. Program execution begins at the address stored in
the NMI vector as shown in Table 1-1. To allow software backward compatibility to users of earlier
MSP430 families, the software may, but does not need to, reenable NMI sources. The block diagram for
NMI sources is shown in Figure 1-3.
A UNMI interrupt can be generated by following sources:
• An edge on the RST/NMI pin when configured in NMI mode
• An oscillator fault occurs
• An access violation to the flash memory
A SNMI interrupt can be generated by following sources:
• Power Management Module (PMM) SVML/SVMH supply voltage fault
• PMM high/low side delay expiration
• Vacant memory access
• JTAG mailbox (JMB) event
Note: The number and types of NMI sources may vary from device to device. See the
device-specific data sheet for all NMI sources available.
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 25
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Interrupts www.ti.com
ACCV ACCVIFG
User NMI
ACCVIE _IRQA
PUC
RETI
NMI NMIIFG R
NMIIE S
User NMI
… ..
...IFG
...IE
OFIE
SVML SVMLIFG
System NMI
SVMLIE _IRQA
PUC
Del. FF RETI
SVMH SVMHIFG R
SVMHIE S
System NMI
… ..
...IFG
...IE
SYSJMBIE
26 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
www.ti.com Interrupts
1.3.3 Maskable Interrupts
Maskable interrupts are caused by peripherals with interrupt capability. Each maskable interrupt source
can be disabled individually by an interrupt enable bit, or all maskable interrupts can be disabled by the
general interrupt enable (GIE) bit in the status register (SR).
Each individual peripheral interrupt is discussed in its respective module chapter in this manual.
Interrupt Processing
When an interrupt is requested from a peripheral and the peripheral interrupt enable bit and GIE bit are
set, the interrupt service routine is requested. Only the individual enable bit must be set for
(non)-maskable interrupts (NMI) to be requested.
Interrupt Acceptance
The interrupt latency is six cycles, starting with the acceptance of an interrupt request, and lasting until the
start of execution of the first instruction of the interrupt service routine, as shown in Figure 1-4. The
interrupt logic executes the following:
1. Any currently executing instruction is completed.
2. The PC, which points to the next instruction, is pushed onto the stack.
3. The SR is pushed onto the stack.
4. The interrupt with the highest priority is selected if multiple interrupts occurred during the last
instruction and are pending for service.
5. The interrupt request flag resets automatically on single-source flags. Multiple source flags remain set
for servicing by software.
6. The SR is cleared. This terminates any low-power mode. Because the GIE bit is cleared, further
interrupts are disabled.
7. The content of the interrupt vector is loaded into the PC; the program continues with the interrupt
service routine at that address.
Before After
Interrupt Interrupt
Item1 Item1
SP Item2 TOS Item2
PC
SP SR TOS
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 27
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Interrupts www.ti.com
The return from the interrupt takes five cycles to execute the following actions and is illustrated in
Figure 1-5.
1. The SR with all previous settings pops from the stack. All previous settings of GIE, CPUOFF, etc. are
now in effect, regardless of the settings used during the interrupt service routine.
2. The PC pops from the stack and begins execution at the point where it was interrupted.
Before After
Return From Interrupt
Item1 Item1
Item2 SP Item2 TOS
PC PC
SP SR TOS SR
Some interrupt enable bits, and interrupt flags, as well as, control bits for the RST/NMI pin are located in
the special function registers (SFR). The SFR are located in the peripheral address range and are byte
and word accessible. See the device-specific data sheet for the SFR configuration.
28 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
www.ti.com Interrupts
Alternate Interrupt Vectors
It is possible to use the RAM as an alternate location for the interrupt vector locations. Setting the
SYSRIVECT bit in SYSCTL causes the interrupt vectors to be remapped to the top of RAM. Once set, any
interrupt vectors to the alternate location now residing in RAM. Because SYSRIVECT is automatically
cleared on a BOR, it is critical that the reset vector at location 0FFFEh still be available and handled
properly in firmware.
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 29
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Interrupts www.ti.com
30 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 31
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
WDT Active
Time expired, Overflow
CPUOFF=1
OSCOFF=0 Active Mode: CPU is Active PMMREGOFF = 1
SCG0=0 to LPM5
Various Modules are active
SCG1=0
LPM0: †
CPU/MCLK = off †
FLL = on
ACLK = on †
VCORE = on †
† LPM4:
CPUOFF=1 CPUOFF=1 CPU/MCLK = off
OSCOFF=0 OSCOFF=1 FLL = off
SCG0=1 SCG0=1 ACLK = off
CPUOFF=1 CPUOFF=1 SCG1=1 VCORE = on
SCG1=0
OSCOFF=0 OSCOFF=0
LPM1: SCG0=0 SCG0=1
CPU/MCLK = off SCG1=1 SCG1=1
FLL = off LPM3:
ACLK = on CPU/MCLK = off
LPM2: FLL = off
VCORE = on CPU/MCLK = off ACLK = on
FLL = off VCORE = on
ACLK = on
VCORE = on
Events
32 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 33
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
34 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 35
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
(1)
The pulldown capacitor should 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.
36 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
This memory map represents the MSP430F5438 device. Though the address ranges differs from device
to device, overall behavior remains the same.
Can generate NMI on read/write/fetch
Generates PUC on fetch access
Protectable for read/write accesses
Always able to access PMM registers from (1); Mass erase by user possible
Mass erase by user possible
Bank erase by user possible
Segment erase by user possible
(1)
Access rights are separately programmable for SYS and PMM.
(2)
Fixed ID for all MSP430 devices. See Section 1.11.1 for further details.
(3)
On vacant memory space, the value 03FFFh is driven on the data bus.
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 37
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
38 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
CRC_length
Information block
CRC_value
DeviceID
Hardware revision
Tag 1
Len 1
First TLV entry
Value field 1
(optional)
Tag N
Len N
Final TLV entry
Value field N
(optional)
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 39
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
The length field is one byte if the tag value is 01h through 0FDh and represents the length of the
descriptor in bytes. If the tag value equals 0FEh, the next byte extends the tag values, and the following
two bytes represent the length of the descriptor in bytes.
40 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
struct peripheral_entry {
PID :8; //bits 15..8
UnitSize :1; //bit 7
AdrVal :7; //bits 6..0
}
Table 1-5 and Table 1-6 show the values that each element inside a memory and peripheral entry can
take, respectively.
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 41
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
42 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 43
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
44 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
JMBOUTIE JMBINIE ACCVIE NMIIE VMAIE Reserved OFIE WDTIE
rw-0 rw-0 rw-0 rw-0 rw-0 r0 rw-0 rw-0
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 45
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
JMBOUTIFG JMBINIFG Reserved NMIIFG VMAIFG Reserved OFIFG WDTIFG
rw-(1) rw-(0) r0 rw-0 rw-0 r0 rw-(1) rw-0
46 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
Reserved Reserved Reserved Reserved SYSRSTRE (1) SYSRSTUP (1)
SYSNMIIES SYSNMI
r0 r0 r0 r0 rw-1 rw-1 rw-0 rw-0
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 47
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
48 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
Reserved Reserved SYSJTAGPIN SYSBSLIND Reserved SYSPMMPE Reserved SYSRIVECT
r0 r0 rw-[0] r-0 r0 rw-[0] r0 rw-[0]
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 49
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
Reserved Reserved Reserved Reserved Reserved SYSBSLR SYSBSLSIZE
r0 r0 r0 r0 r0 rw-[0] rw-[1] rw-[1]
SYSBSLPE Bits 15-7 Bootstrap loader memory protection enable for the size covered in SYSBSLSIZE
0 Area not protected read, program and erase of memory is possible.
1 Area protected
SYSBSLOFF Bits 14-6 Bootstrap loader memory disable for the size covered in SYSBSLSIZE
0 BSL memory is addressed when this area is read.
1 BSL memory behaves like vacant memory.
Reserved Bits 13-3 Reserved. Reads back 0.
SYSBSLR Bit 2 RAM assigned to BSL
0 No RAM assigned to BSL area
1 Lowest 16 bytes of RAM assigned to BSL
SYSBSLSIZE Bits 1-0 Bootstrap loader size. Defines the space and size of flash that is reserved for the BSL.
00 Size: 512B BSL_SEG_3
01 Size: 1024B BSL_SEG_2,3
10 Size: 1536B BSL_SEG_1,2,3
11 Size: 2048B BSL_SEG_0,1,2,3 (value after BOR)
50 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
JMBCLR10FF JMBCLR0OFF Reserved JMBM0DE JMBOUT1FG JMBOUT0FG JMBIN1FG JMBIN0FG
rw-(0) rw-(0) r0 rw-0 r-(1) r-(1) rw-(0) rw-(0)
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 51
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
MSGL0
r-0 r-0 r-0 r-0 r-0 r-0 r-0 r-0
7 6 5 4 3 2 1 0
MSGL0
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
0 0 0 SYSUNVEC 0
r0 r0 r0 r-0 r-0 r-0 r-0 r0
SYSUNIV Bits 15-0 User NMI vector. Generates a value that can be used as address offset for fast interrupt service
routine handling. Writing to this register clears all pending user NMI flags.
Note: Additional events for more complex devices will be appended to this table; sources that are
removed will reduce the length of this table. The vectors are expected to be accessed
symbolic only with the corresponding include file of the device in use.
52 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
0 0 0 SYSSNVEC 0
r0 r0 r0 r-0 r-0 r-0 r-0 r0
SYSSNIV Bits 15-0 System NMI vector. Generates a value that can be used as address offset for fast interrupt service
routine handling. Writing to this register clears all pending system NMI flags.
Note: Additional events for more complex devices will be appended to this table; sources that are
removed will reduce the length of this table. The vectors are expected to be accessed
symbolic only with the corresponding include file of the used device.
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 53
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
0 0 SYSRSTVEC 0
r0 r0 r-0 r-0 r-0 r-0 r-0 r0
SYSRSTIV Bits 15-0 Reset interrupt vector. Generates a value that can be used as address offset for fast interrupt
service routine handling to identify the last cause of a reset (BOR, POR, PUC) . Writing to this
register clears all pending reset source flags.
Note: Additional events for more complex devices will be appended to this table; sources that are
removed will reduce the length of this table. The vectors are expected to be accessed
symbolic only with the corresponding include file of the used device.
54 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
0 0 0 SYSBERRIV 0
r0 r0 r0 r-0 r-0 r-0 r-0 r0
SYSBERRIV Bits 15-0 System bus error interrupt vector. Generates a value that can be used as an address offset for fast
interrupt service routine handling. Writing to this register clears all pending flags.
Note: Additional events for more complex devices will be appended to this table; sources that are
removed will reduce the length of this table. The vectors are expected to be accessed
symbolic only with the corresponding include file of the used device.
SLAU259 – May 2009 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) 55
Submit Documentation Feedback
56 System Resets, Interrupts, and Operating Modes, System Control Module (SYS) SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Chapter 2
SLAU259 – May 2009
The watchdog timer is a 32-bit timer that can be used as a watchdog or as an interval timer. This chapter
describes the watchdog timer. The enhanced watchdog timer, WDT_A, is implemented in all devices.
SMCLK 00
ACLK 01
VLOCLK 10
X_CLK 11
WDTHOLD
WDTSSEL1
WDTSSEL0
WDTTMSEL
WDTCNTCL
WDTIS2
WDTIS1
WDTIS0 LSB
X_CLK request
Clock SMCLK request
Request
Logic ACLK request
VLOCLK request
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
7 6 5 4 3 2 1 0
Read as 069h
WDTPW, must be written as 05Ah
7 6 5 4 3 2 1 0
WDTHOLD WDTSSEL WDTTMSEL WDTCNTCL WDTIS
rw-0 rw-0 rw-0 rw-0 r0(w) rw-1 rw-0 rw-0
WDTPW Bits 15-8 Watchdog timer password. Always read as 069h. Must be written as 05Ah, or a PUC is generated.
WDTHOLD Bit 7 Watchdog timer hold. This bit stops the watchdog timer. Setting WDTHOLD = 1 when the WDT is not in use
conserves power.
0 Watchdog timer is not stopped.
1 Watchdog timer is stopped.
WDTSSEL Bits 6-5 Watchdog timer clock source select
00 SMCLK
01 ACLK
10 VLOCLK
11 X_CLK , same as VLOCLK if not defined differently in data sheet
WDTTMSEL Bit 4 Watchdog timer mode select
0 Watchdog mode
1 Interval timer mode
WDTCNTL Bit 3 Watchdog timer counter clear. Setting WDTCNTCL = 1 clears the count value to 0000h. WDTCNTCL is
automatically reset.
0 No action
1 WDTCNT = 0000h
WDTIS Bits 2-0 Watchdog timer interval select. These bits select the watchdog timer interval to set the WDTIFG flag and/or
generate a PUC.
000 Watchdog clock source /2G (18:12:16 at 32 kHz)
001 Watchdog clock source /128M (01:08:16 at 32 kHz
010 Watchdog clock source /8192k (00:04:16 at 32 kHz)
011 Watchdog clock source /512k (00:00:16 at 32 kHz)
100 Watchdog clock source /32k (1 s at 32 kHz)
101 Watchdog clock source /8192 (250 ms at 32 kHz)
110 Watchdog clock source /512 (15,6 ms at 32 kHz)
111 Watchdog clock source /64 (1.95 ms at 32 kHz)
Chapter 3
SLAU259 – May 2009
The Unified Clock System (UCS) module provides the various clocks for a device. This chapter describes
the operation of the UCS module, which is implemented in all devices.
ACLK_REQEN
ACLK_REQ
SELA OSCOFF
3
Oscillator
XT1 Fault ACLK Enable Logic
XT1BYPASS Detection
DIVPA
EN
3 3
1 XT1CLK ACLK/n
000 Divider
0 DIVA /1/2/4/8/16/32
001
VLOCLK 3
VLO 010
Divider
011 0 ACLK
/1/2/4/8/16/32
REFOCLK 100
REFO 1
101
110
XT1 111
XIN 0V
LF MCLK_REQEN
MCLK_REQ
0V SELREF
XOUT
3
SELM CPUOFF
2 2
000 3
XCAP XT1DRIVE
001
010
MCLK Enable Logic
FLLREFCLK 011
FLL FLLREFDIV EN
100
101 3
3 SCG0 PUC
Divider 110 000
111 001 DIVM
/1/2/4/8/12/16 off Reset 3
+ 010
011 Divider
10-bit /1/2/4/8/16/32 0 MCLK
FLLN Frequency 100
10
Integrator 101 1
Divider −
/(N+1) 110
SCG1 DCORSELDISMOD DCO, 111
3 10 MOD
off DCO SMCLK_REQEN
DC + SMCLK_REQ
Generator Modulator
FLLD SELS SMCLKOFF
3 3
DCOCLK
Prescaler
/1/2/4/8/16/32 SMCLK Enable Logic
DCOCLKDIV
EN
3
000
001 DIVS
3
010
XT2 Oscillator 011 Divider
/1/2/4/8/16/32 0 SMCLK
100
XT2CLK 1
101
110
Fault
Detection 111
XT2OFF
MODOSC_REQEN
RF_XIN
XT2
to Radio MODOSC_REQ
Unconditonal MODOSC
RF_XOUT RF Oscillator requests
.
EN MODCLK
MODOSC
Five of the integrator bits (UCSCTL0 bits 12 to 8) set the DCO frequency tap. Thirty-two taps are
implemented for the DCO, and each is approximately 8% higher than the previous. The modulator mixes
two adjacent DCO frequencies to produce fractional taps.
For a given DCO bias range setting, time must be allowed for the DCO to settle on the proper tap for
normal operation. (n × 32) fFLLREFCLK cycles are required between taps requiring a worst case of
(n × 32 × 32) fFLLREFCLK cycles for the DCO to settle. The value n is defined by the FLLREFDIV bits (n = 1,
2, 4, 8, 12, or 16).
31
24
16
15
2
Lower DCO Tap Frequency fDCO Upper DCO Tap Frequency fDCO+1
SMCLK_REQ 0
0
MCLK_REQ
0 0
ACLK_REQ
SMCLK
MCLK
ACLK
WDTACLKON WDTSMCLKON
Direct clock request
in Watchdog mode Watch Dog Timer Module
The OFIFG oscillator-fault interrupt flag is set and latched at POR or when any oscillator fault
(XT1LFOFFG, XT1HFOFFG, XT2OFFG, or DCOFFG) is detected. When OFIFG is set and OFIE is set,
the OFIFG requests an NMI. When the interrupt is granted, the OFIE is not reset automatically as it is in
previous MSP430 families. It is no longer required to reset the OFIE. NMI entry/exit circuitry removes this
requirement. The OFIFG flag must be cleared by software. The source of the fault can be identified by
checking the individual fault bits.
If a fault is detected for the oscillator sourcing MCLK, MCLK is automatically switched to the DCO for its
clock source (DCOCLKDIV) for all clock sources except XT1 LF mode. If MCLK is sourced from XT1 in LF
mode, an oscillator fault causes MCLK to be automatically switched to the REFO for its clock source
(REFOCLK). This does not change the SELM bit settings. This condition must be handled by user
software.
If a fault is detected for the oscillator sourcing SMCLK, SMCLK is automatically switched to the DCO for
its clock source (DCOCLKDIV) for all clock sources except XT1 LF mode. If SMCLK is sourced from XT1
in LF mode, an oscillator fault causes SMCLK to be automatically switched to the REFO for its clock
source (REFOCLK). This does not change the SELS bit settings. This condition must be handled by user
software.
If a fault is detected for the oscillator sourcing ACLK, ACLK is automatically switched to the DCO for its
clock source (DCOCLKDIV) for all clock sources except XT1 LF mode. If ACLK is sourced from XT1 in LF
mode, an oscillator fault causes ACLK to be automatically switched to the REFO for its clock source
(REFOCLK). This does not change the SELA bit settings. This condition must be handled by user
software.
DCO _ Fault
S S DCO _ OF
Q Q
DCOFFG
R R R
POR
XT 1 _ LF _ OscFault
S S XT 1 _ LFOF
Q Q
XT 1 LFOFFG
R R R
XT 1 _ HF _ OscFault
S S XT 1 _ HFOF
Q Q
XT 1 HFOFFG
R R R
XT 2 _ OscFault
S S XT 2 _ OF
Q Q
XT 2 OFFG
OscFault_Set
R R R S OFIFG
Q NMIRS
OscFault_Clr
S OFIE
Q
R R
PUC
NMI _ IRQA
DCOCLK
ACLK
MCLK
Wait for
DCOCLK ACLK
ACLK
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
7 6 5 4 3 2 1 0
Reserved DCO
r0 r0 r0 rw-0 rw-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
MOD Reserved
rw-0 rw-0 rw-0 rw-0 rw-0 r0 r0 r0
7 6 5 4 3 2 1 0
Reserved
r0 r0 r0 r0 r0 r0 r0 r0
7 6 5 4 3 2 1 0
Reserved DCORSEL Reserved Reserved DISMOD
r0 rw-0 rw-1 rw-0 r0 r0 rw-0 rw-0
7 6 5 4 3 2 1 0
Reserved FLLD Reserved FLLN
r0 rw-0 rw-0 rw-1 r0 r0 rw-0 rw-0
7 6 5 4 3 2 1 0
FLLN
rw-0 rw-0 rw-0 rw-1 rw-1 rw-1 rw-1 rw-1
7 6 5 4 3 2 1 0
Reserved
r0 r0 r0 r0 r0 r0 r0 r0
7 6 5 4 3 2 1 0
Reserved SELREF Reserved FLLREFDIV
r0 rw-0 rw-0 rw-0 r0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
Reserved SELA
r0 r0 r0 r0 r0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
Reserved SELS Reserved SELM
r0 rw-1 rw-0 rw-0 r0 rw-1 rw-0 rw-0
7 6 5 4 3 2 1 0
Reserved DIVPA Reserved DIVA
r0 rw-0 rw-0 rw-0 r0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
Reserved DIVS Reserved DIVM
r0 rw-0 rw-0 rw-0 r0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
Reserved XT2OFF
r0 r0 r0 r0 r0 r0 r0 rw-1
7 6 5 4 3 2 1 0
XT1DRIVE XTS XT1BYPASS XCAP SMCLKOFF XT1OFF
rw-1 rw-1 rw-0 rw-0 rw-1 rw-1 rw-0 rw-1
7 6 5 4 3 2 1 0
Reserved Reserved Reserved Reserved Reserved
r0 r0 rw-0 rw-(0) rw-(1) rw-(1) r-1 r-1
7 6 5 4 3 2 1 0
Reserved Reserved XT2OFFG XT1HFOFFG XT1LFOFFG DCOFFG
r0 r0 r0 rw-(0) rw-(0) rw-(0) rw-(1) rw-(1)
7 6 5 4 3 2 1 0
Reserved Reserved
r0 r0 r0 r0 r0 rw-(1) rw-(1) rw-(1)
7 6 5 4 3 2 1 0
MODOSC
Reserved Reserved SMCLKREQEN MCLKREQEN ACLKREQEN
REQEN
r0 r0 r0 rw-(0) rw-(0) rw-(1) rw-(1) rw-(1)
Chapter 4
SLAU259 – May 2009
This chapter describes the operation of the Power Management Module (PMM) and
Supply Voltage Supervisor (SVS).
SLAU259 – May 2009 Power Management Module and Supply Voltage Supervisor 87
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
25
20
16
12
DVCC > 1.8 V
The PMM module provides a means for DVCC and VCORE to be supervised and monitored. Both of these
functions detect when a voltage falls under a specific threshold. In general, the difference is that
supervision results in a power-on reset (POR) event, while monitoring results in the generation of an
interrupt flag that software may then handle. As such, DVCC is supervised and monitored by the high-side
supervisor (SVSH) and high-side monitor (SVMH), respectively. VCORE is supervised and monitored by the
low-side supervisor (SVSL) and low-side monitor (SVML), respectively. Thus, there are four separate
supervision/monitoring modules that can be active at any given time. The thresholds enforced by these
modules are derived from the same voltage reference used by the regulator to generate VCORE.
88 Power Management Module and Supply Voltage Supervisor SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SVSH SVSL
Reference BOR To reset logic
SVMH SVML
SLAU259 – May 2009 Power Management Module and Supply Voltage Supervisor 89
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SVS/SVM Thresholds
The voltage thresholds enforced by the SVS/SVM modules are selectable. Table 4-1 shows the SVS/SVM
threshold registers, the voltage threshold they control, and the number of threshold options.
The high-side thresholds support various thresholds within the DVCC range. These should be selected
according to the minimum voltages required for device operation in a given application, as well as system
power supply characteristics. See the device-specific data sheet for threshold values corresponding to the
settings shown here.
The low-side threshold options are designed to support the associated VCORE values, such that SVSLRVL
and SVSMLRRL should always be set to a value equal to PMMCOREV.
90 Power Management Module and Supply Voltage Supervisor SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
DVCC
SVMH,SVSH_IT+
SVSH_IT-
VCORE
SVML,SVSL_IT+
SVSL_IT-
Set SVMHIFG
Set SVMHVLRIFG
Set SVSHIFG
Set SVMLIFG
Set SVMLVLRIFG
Set SVSLIFG
POR
Time
Figure 4-3. High-Side and Low-Side Voltage Failure and Resulting PMM Actions
SLAU259 – May 2009 Power Management Module and Supply Voltage Supervisor 91
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
0 Set POR
1
SVMHIE
SVMH Interrupt
Set SVMHIFG
IFG
SVMHFP
SVMH
SVMHE ON Set SVMHVLRIFG
IFG
SVSHFP
SVSH
Set SVSHIFG
ON
If DVCC falls below the SVSH level, SVSHIFG (SVSH interrupt flag) is set. If DVCC remains below the SVSH
level and software attempts to clear SVSHIFG, it is immediately set again by hardware. If the SVSHPE
(SVSH POR enable) bit is set when SVSHIFG gets set, a POR is generated.
If DVCC falls below the SVMH level, SVMHIFG (SVMH interrupt flag) is set. If DVCC remains below the
SVMH level and software attempts to clear SVMHIFG, it is immediately set again by hardware. If the
SVMHIE (SVMH interrupt enable) bit is set when SVMHIFG gets set, an interrupt is generated. If a POR is
desired when SVMHIFG is set, the SVMH can be configured to do so by setting the SVMHVLRPE (SVMH
voltage level reached POR enable) bit while SVMHOVPE bit is cleared.
If DVCC rises above the SVMH level, the SVMHVLRIFG (SVMH voltage level reached) interrupt flag is set.
If SVMHVLRIE (SVMH voltage level reached interrupt enable) is set when this occurs, an interrupt is also
generated.
The SVMH module can also be used for overvoltage detection. This is accomplished by setting the
SVMHOVPE (SVMH overvoltage POR enable) bit, in addition to setting SVMHVLRPE. Under these
conditions, if DVCC exceeds safe device operation, a POR is generated.
The SVSH/SVMH modules have configurable performance modes for power-saving operation. (See
Section 4.2.9 for more information.) If these SVSH/SVMH power modes are modified, or if a voltage level is
modified, a delay element masks the interrupts and POR sources until the SVSH/SVMH circuits have
settled. When the delay has completed, the SVSMHDLYIFG (SVSH/SVMH delay expired) interrupt flag is
set. If the SVSMHDLYIE (SVSH /SVMH delay expired interrupt enable) is set when this occurs, an interrupt
is also generated.
92 Power Management Module and Supply Voltage Supervisor SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
0 Set POR
1
SVMLIE
SVML Interrupt
Set SVMLIFG
IFG
SVMLFP
SVML
SVMLE ON Set SVMLVLRIFG
IFG
SVSLFP
SVSL
Set SVSLIFG
ON
If VCORE falls below the SVSL level, SVSLIFG (SVSL interrupt flag) is set. If VCORE remains below the SVSL
level and software attempts to clear SVSLIFG, it is immediately set again by hardware. If the SVSLPE
(SVSL POR enable) bit is set when SVSLIFG gets set, a POR is generated.
If VCORE falls below the SVML level, SVMLIFG (SVML interrupt flag) is set. If VCORE remains below the
SVML level and software attempts to clear SVMLIFG, it is immediately set again by hardware. If the
SVMLIE (SVML interrupt enable) bit is set when SVMLIFG gets set, an interrupt is generated. If a POR is
desired when SVMLIFG is set, the SVML can be configured to do so by setting the SVMLVLRPE (SVML
voltage level reached POR enable) bit while SVMLOVPE bit is cleared.
If VCORE rises above the SVML level, the SVMLVLRIFG (SVML voltage level reached) interrupt flag is set. If
SVMLVLRIE (SVML voltage level reached interrupt enable) is set when this occurs, an interrupt is also
generated.
The SVML module can also be used for overvoltage detection. This is accomplished by setting the
SVMLOVPE (SVML overvoltage POR enable) bit, in addition to setting SVMLVLRPE. Under these
conditions, if VCORE exceeds safe device operation, a POR is generated.
SLAU259 – May 2009 Power Management Module and Supply Voltage Supervisor 93
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
The SVSL/SVML modules have configurable performance modes for power-saving operation. (See
Section 4.2.9 for more information.) If these SVSL/SVML power modes are modified, or if a voltage level is
modified, a delay element masks the interrupts and POR sources until the SVSL/SVML circuits have
settled. When the delay has completed, the SVSMLDLYIFG (SVSL/SVML delay expired) interrupt flag is
set. If the SVSMLDLYIE (SVSL /SVML delay expired interrupt enable) is set when this occurs, an interrupt
is also generated.
All the interrupt flags remain set until cleared by a BOR or by software.
Voltage
DVCC
SVSH_IT+
VCORE
SVSL_IT+
POR
Time
After this point, both voltage domains are supervised and monitored while the respective modules are
enabled.
94 Power Management Module and Supply Voltage Supervisor SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Voltage
VCORE
SVML
6
1
3
4 5
SVSL
Time
It is critical that the VCORE level be increased by only one level at a time. The following steps 1 through 4
show the procedure to increase VCORE by one level. This sequence is repeated to change the VCORE level
until the targeted level is obtained:
1. Program the SVMH and SVSH to the next level to ensure DVCC is high enough for the next VCORE level.
Program the SVML to the next level and wait for (SVSMLDLYIFG) to be set.
2. Program PMMCOREV to the next VCORE level.
3. Wait for the voltage level reached (SVMLVLRIFG) flag.
4. Program the SVSL to the next level.
As a reference, the following is a C code example for increasing VCORE. The sample libraries provide
routines for increasing and decreasing the VCORE and should be utilized whenever possible.
; C Code example for increasing core voltage.
; Note: Change core voltage one level at a time.
SLAU259 – May 2009 Power Management Module and Supply Voltage Supervisor 95
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
4.2.6 LPM5
LPM5 is an additional low-power mode in which the regulator of the PMM is completely disabled, providing
additional power savings. Because there is no power supplied to VCORE during LPM5, the CPU and all
digital modules including RAM are unpowered. This essentially disables the entire device and, as a result,
the contents of the registers and RAM are lost. Any essential values should be stored to flash prior to
entering LPM5. See the SYS module for complete descriptions and usages of LPM5.
The application software can also manually select the mode by setting the voltage regulator current mode
bits (PMMCMD).
96 Power Management Module and Supply Voltage Supervisor SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Power Management Module and Supply Voltage Supervisor 97
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
98 Power Management Module and Supply Voltage Supervisor SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
PMMHPMRE Reserved PMMREGOFF PMMSWPOR PMMSWBOR PMMCOREV
rw-0 r-0 r-0 rw-0 rw-0 rw-0 rw-[0] rw-[0]
PMMPW Bits 15-8 PMM password. Always read as 096h. Must be written with 0A5h or a PUC is generated.
PMMHPMRE Bit 7 Global high power module request enable. If the PMMHPMRE bit is set, any module is able to request
the PMM high-power mode.
Reserved Bits 6-5 Reserved. Always read 0.
PMMREGOFF Bit 4 Regulator off (see SYS chapter for further details)
PMMSWPOR Bit 3 Software power-on reset. Setting this bit to 1 triggers a POR. This bit is self clearing.
PMMSWBOR Bit 2 Software brownout reset. Setting this bit to 1 triggers a BOR. This bit is self clearing.
PMMCOREV Bits 1-0 Core voltage (see the device-specific data sheet for supported levels and corresponding voltages)
00 VCORE level 0
01 VCORE level 1
10 VCORE level 2
11 VCORE level 3
7 6 5 4 3 2 1 0
Reserved PMMCMD Reserved Reserved PMMREFMD
r-0 r-0 rw-[0] rw-[0] r-0 r-0 rw-0 rw-0
SLAU259 – May 2009 Power Management Module and Supply Voltage Supervisor 99
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
SVSMHACE SVSMHEVM Reserved SVSHMD SVSMHDLYST SVSMHRRL
rw-[0] rw-0 r-0 rw-0 rw-0 rw-[0] rw-[0] rw-[0]
SVMHFP Bit 15 SVM high-side full-performance mode. If this bit is set, the SVMH operates in full-performance mode.
0 Normal mode. See the device-specific data sheet for response times.
1 Full-performance mode. See the device-specific data sheet for response times.
SVMHE Bit 14 SVM high-side enable. If this bit is set, the SVMH is enabled.
Reserved Bit 13 Reserved. Always read 0.
SVMHOVPE Bit 12 SVM high-side overvoltage enable. If this bit is set, the SVMH overvoltage detection is enabled. If
SVMHVLRPE is also set, a POR occurs on an overvoltage condition.
SVSHFP Bit 11 SVS high-side full-performance mode. If this bit is set, the SVSH operates in full-performance mode.
0 Normal mode. See the device-specific data sheet for response times.
1 Full-performance mode. See the device-specific data sheet for response times.
SVSHE Bit 10 SVS high-side enable. If this bit is set, the SVSH is enabled.
SVSHRVL Bits 9-8 SVS high-side reset voltage level. If DVCC falls short of the SVSH voltage level selected by SVSHRVL, a
reset is triggered (if SVSHPE = 1). The voltage levels are defined in the device-specific data sheet.
SVSMHACE Bit 7 SVS and SVM high-side automatic control enable. If this bit is set, the low-power mode of the SVSH and
SVMH circuits is under hardware control.
SVSMHEVM Bit 6 SVS and SVM high-side event mask. If this bit is set, the SVSH and SVMH events are masked.
0 No events are masked.
1 All events are masked.
Reserved Bit 5 Reserved. Always read 0.
SVSHMD Bit 4 SVS high-side mode. If this bit is set, the SVSH interrupt flag is set in LPM2, LPM3, and LPM4 in case of
power-fail conditions. If this bit is not set, the SVSH interrupt is not set in LPM2, LPM3, and LPM4.
SVSMHDLYST Bit 3 SVS and SVM high-side delay status. If this bit is set, the SVSH and SVMH events are masked for some
delay time. The delay time depends on the power mode of the SVSH and SVMH. If SVMHFP = 1 and
SVSHFP = 1 i.e. full-performance mode the delay is shorter. See the device-specific data sheet for
details. The bit is cleared by hardware if the delay has expired.
SVSMHRRL Bits 2-0 SVS and SVM high-side reset release voltage level. These bits define the reset release voltage level of
the SVSH. It is also used for the SVMH to define the voltage reached level. The voltage levels are defined
in the device-specific data sheet.
100 Power Management Module and Supply Voltage Supervisor SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
SVSMLACE SVSMLEVM Reserved SVSLMD SVSMLDLYST SVSMLRRL
rw-[0] rw-0 r-0 rw-0 rw-0 rw-[0] rw-[0] rw-[0]
SVMLFP Bit 15 SVM low-side full-performance mode. If this bit is set, the SVML operates in full-performance mode.
0 Normal mode. See the device-specific data sheet for response times.
1 Full-performance mode. See the device-specific data sheet for response times.
SVMLE Bit 14 SVM low-side enable. If this bit is set, the SVML is enabled.
Reserved Bit 13 Reserved. Always read 0.
SVMLOVPE Bit 12 SVM low-side overvoltage enable. If this bit is set, the SVML overvoltage detection is enabled.
SVSLFP Bit 11 SVS low-side full-performance mode. If this bit is set, the SVSL operates in full-performance mode.
0 Normal mode. See the device-specific data sheet for response times.
1 Full-performance mode. See the device-specific data sheet for response times.
SVSLE Bit 10 SVS low-side enable. If this bit is set, the SVSL is enabled.
SVSLRVL Bits 9-8 SVS low-side reset voltage level. If DVCC falls short of the SVSL voltage level selected by SVSHRVL, a
reset is triggered (if SVSLPE = 1). The voltage levels are defined in the device-specific data sheet.
SVSMLACE Bit 7 SVS and SVM low-side automatic control enable. If this bit is set, the low-power mode of the SVSL and
SVML circuits is under hardware control.
SVSMLEVM Bit 6 SVS and SVM low-side event mask. If this bit is set, the SVSL and SVML events are masked.
0 No events are masked.
1 All events are masked.
Reserved Bit 5 Reserved. Always read 0.
SVSLMD Bit 4 SVS low-side mode. If this bit is set, the SVSL interrupt flag is set in LPM2, LPM3 and LPM4 in case of
power-fail conditions. If this bit is not set, the SVSL interrupt is not set in LPM2, LPM3, and LPM4.
SVSMLDLYST Bit 3 SVS and SVM low-side delay status. If this bit is set, the SVSL and SVML events are masked for some
delay time. The delay time depends on the power mode of the SVSL and SVML. If SVMLFP = 1 and
SVSLFP = 1 i.e. full-performance mode, it is shorter. The bit is cleared by hardware if the delay has
expired.
SVSMLRRL Bits 2-0 SVS and SVM low-side reset release voltage level. These bits define the reset release voltage level of
the SVSL. It is also used for the SVML to define the voltage reached level. The voltage levels are defined
in the device-specific data sheet.
SLAU259 – May 2009 Power Management Module and Supply Voltage Supervisor 101
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
Reserved SVMOUTPOL SVMLVLROE SVMLOE Reserved
r-0 r-0 rw-[1] rw-[0] rw-[0] r-0 r-0 r-0
102 Power Management Module and Supply Voltage Supervisor SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
SVSMHDLYIF
Reserved SVMHVLRIFG1 SVMHIFG Reserved SVMLVLRIFG1 SVMLIFG SVSMLDLYIFG
G
r-0 rw-[0] rw-[0] rw-0 r-0 rw-[0] rw-[0] rw-0
1
After power up, the reset value depends on the power sequence.
PMMLPM5IFG Bit 15 LPM5 flag. This bit is set if the system was in LPM5 before. The bit is cleared by software or by reading
the reset vector word. A power failure on the DVCC domain clears the bit.
0 No interrupt pending
1 Interrupt pending
Reserved Bit 14 Reserved. Always read 0.
SVSLIFG Bit 13 SVS low-side interrupt flag. The bit is cleared by software or by reading the reset vector word.
0 No interrupt pending
1 Interrupt pending
SVSHIFG Bit 12 SVS high-side interrupt flag. The bit is cleared by software or by reading the reset vector word.
0 No interrupt pending
1 Interrupt pending
Reserved Bit 11 Reserved. Always read 0.
PMMPORIFG Bit 10 PMM software power-on reset interrupt flag. This interrupt flag is set if a software POR is triggered. The
bit is cleared by software or by reading the reset vector word.
0 No interrupt pending
1 Interrupt pending
PMMRSTIFG Bit 9 PMM reset pin interrupt flag. This interrupt flag is set if the RST/NMI pin is the reset source. The bit is
cleared by software or by reading the reset vector word.
0 No interrupt pending
1 Interrupt pending
PMMBORIFG Bit 8 PMM software brownout reset interrupt flag. This interrupt flag is set if a software BOR (PMMSWBOR) is
triggered. The bit is cleared by software or by reading the reset vector word.
0 No interrupt pending
1 Interrupt pending
Reserved Bit 7 Reserved. Always read 0.
SVMHVLRIFG Bit 6 SVM high-side voltage level reached interrupt flag. The bit is cleared by software or by reading the reset
vector (SVSHPE = 1) word or by reading the interrupt vector (SVSHPE = 0) word.
0 No interrupt pending
1 Interrupt pending
SVMHIFG Bit 5 SVM high-side interrupt flag. The bit is cleared by software.
0 No interrupt pending
1 Interrupt pending
SVSMHDLYIFG Bit 4 SVS and SVM high-side delay expired interrupt flag. This interrupt flag is set if the delay element
expired. The bit is cleared by software or by reading the interrupt vector word.
0 No interrupt pending
1 Interrupt pending
Reserved Bit 3 Reserved. Always read 0.
SVMLVLRIFG Bit 2 SVM low-side voltage level reached interrupt flag. The bit is cleared by software or by reading the reset
vector (SVSLPE = 1) word or by reading the interrupt vector (SVSLPE = 0) word.
0 No interrupt pending
1 Interrupt pending
SLAU259 – May 2009 Power Management Module and Supply Voltage Supervisor 103
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SVMLIFG Bit 1 SVM low-side interrupt flag. The bit is cleared by software.
0 No interrupt pending
1 Interrupt pending
SVSMLDLYIFG Bit 0 SVS and SVM low-side delay expired interrupt flag. This interrupt flag is set if the delay element expired.
The bit is cleared by software or by reading the interrupt vector word.
0 No interrupt pending
1 Interrupt pending
7 6 5 4 3 2 1 0
Reserved SVMHVLRIE SVMHIE SVSMHDLYIE Reserved SVMLVLRIE SVMLIE SVSMLDLYIE
r-0 rw-0 rw-0 rw-0 r-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
Reserved Reserved Reserved Reserved Reserved Reserved Reserved LOCKIO
r0 r0 r0 r0 r0 r0 r0 rw-[0]
104 Power Management Module and Supply Voltage Supervisor SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Chapter 5
SLAU259 – May 2009
CPUX
This chapter describes the extended MSP430X 16-bit RISC CPU (CPUX) with 1-MB memory access, its
addressing modes, and instruction set.
Note: The MSP430X CPU implemented on MSP430F5xx devices has, in some cases, slightly
different cycle counts from the MSP430X CPU implemented on the 2xx and 4xx families.
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
Interrupts www.ti.com
5.2 Interrupts
The MSP430X has the following interrupt structure:
• Vectored interrupts with no polling necessary
• Interrupt vectors are located downward from address 0FFFEh.
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.
During an interrupt, the program counter (PC) and the status register (SR) are pushed onto the stack as
shown in Figure 5-2. The MSP430X architecture stores the complete 20-bit PC value efficiently by
appending the PC bits 19:16 to the stored SR value automatically 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.
The PC can be addressed with all instructions and addressing modes. A few examples:
<br/>
MOV.W #LABEL,PC ; Branch to address LABEL (lower 64 KB)
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.
Figure 5-6 shows the stack usage. Figure 5-7 shows the stack usage when 20-bit address words are
pushed.
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 5-8.
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)
rw-0
Note: Bit manipulations of the SR should be done via the following instructions: MOV, BIS, and
BIC.
19 16 15 87 0
Un- Unused
Memory Register
used
Operation Operation
Memory 0 0 Register
Figure 5-11 and Figure 5-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
Word-Register Operation
Memory
19 16 15 87 0
Un-
Register
used
Operation
0 Register
Figure 5-13 and Figure 5-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 - Ad dress-Word Operation
Operation
Memory +2 0 Memory
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.
Operation: The operand is the 8-, 16-, or 20-bit content of the used CPU register.
Length: One, two, or three words
Comment: Valid for source and destination
Byte operation: Byte operation reads only the eight least significant bits (LSBs) of the source
register Rsrc and writes the result to the eight LSBs of the destination register Rdst.
The bits Rdst.19:8 are cleared. The register Rsrc is not modified.
Word operation: Word operation reads the 16 LSBs of the source register Rsrc and writes the result
to the 16 LSBs of the destination register Rdst. The bits Rdst.19:16 are cleared.
The register Rsrc is not modified.
Address-word Address-word operation reads the 20 bits of the source register Rsrc and writes the
operation: result to the 20 bits of the destination register Rdst. The register Rsrc is not
modified
SXT exception: The SXT instruction is the only exception for register operation. The sign of the low
byte in bit 7 is extended to the bits Rdst.19:8.
Example: BIS.W R5,R6 ;
This instruction logically ORs the 16-bit data contained in R5 with the 16-bit
contents of R6. R6.19:16 is cleared.
Before: After:
Address Register Address Register
Space Space
A550h.or.1111h = B551h
Before: After:
Address Register Address Register
Space Space
AA550h.or.11111h = BB551h
10000
0FFFF
Lower 64KB
Before: After:
Address Register Address Register
Space Space
0479Ch
0579Eh xxxxh +1000h 0579Eh xxxxh
0579Ch
0579Ch xx32h 0579Ch xx32h
Rn.19:0 Rn ± 32 KB
Rn.19:0
FFFFF
±32 KB
Rn.19:0
±32 KB
10000 Rn.19:0
0,FFFF
Lower 64 KB
Rn.19:0
0000C
Before: After:
Address Register Address Register
Space Space
23456h
1B79Eh xxxxh +F8346h 1B79Eh xxxxh
1B79Ch
1B79Ch 5432h 1B79Ch 5432h
23456h
3579Eh 0006h +12346h 3579Eh 0006h
3579Ch
3579Ch 5432h 3579Ch 5432h
Lower 64 KB
PC.19:16 = 0
19 16 15 0
FFFFF
Program
0
counter PC
Lower 64 KB
16-bit signed add
PC.19:0
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 64 KB.
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.
Before: After:
Address Address
Space Space
01036h
0579Eh xxxxh +04766h 0579Eh xxxxh
0579Ch
0579Ch xx32h 0579Ch xx32h
PC.19:0 PC ±32 KB
PC.19:0
FFFFF
±32 KB
PC.19:0
±32 KB
10000 PC.19:0
0FFFF
Lower 64 KB
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
21036h
3579Eh xxxxh +14766h 3579Eh xxxxh
3579Ch
3579Ch xx32h 3579Ch xx32h
5432h src
0777Ah xxxxh 0777Ah xxxxh +2345h dst
7777h Sum
07778h 2345h 07778h 7777h
Before: After:
Address Address
Space Space
65432h src
7777Ah 0001h 7777Ah 0007h +12345h dst
77777h Sum
77778h 2345h 77778h 7777h
Before: After:
Address Register Address Register
Space Space
Before: After:
Address Register Address Register
Space Space
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
Destination 15:0
Destination 15:0
Jump Instructions
Figure 5-24 shows the format for MSP430 and MSP430X jump instructions. The signed 10-bit word offset
of the jump instruction is multiplied by two, sign-extended to a 20-bit address, and added to the 20-bit PC.
This allows jumps in a range of –511 to +512 words relative to the PC in the full 20-bit address space.
Jumps do not affect the status bits. Table 5-6 lists and describes the eight jump instructions.
15 13 12 10 9 8 0
Emulated Instructions
In addition to the MSP430 and MSP430X instructions, emulated instructions are instructions that make
code easier to write and read, but do not have op-codes themselves. Instead, they are replaced
automatically by the assembler with a core instruction. There is no code or performance penalty for using
emulated instructions. The emulated instructions are listed in Table 5-7.
(1)
* = Status bit is affected.
– = Status bit is not affected.
0 = Status bit is cleared.
1 = Status bit is set.
(1)
MOV, BIT, and CMP instructions execute in one fewer cycle.
Table 5-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 instructions 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.
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
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
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Source 15:0
Destination 15:0
X(Rn)
01: Address
word @PC+
0 0 0 1 1 1 0 0 4
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 5-30.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
(1)
* = Status bit is affected.
– = Status bit is not affected.
0 = Status bit is cleared.
1 = Status bit is set.
The three possible addressing mode combinations for Format II instructions are shown in Figure 5-31.
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
15 12 11 10 9 4 3 0
15 12 11 8 7 4 3 0
#imm15:0 / &abs15:0
index15:0
15 4 3 0
Op-code Rdst
Op-code Rdst
index15:0
Op-code #imm/ix/abs19:16
(1)
* = Status bit is affected.
– = Status bit is not affected.
0 = Status bit is cleared.
1 = Status bit is set.
(1)
Add one cycle when Rn = SP
(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.
Instruction Instruction
Bit Loc. Inst. ID dst
Instruction Group 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
Example The 8-bit counter pointed to by R13 is added to a 16-bit counter pointed to by R12.
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
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
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
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.
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.
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.
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 64 K.
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).
CLR R5
CLRN
CALL SUBR
......
......
SUBR JN SUBRET ; If input is negative: do nothing and return
......
......
......
SUBRET RET
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), e.g., a table with addresses starting at X. The address is
within the lower 64 KB. X is within +32 KB.
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.
Example The two-digit decimal number contained in R5 is added to a four-digit decimal number
pointed to by R8.
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
; Move a block of 255 bytes from memory location starting with EDE to
; memory location starting with TONI. Tables should not overlap: start of
; destination address TONI must not be within the range EDE to EDE+0FEh
MOV #EDE,R6
MOV #510,R10
L$1 MOV @R6+,TONI-EDE-1(R6)
DEC R10
JNZ L$1
Do not transfer tables using the routine above with the overlap shown in Figure 5-36.
EDE
TONI
EDE+254
TONI+254
; Move a block of 255 bytes from memory location starting with EDE to
; memory location starting with TONI.
; Tables should not overlap: start of destination address TONI must not
; be within the range EDE to EDE+0FEh
MOV #EDE,R6
MOV #255,R10
L$1 MOV.B @R6+,TONI-EDE-2(R6)
DECD R10
JNZ L$1
DECD.B STATUS
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
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
INC.B STATUS
CMP.B #11,STATUS
JEQ OVFL
.......
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
JC Jump if carry
JHS Jump if higher or same (unsigned)
Syntax JC label
JHS label
Operation If C = 1: PC + (2 × Offset) → PC
If C = 0: execute the following instruction
Description The carry bit C 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 C is reset, the instruction after the jump is executed.
JC is used for the test of the carry bit C.
JHS is used for the comparison of unsigned numbers.
Status Bits Status bits are not affected
Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Example The state of the port 1 pin P1IN.1 bit defines the program flow.
Example R7 (20-bit counter) is incremented. If its content is zero, the program continues at
Label4.
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.
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.
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 64 K.
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 64 K, 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.
Example The word TONI is added to R5. If no carry occurs, continue at Label0. The address of
TONI is within PC ± 32 K.
Example If word EDE ≠ 1500, the program continues at Label2. Data in lower 64 K, 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.
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 64 K.
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.
* 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.
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.
Example Save the two bytes EDE and TONI on the stack. The addresses EDE and TONI are
within PC ± 32 K.
Item n SP Item n
SP PCReturn
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.
Byte 7 0
Example The input P1IN.1 information is shifted into the LSB of R5.
Example The signed RAM byte EDE is shifted arithmetically right one position.
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
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
Example The 8-bit counter pointed to by R13 is subtracted from a 16-bit counter pointed to by
R12.
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 ± 32
K. The address R12 points to is in full memory range.
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 64 K.
After SWPB
15 8 7 0
Before SWPB
19 16 15 8 7 0
After SWPB
19 16 15 8 7 0
Example The signed 8-bit data in EDE (PC +32 K) is sign extended and added to the 20-bit data
in R7.
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.
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.
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
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.
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.
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.
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.
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.
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
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.
INVX.A R5 ; Invert R5
INCX.A R5 ; R5 is now negated
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:
Example Restore the 16-bit registers R9, R10, R11, R12, R13 from the stack.
Example Save the five 16-bit registers R9, R10, R11, R12, R13 on the stack
RLAM.A #3,R5 ; R5 = R5 x 8
19 16 15 0
19 0
C MSB LSB 0
MSB 0
C 0
Example The RAM byte LEO is shifted left one position. PC is pointing to upper memory.
Example The signed 20-bit value in R15 is multiplied by 0.75. (0.5 + 0.25) × R15.
19 0
C MSB LSB
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 5-48. 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 5-49. 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
19 8 7 0
C 0 0 MSB LSB
19 16 15 0
19 0
C MSB LSB
7 0
C MSB LSB
15 0
C MSB LSB
31 20
0 0
19 0
C MSB LSB
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 5-50. 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.
C 0 MSB LSB
19 0
C MSB LSB
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 5-51. 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 5-52. 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
19 8 7 0
19 16 15 0
C 0 0 0 0 MSB LSB
19 0
C MSB LSB
7 0
C MSB LSB
15 0
C MSB LSB
31 20
0 0
19 0
C MSB LSB
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 5-53. 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 0
C 0 MSB LSB
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
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
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.
After SWPBX.A
19 16 15 8 7 0
Before SWPBX.A
31 20 19 16 15 8 7 0
After SWPBX.A
31 20 19 16 15 8 7 0
Before SWPBX
19 16 15 8 7 0
After SWPBX
19 16 15 8 7 0
Before SWPBX
15 8 7 0
After SWPBX
15 8 7 0
SXTX.A dst
31 20 19 16 15 8 7 6 0
0 ...... 0 S
SXTX[.W] Rdst
19 16 15 8 7 6 0
SXTX[.W] dst
15 8 7 6 0
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)
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.
Indexed mode: Branch to the 20-bit address contained in the address pointed to by
register (R5 + X) (e.g., 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:
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.
Indexed mode: Call a subroutine at the 20-bit address contained in the address pointed
to by register (R5 + X); e.g., 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).
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.
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.
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.
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.
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
Chapter 6
SLAU259 – May 2009
Note: Bank operations are not supported on all devices. See the device-specific data sheet for
banks supported and their respective sizes.
The block diagram of the flash memory and controller is shown in Figure 6-1.
MAB MDB
Timing
Generator
Flash
Memory
Array
Programming
Voltage
Generator
512-byte 512-byte
Segment 0
BSL Memory A BSL Memory B
512-byte 512-byte
BSL Memory C BSL Memory D
Segment 0
Segment X
64-kbyte 64-kbyte
Flash Memory Flash Memory Segment 125
Bank C Bank D
Segment 126
Segment 127
6.2.1 Segment A
Segment A of the information memory is locked separately from all other segments with the LOCKA bit. If
LOCKA = 1, segment A cannot be written or erased, and all information memory is protected from being
segment erased. If LOCKA = 0, segment A can be erased and written like any other flash memory
segment.
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 Info Memory
BIC #FWKEY+LOCKINFO, &FCTL4 ; Clear LOCKINFO
; 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
; Lock Info Memory
BIS #FWKEY+LOCKINFO,&FCTL4 ; Set LOCKINFO
Flash memory is in-system programmable (ISP) without the need for additional external voltage. The CPU
can program the flash memory. The flash memory write/erase modes are selected by the BLKWRT, WRT,
MERAS, and ERASE bits and are:
• Byte/word/long-word (32-bit) write
• Block write
• Segment erase
• Bank erase (only main memory)
• Mass erase (all main memory banks)
• Read during bank erase (except for the one currently read from)
Reading or writing to flash memory while it is busy programming or erasing (page, mass, or bank) from
the same bank is prohibited. Any flash erase or programming can be initiated from within flash memory or
RAM.
(1)
Bank operations are not supported on all devices. See the device-specific data sheet for support of bank operations.
Erase Cycle
An erase cycle is initiated by a dummy write to the address range of the segment to be erased. The
dummy write starts the erase operation. Figure 6-3 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 mass erase cycle timing is not
dependent on the amount of flash memory present on a device. Erase cycle times are equivalent for all
devices.
Disable watchdog
Yes
BUSY = 1
Dummy write
Disable watchdog
Yes
BUSY = 1
Dummy write
Yes
BUSY = 1
The write modes use a sequence of individual write instructions. Using the long-word write mode is
approximately twice as fast as the byte/word mode. Using the long-word block write mode is
approximately four times faster than byte/word mode, because the voltage generator remains on for the
complete block write, and long-words are written in parallel. Any instruction that modifies a destination can
be used to modify a flash location in either byte/word write mode, long-word write mode, or block
long-word write mode.
The BUSY bit is set while the 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 is set to 1. Otherwise,
an access violation occurs, ACCVIFG is set, and the flash write is unpredictable.
Byte/Word Write
A byte/word write operation can be initiated from within flash memory or from RAM. When initiating from
within flash memory, the CPU is held while the write completes. After the write completes, the CPU
resumes code execution with the instruction following the write access. The byte/word write timing is
shown in Figure 6-6.
BUSY
tWord_Write = 64 ... 85 µs
When a byte/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/word write mode, the internally-generated programming voltage is applied to the complete
128-byte block. The cumulative programming time, tCPT, must not be exceeded for any block. Each byte or
word write adds to the cumulative program time of a segment. If the maximum cumulative program time is
reached or exceeded, the segment must be erased. Further programming or using the data returns
unpredictable results (see the device-specific data sheet for specifications).
Disable watchdog
Disable watchdog
Yes
BUSY = 1
Yes
BUSY = 1
Long-Word Write
A long-word write operation can be initiated from within flash memory or from RAM. The BUSY bit is set to
1 after 32 bits are written to the flash controller and the programming cycle starts. When initiating from
within flash memory, the CPU is held while the write completes. After the write completes, the CPU
resumes code execution with the instruction following the write access. The long-word write timing is
shown in Figure 6-6.
A long-word consists of four consecutive bytes aligned to at 32-bit address (only the lower two address
bits are different). The bytes can be written in any order or any combination of bytes and words. If a byte
or word is written more than once, the last data written to the four bytes are stored into the flash memory.
If a write to a flash address outside of the 32-bit address happens before all four bytes are available, the
data written so far is discarded, and the latest byte/word written defines the new 32-bit aligned address.
When 32 bits are available, the write cycle is executed. When executing from RAM, the CPU continues to
execute code. 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 long-word write mode, the internally-generated programming voltage is applied to a complete 128-byte
block. The cumulative programming time, tCPT, must not be exceeded for any block. Each byte or word
write adds to the cumulative program time of a segment. If the maximum cumulative program time is
reached or exceeded, the segment must be erased. Further programming or using the data returns
unpredictable results.
With each byte or word write, the amount of time the block is subjected to the programming voltage
accumulates. If the cumulative programming time is reached or exceeded, the block must be erased
before further programming or use (see the device-specific data sheet for specifications).
Initiating Long-Word Write From Flash
The flow to initiate a long-word write from flash is shown in Figure 6-9.
Disable watchdog
Disable watchdog
Yes
BUSY = 1
Yes
BUSY = 1
Block Write
The block write can be used to accelerate the flash write process when many sequential bytes or words
need to be programmed. The flash programming voltage remains on for the duration of writing the
128-byte row. The cumulative programming time, tCPT, must not be exceeded for any row during a block
write.
A block write cannot be initiated from within flash memory. The block write must be initiated from RAM.
The BUSY bit remains set throughout the duration of the block write. The WAIT bit must be checked
between writing four bytes, or two words, to the block. When WAIT is set, then four bytes, or two 16-bit
words, of the block can be written. When writing successive blocks, the BLKWRT bit must be cleared after
the current block is completed. BLKWRT can be set initiating the next block write after the required flash
recovery time given by tEND. BUSY is cleared following each block write completion, indicating the next
block can be written. Figure 6-11 shows the block write timing.
BLKWRT bit
Write to Flash; e.g., MOV #0123h, &Flash
MOV #4567h, &Flash1
BUSY
Disable watchdog
Yes
BUSY = 1
Yes
WAIT = 0?
No
Block Border?
Set BLKWRT=0
Yes
BUSY = 1
Yes Another
Block?
Flash memory
Commands, data, etc.
UART,
Px.x, CPU executes
Host MSP430
SPI, user software
etc.
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
7 6 5 4 3 2 1 0
BLKWRT WRT SWRT Reserved Reserved MERAS ERASE Reserved
rw-0 rw-0 rw-0 r-0 r-0 rw-0 rw-0 r-0
FRKEY/FWKEY Bits 15–8 FCTL password. Always read as 096h. Must be written as 0A5h or a PUC is generated.
BLKWRT Bit 7 See following table
WRT Bit 6 See following table
SWRT Bit 5 Smart write. If this bit is set, the program time is shortened. The programming quality has to be
checked by marginal read modes.
Reserved Bits 4-3 Reserved. Must be written to 0. Always read 0.
MERAS Bit 2 Mass erase and erase. These bits are used together to select the erase mode. MERAS and
ERASE are automatically reset when a flash erase operation has completed.
ERASE Bit 1
7 6 5 4 3 2 1 0
Reserved LOCKA Reserved LOCK WAIT ACCVIFG KEYV BUSY
r-0 rw-1 rw-0 rw-1 r-1 rw-0 rw-(0) rw-0
FWKEY Bits 15–8 FCTLx password. Always read as 096h. Must be written as 0A5h or a PUC is generated.
Reserved Bit 7 Reserved. Always read 0.
LOCKA Bit 6 Segment A lock. Write a 1 to this bit to change its state. Writing 0 has no effect.
0 Segment A, B, C, D are unlocked. and are erased during a mass erase.
1 Segment A of the information memory is write protected. Segment B, C, and D are
protected from all erase.
Reserved Bit 5 Reserved. Must be written with 0.
LOCK Bit 4 Lock. This bit unlocks the flash memory for writing or erasing. The LOCK bit can be set any time
during a byte/word write or erase operation, and the operation completes normally. In the block write
mode, if the LOCK bit is set while BLKWRT = WAIT = 1, BLKWRT and WAIT are reset and the mode
ends normally.
0 Unlocked
1 Locked
WAIT Bit 3 Wait. Indicates the flash memory is being written to.
0 Flash memory is not ready for the next byte/word write.
1 Flash memory is ready for the next byte/word write.
ACCVIFG Bit 2 Access violation interrupt flag
0 No interrupt pending
1 Interrupt pending
KEYV Bit 1 Flash security key violation. This bit indicates an incorrect FCTLx password was written to any flash
control register and generates a PUC when set. KEYV must be reset with software.
0 FCTLx password was written correctly.
1 FCTLx password was written incorrectly.
BUSY Bit 0 Busy. This bit indicates if the flash is currently busy erasing or programming.
0 Not busy
1 Busy
7 6 5 4 3 2 1 0
LOCKINFO Reserved MRG1 MRG0 Reserved VPE
rw-0 r-0 rw-0 rw-0 r-0 r-0 r-0 rw-0
FWKEY Bits 15–8 FCTLx password. Always read as 096h. Must be written as 0A5h or a PUC is generated.
LOCKINFO Bit 7 Lock information memory. If set, the information memory cannot be erased in segment erase mode
and cannot be written to.
Reserved Bit 6 Reserved. Always read as 0.
MRG1 Bit 5 Marginal read 1 mode. This bit enables the marginal 1 read mode. The marginal read 1 bit is valid for
reads from the flash memory only. During a fetch cycle, the marginal mode is turned off
automatically. If both MRG1 and MRG0 are set, MRG1 is active and MRG0 is ignored.
0 Marginal 1 read mode is disabled.
1 Marginal 1 read mode is enabled.
MRG0 Bit 4 Marginal read 0 mode. This bit enables the marginal 0 read mode. The marginal read 1 bit is valid for
reads from the flash memory only. During a fetch cycle, the marginal mode is turned off
automatically. If both MRG1 and MRG0 are set, MRG1 is active and MRG0 is ignored.
0 Marginal 0 read mode is disabled.
1 Marginal 0 read mode is enabled.
Reserved Bits 3–1 Reserved. Always read as 0.
VPE Bit 0 Voltage changed during program error. This bit is set by hardware and can only be cleared by
software. If DVCC changed significantly during programming, this bit is set to indicate an invalid
result. The ACCVIFG bit is set if VPE is set.
7 6 5 4 3 2 1 0
ACCVIE
rw-0
Bits 15–6, 4–0 These bits may be used by other modules (see the device-specific data sheet and SYS chapter for
details).
ACCVIE Bit 5 Flash memory access violation interrupt enable. This bit enables the ACCVIFG interrupt. Because other
bits in SFRIE1 may be used for other modules, it is recommended to set or clear this bit using BIS.B or
BIC.B instructions, rather than MOV.B or CLR.B instructions. See the System Resets, Interrupts, and
Operating Modes, System Control Module (SYS) chapter for more details.
0 Interrupt not enabled
1 Interrupt enabled
Chapter 7
SLAU259 – May 2009
RAM Controller
The RAM controller (RAMCTL) allows control of the operation of the RAM.
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
7 6 5 4 3 2 1 0
RCRS7OFF Reserved RCRS3OFF RCRS2OFF RCRS1OFF RCRS0OFF
rw-0 r-0 r-0 r-0 rw-0 rw-0 rw-0 rw-0
RCKEY Bits 15-8 RAM controller key. Always read as 69h. Must be written as 5Ah, otherwise the RAMCTL write is
ignored.
RCRS7OFF Bit 7 RAM controller RAM sector 7 off. Setting the bit to 1 turns off the RAM sector 7. All data of the RAM
sector 7 is lost. On devices with USB, this sector is also used as USB buffer memory. See the
device-specific data sheet to find the address range and size of each RAM sector.
Reserved Bits 6-4 Reserved. Always read as 0.
RCRSyOFF Bits 3-0 RAM controller RAM sector y off. Setting the bit to 1 turns off the RAM sector y. All data of the RAM
sector y is lost. See the device-specific data sheet to find the address range and size of each RAM
sector.
Chapter 8
SLAU259 – May 2009
Digital I/O
This chapter describes the operation of the digital I/O ports in all devices.
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.
Any access (read or write) of the P1IV register automatically resets the highest pending interrupt flag. If
another interrupt flag is set, another interrupt is immediately generated after servicing the initial interrupt.
For example, assume that P1IFG.0 has the highest priority. If the P1IFG.0 and P1IFG.2 flags are set when
the interrupt service routine accesses the P1IV register, P1IFG.0 is reset automatically. After the RETI
instruction of the interrupt service routine is executed, the P1IFG.2 will generate another interrupt.
Port P2 interrupts behave similarly, and source a separate single interrupt vector and utilize the P2IV
register.
P1IV, P2IV Software Example
The following software example shows the recommended use of P1IV and the handling overhead. The
P1IV value is added to the PC to automatically jump to the appropriate routine. The P2IV is similar.
The numbers at the right margin show the necessary CPU cycles for each instruction. The software
overhead for different interrupt sources includes interrupt latency and return-from-interrupt cycles, but not
the task handling itself.
<br/>
;Interrupt handler for P1IFGx Cycles
P1_HND ... ; Interrupt latency 6
ADD &P1IV,PC ; Add offset to Jump table 3
RETI ; Vector 0: No interrupt 5
JMP P1_0_HND ; Vector 2: Port 1 bit 0 2
JMP P1_1_HND ; Vector 4: Port 1 bit 1 2
JMP P1_2_HND ; Vector 6: Port 1 bit 2 2
JMP P1_3_HND ; Vector 8: Port 1 bit 3 2
JMP P1_4_HND ; Vector 10: Port 1 bit 4 2
JMP P1_5_HND ; Vector 12: Port 1 bit 5 2
JMP P1_6_HND ; Vector 14: Port 1 bit 6 2
JMP P1_7_HND ; Vector 16: Port 1 bit 7 2
7 6 5 4 3 2 1 0
0 0 P1IVx 0
r0 r0 r0 r-0 r-0 r-0 r-0 r0
P1IVx Interrupt
Interrupt Source Interrupt Flag
Contents Priority
00h No interrupt pending
02h Port 1.0 interrupt P1IFG.0 Highest
04h Port 1.1 interrupt P1IFG.1
06h Port 1.2 interrupt P1IFG.2
08h Port 1.3 interrupt P1IFG.3
0Ah Port 1.4 interrupt P1IFG.4
0Ch Port 1.5 interrupt P1IFG.5
0Eh Port 1.6 interrupt P1IFG.6
10h Port 1.7 interrupt P1IFG.7 Lowest
7 6 5 4 3 2 1 0
0 0 P2IVx 0
r0 r0 r0 r-0 r-0 r-0 r-0 r0
P2IVx Interrupt
Interrupt Source Interrupt Flag
Contents Priority
00h No interrupt pending
02h Port 2.0 interrupt P2IFG.0 Highest
04h Port 2.1 interrupt P2IFG.1
06h Port 2.2 interrupt P2IFG.2
08h Port 2.3 interrupt P2IFG.3
0Ah Port 2.4 interrupt P2IFG.4
0Ch Port 2.5 interrupt P2IFG.5
0Eh Port 2.6 interrupt P2IFG.6
10h Port 2.7 interrupt P2IFG.7 Lowest
Chapter 9
SLAU259 – May 2009
The port mapping controller allows a flexible mapping of digital functions to port pins. This chapter
describes the port mapping controller.
9.2.1 Access
To enable write access to any of the port mapping controller registers, the correct password must be
written into the PMAPPWD register. The PMAPPWD register always reads 096A5h. Writing the password
02D52h grants write access to all port mapping controller registers. Read access is always possible.
If an invalid password is written while write access is granted, any further write accesses are prevented. It
is recommended that the application complete mapping configuration by writing an invalid password.
There is a timeout counter implemented that is incremented with each (assembler) instruction, and when it
counts to 32, the write access is locked again. Any access to the port mapping controller registers resets
the counter. Interrupts should be disabled during the configuration process or the application should take
precautions that the execution of an interrupt service routine does not accidentally cause a permanent
lock of the port mapping registers; e.g., by using the reconfiguration capability (see below).
The access status is reflected in the PMAPLOCK bit.
By default, the port mapping controller allows only one configuration after PUC. A second attempt to
enable write access by writing the correct password is ignored, and the registers remain locked. A PUC is
required to disable the permanent lock again. If it is necessary to reconfigure the mapping during runtime,
the PMAPRECFG bit must be set during the first write access timeslot. If PMAPRECFG is cleared during
later configuration sessions, no more configuration sessions are possible.
9.2.2 Mapping
For each port pin, Px.y, on ports providing the mapping functionality, a mapping register, PxMAPy, is
available. Setting this register to a certain value maps a module’s input and output signals to the
respective port pin Px.y. The port pin itself is switched from a general purpose I/O to the selected
peripheral/secondary function by setting the corresponding PxSEL.y bit to 1. If the input or the output
function of the module is used, it is typically defined by the setting the PxDIR.y bit. If PxDIR.y = 0, the pin
is an input, if PxDIR.y = 1, the pin is an output. There are also peripherals (e.g., the USCI module) that
control the direction or even other functions of the pin (e.g., open drain), and these options are
documented in the mapping table.
The mapping is device-dependent; see the device-specific data sheet for available functions and specific
values. Use mapping-mnemonics to abstract the underlying PxMAPy values is recommended, to allow
simple portability between different devices. Table 9-1 shows some examples for mapping mnemonics of
some common peripherals.
All mappable port pins provide the function PM_ANALOG (0FFh). Setting the port mapping register
PxMAPy of a port pin Px.y to PM_ANALOG together with PxSEL.y = 1 disables the output driver and the
input Schmitt-trigger, to prevent parasitic cross currents when applying analog signals.
void configure_ports()
{
int i;
#ifdef PORT_MAP_RECFG
// Allow reconfiguration during runtime:
PMAPCTL = PMAPRECFG;
#endif
#ifdef PORT_MAP_EINT
// Re-enable all interrupts
__enable_interrupt();
#endif
} // configure_ports()
7 6 5 4 3 2 1 0
PMAPPWDx, read as 096A5h, must be written as 02D52h
7 6 5 4 3 2 1 0
Reserved PMAPRECFG PMAPLOCKED
r0 r0 r0 r0 r0 r0 rw-0 r-1
PMAPx Bits 7-0 Selects secondary port function. Settings are device-dependent; see the device-specific data
sheet.
(1)
If not all bits are required to decode all provided functions, the unused bits are r0.
Chapter 10
SLAU259 – May 2009
DMA Controller
The direct memory access (DMA) controller module transfers data from one address to another, without
CPU intervention. This chapter describes the operation of the DMA controller.
JTAG Active
NMI Interrupt Request
Halt ENNMI
DMA0TSEL ROUNDROBIN
5 DMADT
DMADSTINCR
DMA0TRIG0 00000 2 DMADSTBYTE 3
DMA0TRIG1 00001
DMA Channel 0
DMA0SA
DMA0DA
DMA0SZ
DMA0TRIG31 11111 2 DMASRSBYTE
DMASRCINCR
to USB DMAEN
if available
DMA Priority and Control
DMA1TSEL DMADT
DMADSTINCR
5
2 DMADSTBYTE 3
DMA1TRIG0 00000
DMA Channel1
DMA1TRIG1 00001
DMA1SA
DMA1DA Address
Space
DMA1SZ
2 DMASRSBYTE
DMA1TRIG31 11111 DMASRCINCR
DMAEN
to USB
if available DMADT
DMADSTINCR
2 DMADSTBYTE 3
DMAnTSEL
5 DMA Channel n
DMAnSA
DMAnTRIG0 00000
DMAnTRIG1 00001 DMAnDA
DMAnSZ
2
DMASRSBYTE DMAEN
DMASRCINCR
DMARMWDIS
DMAnTRIG31 11111
Halt CPU
to USB
if available
DMA DMA
Address Space Address Space
Controller Controller
Single Transfer
In single transfer mode, each byte/word transfer requires a separate trigger. The single transfer state
diagram is shown in Figure 10-3.
The DMAxSZ register is used to define the number of transfers to be made. The DMADSTINCR and
DMASRCINCR bits select if the destination address and the source address are incremented or
decremented after each transfer. If DMAxSZ = 0, no transfers occur.
The DMAxSA, DMAxDA, and DMAxSZ registers are copied into temporary registers. The temporary
values of DMAxSA and DMAxDA are incremented or decremented after each transfer. The DMAxSZ
register is decremented after each transfer. When the DMAxSZ register decrements to zero, it is reloaded
from its temporary register and the corresponding DMAIFG flag is set. When DMADT = {0}, the DMAEN
bit is cleared automatically when DMAxSZ decrements to zero and must be set again for another transfer
to occur.
In repeated single transfer mode, the DMA controller remains enabled with DMAEN = 1, and a transfer
occurs every time a trigger occurs.
DMAEN = 0
Reset
DMAEN = 0 DMAEN = 0
DMAEN = 1
DMAREQ = 0
T_Size → DMAxSZ
DMAxSZ → T_Size
DMAxSA → T_SourceAdd
[ DMADT = {0}
DMAxDA → T_DestAdd
AND DMAxSZ = 0]
OR DMAEN = 0
DMAABORT = 1
Idle
DMAABORT=0 DMAREQ = 0
DMAxSZ > 0
Wait forTrigger
AND DMAEN = 1
T_Size → DMAxSZ
Hold CPU,
DMAxSA → T_SourceAdd
Transfer one word/byte
DMAxDA → T_DestAdd
[ENNMI = 1
AND NMI event]
OR
DMADT = {4}
[DMALEVEL = 1
AND DMAxSZ = 0
AND Trigger = 0]
AND DMAEN = 1
Decrement DMAxSZ
Modify T_SourceAdd
Modify T_DestAdd
Block Transfer
In block transfer mode, a transfer of a complete block of data occurs after one trigger. When DMADT = {1}
,the DMAEN bit is cleared after the completion of the block transfer and must be set again before another
block transfer can be triggered. After a block transfer has been triggered, further trigger signals occurring
during the block transfer are ignored. The block transfer state diagram is shown in Figure 10-4.
The DMAxSZ register is used to define the size of the block, and the DMADSTINCR and DMASRCINCR
bits select if the destination address and the source address are incremented or decremented after each
transfer of the block. If DMAxSZ = 0, no transfers occur.
The DMAxSA, DMAxDA, and DMAxSZ registers are copied into temporary registers. The temporary
values of DMAxSA and DMAxDA are incremented or decremented after each transfer in the block. The
DMAxSZ register is decremented after each transfer of the block and shows the number of transfers
remaining in the block. When the DMAxSZ register decrements to zero, it is reloaded from its temporary
register and the corresponding DMAIFG flag is set.
Reset
DMAEN = 0
DMAREQ = 0 DMAEN = 0
DMAEN = 1
T_Size → DMAxSZ
DMAxSZ → T_Size
[DMADT = {1}
AND DMAxSZ = 0] DMAxSA → T_SourceAdd
OR DMAxDA → T_DestAdd
DMAEN = 0
DMAABORT = 1
Idle
DMAREQ = 0
T_Size → DMAxSZ
DMAABORT = 0
DMAxSA → T_SourceAdd
DMAxDA → T_DestAdd
Wait forTrigger
DMADT = {5}
AND DMAxSZ = 0
AND DMAEN = 1
[+TriggerAND DMALEVEL= 0 ]
OR
[Trigger=1AND DMALEVEL=1]
2 × MCLK
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
Burst-Block Transfer
In burst-block mode, transfers are block transfers with CPU activity interleaved. The CPU executes
two MCLK cycles after every four byte/word transfers of the block, resulting in 20% CPU execution
capacity. After the burst-block, CPU execution resumes at 100% capacity and the DMAEN bit is cleared.
DMAEN must be set again before another burst-block transfer can be triggered. After a burst-block
transfer has been triggered, further trigger signals occurring during the burst-block transfer are ignored.
The burst-block transfer state diagram is shown in Figure 10-5.
The DMAxSZ register is used to define the size of the block, and the DMADSTINCR and DMASRCINCR
bits select if the destination address and the source address are incremented or decremented after each
transfer of the block. If DMAxSZ = 0, no transfers occur.
The DMAxSA, DMAxDA, and DMAxSZ registers are copied into temporary registers. The temporary
values of DMAxSA and DMAxDA are incremented or decremented after each transfer in the block. The
DMAxSZ register is decremented after each transfer of the block and shows the number of transfers
remaining in the block. When the DMAxSZ register decrements to zero, it is reloaded from its temporary
register and the corresponding DMAIFG flag is set.
In repeated burst-block mode, the DMAEN bit remains set after completion of the burst-block transfer and
no further trigger signals are required to initiate another burst-block transfer. Another burst-block transfer
begins immediately after completion of a burst-block transfer. In this case, the transfers must be stopped
by clearing the DMAEN bit, or by an (non)maskable interrupt (NMI) when ENNMI is set. In repeated
burst-block mode the CPU executes at 20% capacity continuously until the repeated burst-block transfer is
stopped.
DMAEN = 0
Reset
DMAEN = 0
DMAREQ = 0 DMAEN = 0
DMAEN = 1
T_Size → DMAxSZ
DMAxSZ → T_Size
[DMADT = {2, 3}
DMAxSA → T_SourceAdd
AND DMAxSZ = 0]
OR DMAxDA → T_DestAdd
DMAEN = 0
DMAABORT = 1
Idle
DMAABORT=0
Hold CPU,
Transfer one word/byte
[ENNMI = 1
AND NMI event]
OR T_Size → DMAxSZ
[DMALEVEL = 1 DMAxSA → T_SourceAdd
AND DMAxDA → T_DestAdd
Trigger = 0]
DMAxSZ > 0
Decrement DMAxSZ
Modify T_SourceAdd
Modify T_DestAdd
Edge-Sensitive Triggers
When DMALEVEL = 0, edge-sensitive triggers are used, and the rising edge of the trigger signal initiates
the transfer. In single-transfer mode, each transfer requires its own trigger. When using block or
burst-block modes, only one trigger is required to initiate the block or burst-block transfer.
Level-Sensitive Triggers
When DMALEVEL = 1, level-sensitive triggers are used. For proper operation, level-sensitive triggers can
only be used when external trigger DMAE0 is selected as the trigger. DMA transfers are triggered as long
as the trigger signal is high and the DMAEN bit remains set.
The trigger signal must remain high for a block or burst-block transfer to complete. If the trigger signal
goes low during a block or burst-block transfer, the DMA controller is held in its current state until the
trigger goes back high or until the DMA registers are modified by software. If the DMA registers are not
modified by software, when the trigger signal goes high again, the transfer resumes from where it was
when the trigger signal went low.
When DMALEVEL = 1, transfer modes selected when DMADT = {0, 1, 2, 3} are recommended because
the DMAEN bit is automatically reset after the configured transfer.
(1)
The additional 5 µs are needed to start the DCOCLK. It is the t(LPMx) parameter in the data sheet.
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
7 6 5 4 3 2 1 0
Reserved DMA0TSEL
r0 r0 r0 rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
7 6 5 4 3 2 1 0
Reserved DMA2TSEL
r0 r0 r0 rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
7 6 5 4 3 2 1 0
Reserved DMA4TSEL
r0 r0 r0 rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
7 6 5 4 3 2 1 0
Reserved DMA6TSEL
r0 r0 r0 rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
7 6 5 4 3 2 1 0
0 0 0 0 0 DMARMWDIS ROUND ENNMI
ROBIN
r0 r0 r0 r0 r0 rw-(0) rw-(0) rw-(0)
7 6 5 4 3 2 1 0
DMA DMA DMALEVEL DMAEN DMAIFG DMAIE DMAABORT DMAREQ
DSTBYTE SRCBYTE
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
23 22 21 20 19 18 17 16
Reserved DMAxSA
r0 r0 r0 r0 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
23 22 21 20 19 18 17 16
Reserved DMAxDA
r0 r0 r0 r0 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
7 6 5 4 3 2 1 0
DMAxSZ
rw rw rw rw rw rw rw rw
DMAxSZ Bits 15-0 DMA size. The DMA size register defines the number of byte/word data per block transfer. DMAxSZ
register decrements with each word or byte transfer. When DMAxSZ decrements to 0, it is immediately
and automatically reloaded with its previously initialized value.
00000h Transfer is disabled.
00001h One byte or word is transferred.
00002h Two bytes or words are transferred.
⋮
0FFFFh 65535 bytes or words are transferred.
7 6 5 4 3 2 1 0
0 0 DMAIV 0
r0 r0 r-(0) r-(0) r-(0) r-(0) r-(0) r0
DMAIV Interrupt
Interrupt Source Interrupt Flag
Contents Priority
00h No interrupt pending
02h DMA channel 0 DMA0IFG Highest
04h DMA channel 1 DMA1IFG
06h DMA channel 2 DMA2IFG
08h DMA channel 3 DMA3IFG
0Ah DMA channel 4 DMA4IFG
0Ch DMA channel 5 DMA5IFG
0Eh DMA channel 6 DMA6IFG
10h DMA channel 7 DMA7IFG Lowest
Chapter 11
SLAU259 – May 2009
This chapter describes the 32-bit hardware multiplier (MPY32). The MPY32 module is implemented in all
devices.
Accessible
MPY
Register
MPYS
MAC
MACS
MPY32H MPY32L
MPYS32H MPYS32L
31 16 15 0 31 16 15 0
OP1 (high word) OP1 (low word) OP2 (high word) OP2 (low word)
16×16 Multiplier
OP1_32
OP2_32
2
MPYMx Control
MPYSAT Logic 32-bit Adder
MPYFRAC
MPYC
32-bit Demultiplexer
32-bit Multiplexer
Writing the second operand to the OP2 initiates the multiply operation. Writing OP2 starts the selected
operation with a 16-bit-wide second operand together with the values stored in OP1. Writing OP2L starts
the selected operation with a 32-bit-wide second operand and the multiplier expects a the high word to be
written to OP2H. Writing to OP2H without a preceding write to OP2L is ignored.
For 8-bit or 24-bit operands, the operand registers can be accessed with byte instructions. Accessing the
multiplier with a byte instruction during a signed operation automatically causes a sign extension of the
byte within the multiplier module. For 24-bit operands, only the high word should be written as byte. If the
24-bit operands are sign-extended as defined by the register, that is used to write the low word to,
because this register defines if the operation is unsigned or signed.
The high-word of a 32-bit operand remains unchanged when changing the size of the operand to 16 bit,
either by modifying the operand size bits or by writing to the respective operand register. During the
execution of the 16-bit operation, the content of the high-word is ignored.
In addition to RES0 to RES3, for compatibility with the 16×16 hardware multiplier, the 32-bit result of a
8-bit or 16-bit operation is accessible via RESLO, RESHI, and SUMEXT. In this case, the result low
register RESLO holds the lower 16 bits of the calculation result and the result high register RESHI holds
the upper 16 bits. RES0 and RES1 are identical to RESLO and RESHI, respectively, in usage and access
of calculated results.
The sum extension register SUMEXT contents depend on the multiply operation and are listed in
Table 11-4. If all operands are 16 bits wide or less, the 32-bit result is used to determine sign and carry. If
one of the operands is larger than 16 bits, the 64-bit result is used.
The MPYC bit reflects the multiplier's carry as listed in Table 11-4 and, thus, can be used as 33rd or 65th
bit of the result, if fractional or saturation mode is not selected. With MAC or MACS operations, the MPYC
bit reflects the carry of the 32-bit or 64-bit accumulation and is not taken into account for successive MAC
and MACS operations as the 33rd or 65th bit.
There is no sign extension necessary in software. Accessing the multiplier with a byte instruction during a
signed operation automatically causes a sign extension of the byte within the multiplier module.
; 32x32 Unsigned Multiply
MOV #01234h,&MPY32L ; Load low word of 1st operand
MOV #01234h,&MPY32H ; Load high word of 1st operand
MOV #05678h,&OP2L ; Load low word of 2nd operand
MOV #05678h,&OP2H ; Load high word of 2nd operand
; ... ; Process results
15 bits
1 1 1 1
S ...
2 4 8 16
Decimal point
Sign bit
14 bits
1 1 1 1
S x ...
2 4 8 16
The benefit of using 16-bit signed Q15 or 32-bit signed Q31 numbers with multiplication is that the product
of two number in the range from –1.0 to 1.0 is always in that same range.
Fractional Number Mode
Multiplying two fractional numbers using the default multiplication mode with MPYFRAC = 0 and
MPYSAT = 0 gives a result with two sign bits. For example, if two 16-bit Q15 numbers are multiplied, a
32-bit result in Q30 format is obtained. To convert the result into Q15 format manually, the first 15 trailing
bits and the extended sign bit must be removed. However, when the fractional mode of the multiplier is
used, the redundant sign bit is automatically removed, yielding a result in Q31 format for the multiplication
of two 16-bit Q15 numbers. Reading the result register RES1 gives the result as 16-bit Q15 number. The
32-bit Q31 result of a multiplication of two 32-bit Q31 numbers is accessed by reading registers RES2 and
RES3.
The fractional mode is enabled with MPYFRAC = 1 in register MPY32CTL0. The actual content of the
result register(s) is not modified when MPYFRAC = 1. When the result is accessed using software, the
value is left shifted one bit, resulting in the final Q formatted result. This allows user software to switch
between reading both the shifted (fractional) and the unshifted result. The fractional mode should only be
enabled when required and disabled after use.
In fractional mode, the SUMEXT register contains the sign extended bits 32 and 33 of the shifted result for
16×16-bit operations and bits 64 and 65 for 32×32-bit operations – not only bits 32 or 64, respectively.
The MPYC bit is not affected by the fractional mode. It always reads the carry of the nonfractional result.
; Example using
; Fractional 16x16 multiplication
BIS #MPYFRAC,&MPY32CTL0 ; Turn on fractional mode
MOV &FRACT1,&MPYS ; Load 1st operand as Q15
MOV &FRACT2,&OP2 ; Load 2nd operand as Q15
MOV &RES1,&PROD ; Save result as Q15
BIC #MPYFRAC,&MPY32CTL0 ; Back to normal mode
Saturation Mode
The multiplier prevents overflow and underflow of signed operations in saturation mode. The saturation
mode is enabled with MPYSAT = 1 in register MPY32CTL0. If an overflow occurs, the result is set to the
most-positive value available. If an underflow occurs, the result is set to the most-negative value available.
This is useful to reduce mathematical artifacts in control systems on overflow and underflow conditions.
The saturation mode should only be enabled when required and disabled after use.
The actual content of the result register(s) is not modified when MPYSAT = 1. When the result is
accessed using software, the value is automatically adjusted providing the most-positive or most-negative
result when an overflow or underflow has occurred. The adjusted result is also used for successive
multiply-and-accumulate operations. This allows user software to switch between reading the saturated
and the nonsaturated result.
With 16×16 operations, the saturation mode only applies to the least significant 32 bits, i.e., the result
registers RES0 and RES1. Using the saturation mode in MAC or MACS operations that mix 16×16
operations with 32×32, 16×32, or 32×16 operations leads to unpredictable results.
With 32×32, 16×32, and 32×16 operations, the saturated result can only be calculated when RES3 is
ready. In non-5xx devices, reading RES0 to RES2 prior to the complete result being ready delivers the
nonsaturated results independent of the MPYSAT bit setting.
Enabling the saturation mode does not affect the content of the SUMEXT register nor the content of the
MPYC bit.
; Example using
; Fractional 16x16 multiply accumulate with Saturation
; Turn on fractional and saturation mode:
BIS #MPYSAT+MPYFRAC,&MPY32CTL0
MOV &A1,&MPYS ; Load A1 for 1st term
MOV &K1,&OP2 ; Load K1 to get A1*K1
MOV &A2,&MACS ; Load A2 for 2nd term
MOV &K2,&OP2 ; Load K2 to get A2*K2
MOV &RES1,&PROD ; Save A1*K1+A2*K2 as result
BIC #MPYSAT+MPYFRAC,&MPY32CTL0 ; turn back to normal
Overflow: Overflow:
MPYC=0 and Yes RES3 unchanged MPYC=0 and Yes RES3 = 07FFFh
unshifted RES1, RES2 unchanged unshifted RES3, RES2 = 0FFFFh
bit15=1 RES1 = 07FFFh bit15=1 RES1 = 0FFFFh
RES0 = 0FFFFh RES0 = 0FFFFh
No No
Underflow: Underflow:
MPYC=1 and Yes RES3 unchanged MPYC=1 and Yes RES3 = 08000h
unshifted RES1, RES2 unchanged unshifted RES3, RES2 = 00000h
bit15=0 RES1 = 08000h bit15=0 RES1 = 00000h
RES0 = 00000h RES0 = 00000h
No No
No No
MPYFRAC=1 MPYFRAC=1
Yes Yes
Overflow: Overflow:
Unshifted RES1, Yes RES3 unchanged Unshifted RES3, Yes RES3 = 07FFFh
bit 15=0 and RES2 unchanged bit 15=0 and RES2 = 0FFFFh
bit 14=1 RES1 = 07FFFh bit 14=1 RES1 = 0FFFFh
RES0 = 0FFFFh RES0 = 0FFFFh
No No
Underflow: Underflow:
Unshifted RES1, Yes RES3 unchanged Unshifted RES3, Yes RES3 = 08000h
bit 15=1 and RES2 unchanged bit 15=1 and RES2 = 00000h
bit 14=0 RES1 = 08000h bit 14=0 RES1 = 00000h
RES0 = 00000h RES0 = 00000h
No No
The following example illustrates a special case showing the saturation function in fractional mode. It also
uses the 8-bit functionality of the MPY32 module.
; Turn on fractional and saturation mode,
; clear all other bits in MPY32CTL0:
MOV #MPYSAT+MPYFRAC,&MPY32CTL0
;Pre-load result registers to demonstrate overflow
MOV #0,&RES3 ;
MOV #0,&RES2 ;
MOV #07FFFh,&RES1 ;
MOV #0FA60h,&RES0 ;
MOV.B #050h,&MACS_B ; 8-bit signed MAC operation
MOV.B #012h,&OP2_B ; Start 16x16 bit operation
MOV &RES0,R6 ; R6 = 0FFFFh
MOV &RES1,R7 ; R7 = 07FFFh
The result is saturated because already the result not converted into a fractional number shows an
overflow. The multiplication of the two positive numbers 00050h and 00012h gives 005A0h. 005A0h added
to 07FFF FA60h results in 8000 059Fh, without MPYC being set. Because the MSB of the unmodified
result RES1 is 1 and MPYC = 0, the result is saturated according Figure 11-4.
New Multiplication
Started
Yes No
16×16
?
No Yes Yes No
MAC or MACS MAC or MACS
? ?
Yes Yes
MPYSAT=1 MPYSAT=1
? ? Clear Result:
Clear Result: RES3 = 00000h
RES1 = 00000h non-fractional No No non-fractional RES2 = 00000h
RES0 = 00000h 32-bit Saturation 64-bit Saturation RES1 = 00000h
RES0 = 00000h
Yes Yes
MPYFRAC=1 MPYFRAC=1
? ?
Yes Yes
MPYSAT=1 MPYSAT=1
? ?
Multiplication
completed
Given the separation in processing of 16-bit operations (32-bit results) and 32-bit operations (64-bit
results) by the module, it is important to understand the implications when using MAC/MACS operations
and mixing 16-bit operands/results with 32-bit operands/results. User software must address these points
during usage when mixing these operations. The following code snippet illustrates the issue.
; Mixing 32x24 multiplication with 16x16 MACS operation
MOV #MPYSAT,&MPY32CTL0 ; Saturation mode
MOV #052C5h,&MPY32L ; Load low word of 1st operand
MOV #06153h,&MPY32H ; Load high word of 1st operand
MOV #001ABh,&OP2L ; Load low word of 2nd operand
MOV.B #023h,&OP2H_B ; Load high word of 2nd operand
;... 5 NOPs required
MOV &RES0,R6 ; R6 = 00E97h
MOV &RES1,R7 ; R7 = 0A6EAh
MOV &RES2,R8 ; R8 = 04F06h
MOV &RES3,R9 ; R9 = 0000Dh
; Note that MPYC = 0!
MOV #0CCC3h,&MACS ; Signed MAC operation
MOV #0FFB6h,&OP2 ; 16x16 bit operation
MOV &RESLO,R6 ; R6 = 0FFFFh
MOV &RESHI,R7 ; R7 = 07FFFh
The second operation gives a saturated result because the 32-bit value used for the 16×16-bit MACS
operation was already saturated when the operation was started; the carry bit MPYC was 0 from the
previous operation, but the MSB in result register RES1 is set. As one can see in the flow chart, the
content of the result registers are saturated for multiply-and-accumulate operations after starting a new
operation based on the previous results, but depending on the size of the result (32 bit or 64 bit) of the
newly initiated operation.
The saturation before the multiplication can cause issues if the MPYC bit is not properly set as the
following code example illustrates.
;Pre-load result registers to demonstrate overflow
MOV #0,&RES3 ;
MOV #0,&RES2 ;
MOV #0,&RES1 ;
MOV #0,&RES0 ;
; Saturation mode and set MPYC:
MOV #MPYSAT+MPYC,&MPY32CTL0
MOV.B #082h,&MACS_B ; 8-bit signed MAC operation
MOV.B #04Fh,&OP2_B ; Start 16x16 bit operation
MOV &RES0,R6 ; R6 = 00000h
MOV &RES1,R7 ; R7 = 08000h
Even though the result registers were loaded with all zeros, the final result is saturated. This is because
the MPYC bit was set causing the result used for the multiply-and-accumulate to be saturated to
08000 0000h. Adding a negative number to it would again cause an underflow, thus, the final result is also
saturated to 08000 0000h.
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
7 6 5 4 3 2 1 0
MPYOP2_32 MPYOP1_32 MPYMx MPYSAT MPYFRAC Reserved MPYC
rw rw rw rw rw-0 rw-0 rw-0 rw
Chapter 12
SLAU259 – May 2009
CRC Module
The cyclic redundancy check (CRC) module provides a signature for a given data sequence. This chapter
describes the operation and use of the CRC module.
Note: The CRC module on the MSP430F543x and MSP430F541x non-A versions does not support
the bit-wise reverse feature described in this module description. Registers CRCDIRB and
CRCRESR, along with their respective functionality, are not available.
Q D Q D Q D Q D Q D Q D Q D Q D Q D Q D
Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit
15 12 11 10 6 5 4 3 1 0
Shift Clock
Figure 12-1. LFSR Implementation of CRC-CCITT Standard, Bit 0 is the MSB of the Result
Identical input data sequences result in identical signatures when the CRC is initialized with a fixed seed
value, whereas different sequences of input data, in general, result in different signatures.
If the Check Sum itself (with reversed bit order) is included into the CRC operation (as data written to
CRCDI or CRCDIRB), the result in the CRCINIRES and CRCRESR registers must be zero.
Data In
8-bit or 16-bit
8 8
Byte MUX
8 16
Figure 12-2. Implementation of CRC-CCITT using the CRCDI and CRCINIRES registers
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
(1)
Not available on MSP430F543x and MSP430F541x non-A versions.
7 6 5 4 3 2 1 0
CRCDI
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
CRCDI Bits 15-0 CRC data in. Data written to the CRCDI register is included to the present signature in the CRCINIRES
register according to the CRC-CCITT standard.
7 6 5 4 3 2 1 0
CRCDIRB
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
CRCDIRB Bits 15-0 CRC data in reverse byte. Data written to the CRCDIRB register is included to the present signature in
the CRCINIRES and CRCRESR registers according to the CRC-CCITT standard. Reading the register
returns the register CRCDI content.
7 6 5 4 3 2 1 0
CRCINIRES
rw-1 rw-1 rw-1 rw-1 rw-1 rw-1 rw-1 rw-1
CRCINIRES Bits 15-0 CRC initialization and result. This register holds the current CRC result (according to the CRC-CCITT
standard). Writing to this register initializes the CRC calculation with the value written to it. The value
just written can be read from CRCINIRES register.
7 6 5 4 3 2 1 0
CRCRES R
r-1 r-1 r-1 r-1 r-1 r-1 r-1 r-1
CRCRESR Bits 15-0 CRC reverse result. This register holds the current CRC result (according to the CRC-CCITT standard).
The order of bits is reverse (e.g., CRCINIRES[15] = CRCRESR[0]) to the order of bits in the
CRCINIRES register (see example code).
Chapter 13
SLAU259 – May 2009
AES Accelerator
The AES accelerator module performs AES128 encryption or decryption in hardware. This chapter
describes the AES accelerator.
AESADIN
AES128
Encryption/
AESAKEY
Decryption
Key Buffer Core
AESADOUT
in[0] in[4] in[8] in[12] s[0,0] s[0,1] s[0,2] s[0,3] out[0] out[4] out[8] out[12]
in[1] in[5] in[9] in[13] s[1,0] s[1,1] s[1,2] s[1,3] out[1] out[5] out[9] out[13]
in[2] in[6] in[10] in[14] s[2,0] s[2,1] s[2,2] s[2,3] out[2] out[6] out[10] out[14]
in[3] in[7] in[11] in[15] s[3,0] s[3,1] s[3,2] s[3,3] out[3] out[7] out[11] out[15]
The module allows word and byte access to all data registers, AESAKEY, AESADIN, and AESADOUT.
Word and byte access should not be mixed while reading from or writing into one of the registers.
However, it is possible to write one of the registers using byte access and another using word access.
13.2.1 Encryption
Figure 13-3 shows the encryption process with the cipher being a series of transformations that converts
the plaintext written into the AESADIN register to a ciphertext that can be read from the AESADOUT
register using the cipher key provided via the AESAKEY register.
Encryption Process
Cipher
Round Key 9 Round 9
Ciphertext
(AESADOUT)
Inverse Cipher
Round Key 2 Round Key 2 Inverse Round 2
Ciphertext
(AESADIN)
Inverse Cipher
Round Key 2 Round Key 2 Inverse Round 2
To generate the decryption key independent from the actual decryption, the following steps are required:
1. Set AESOPx = 10 to select decryption key generation. Changing the AESOPx bits clears the
AESKEYWR flag, and a new key must be loaded in step 2.
2. Load the 128-bit key into AESAKEY, or set the AESKEYWR flag by software if the key from a previous
operation should be used. When all 16 bytes are written, the AESKEYWR flag indicates completion.
The generation of the first round key required for decryption is started immediately.
3. While the AES module is performing the key generation, the AESBUSY bit is 1. It takes 52 CPU clock
cycles to complete the key generation. After its completion, the AESRDYIFG is set, and the result can
be read from AESADOUT. When all 16 bytes are read, the AESDOUTRD flag indicates completion.
The AESRDYIFG flag is cleared when reading AESADOUT or writing to AESAKEY or AESADIN.
4. If data should be decrypted with the generated key, AESOPx must be set to 11. Then the generated
key must be loaded or, if it was just generated with AESOPx = 10, it is sufficient to set the
AESKEYWR flag by software to indicate that the key is already valid. Afterward, the steps described in
Section 13.2.2 to load the data, etc., must be followed.
7 6 5 4 3 2 1 0
AESSWRST Reserved AESOPx
rw-0 r0 r0 r0 r0 r0 rw-0 rw-0
7 6 5 4 3 2 1 0
AESKEYCNTx AESDOUTRD AESDINWR AEKEYWR AESBUSY
r-0 r-0 r-0 r-0 r-0 rw-0 rw-0 r-0
AESDOUTCNTx Bits 15-12 Bytes read via AESADOUT. Reset when AESDOUTRD is reset.
If AESDOUTCNTx = 0 and AESDOUTRD = 0, no bytes were read.
If AESDOUTCNTx = 0 and AESDOUTRD = 1, all bytes were read.
AESDINCNTx Bits 11-8 Bytes written via AESADIN. Reset when AESDINWR is reset.
If AESDINCNTx = 0 and AESDINWR = 0, no bytes were written.
If AESDINCNTx = 0 and AESDINWR = 1, all bytes were written.
AESKEYCNTx Bit 7-4 Bytes written via AESAKEY. Reset when AESKEYWR is reset.
If AESKEYCNTx = 0 and AESKEYWR = 0, no bytes were written.
If AESKEYCNTx = 0 and AESKEYWR = 1, all bytes were written.
AESDOUTRD Bit 3 All 16 bytes read from AESADOUT.
AESDOUTRD is reset by PUC, AESSWRST, an error condition, changing AESOPx, when the
AES accelerator is busy, and when the output data is read again.
0 Not all bytes read.
1 All bytes read.
AESDINWR Bit 2 All 16 bytes written to AESADIN. This bit can be modified by software. Changing its state by
software also resets the AEDINCNTx bits.
AESDINWR is reset by PUC, AESSWRST, an error condition, changing AESOPx, the start to
(over)write the data, and when the AES accelerator is busy. Because it is reset when AESOPx
is changed it can be set by software again to indicate that the current data is still valid (e.g. for
OFB cipher block chaining).
0 Not all bytes written.
1 All bytes written.
AEKEYWR Bit 1 All 16 bytes written to AESAKEY. This bit can be modified by software. Changing its state by
software also resets the AESKEYCNTx bits.
AESKEYWR is reset by PUC, AESSWRST, an error condition, changing AESOPx, and the start
to (over)write a new key. Because it is reset when AESOPx is changed it can be set by software
again to indicate that the loaded key is still valid
0 Not all bytes written.
1 All bytes written.
AESBUSY Bit 0 AES accelerator module busy; encryption, decryption, or key generation in progress.
0 Not busy
1 Busy
7 6 5 4 3 2 1 0
AESKEY0x (Key Byte n)
w-0 w-0 w-0 w-0 w-0 w-0 w-0 w-0
AESKEY1x Bits 15-8 AES key byte n+1 when AESAKEY is written as word.
Do not use these bits for byte access.
Do not mix word and byte access.
Always reads as zero.
The key is reset by PUC or by AESSWRST = 1.
AESKEY0x Bits 7-0 AES key byte n when AESAKEY is written as word.
AES next key byte when AESAKEY_L is written as byte.
Do not mix word and byte access.
Always reads as zero.
The key is reset by PUC or by AESSWRST = 1.
7 6 5 4 3 2 1 0
AESDIN0x (DIN Byte n)
w-0 w-0 w-0 w-0 w-0 w-0 w-0 w-0
AESDIN1x Bits 15-8 AES data in byte n+1 when AESADIN is written as word.
Do not use these bits for byte access.
Do not mix word and byte access.
Always reads as zero.
AESDIN0x Bits 7-0 AES data in byte n when AESADIN is written as word.
AES next data in byte when AESADIN_L is written as byte.
Do not mix word and byte access.
Always reads as zero.
7 6 5 4 3 2 1 0
AESDOUT0x (DOUT Byte n)
r-0 r-0 r-0 r-0 r-0 r-0 r-0 r-0
AESDOUT1x Bits 15-8 AES data out byte n+1 when AESADOUT is read as word.
Do not use these bits for byte access.
Do not mix word and byte access.
AESDOUT0x Bits 7-0 AES data out byte n when AESADOUT is read as word.
AES next data out byte when AESADOUT_L is read as byte.
Do not mix word and byte access.
Chapter 14
SLAU259 – May 2009
Timer_A
Timer_A is a 16-bit timer/counter with multiple capture/compare registers. There can be multiple Timer_A
modules on a given device (see the device-specific data sheet). This chapter describes the operation and
use of the Timer_A module.
Note: Nomenclature
There may be multiple instantiations of Timer_A on a given device. The prefix TAx is used,
where x is a greater than equal to zero indicating the Timer_A instantiation. For devices with
one instantiation, x = 0. The suffix n, where n = 0 to 6, represents the specific
capture/compare registers associated with the Timer_A instantiation.
Timer Block
TASSEL ID IDEX Timer Clock MC
2 15 0
2 3 2
TAxCLK 00 Divider Divider 16-bit Timer
Count
TAxR EQU0
ACLK 01 /1/2/4/8 /1.../8 Mode
Clear RC
SMCLK 10
11 Set TAxCTL
TAIFG
TACLR
CCR0
CCR1
CCR2
CCR3
CCR4
CCR5
CCR6
Compararator 6
CCI
EQU6
CAP
A
SCCI Y
EN 0 Set TAxCCR6
1 CCIFG
OUT
Output
Unit4 D Set Q OUT6 Signal
EQU0
Timer Clock
Reset
3 POR
OUTMOD
TAxR may be cleared by setting the TACLR bit. Setting TACLR also clears the clock divider and count
direction for up/down mode.
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 TAxCCR0, which defines the period (see Figure 14-2). The
number of timer counts in the period is TAxCCR0 + 1. When the timer value equals TAxCCR0, the timer
restarts counting from zero. If up mode is selected when the timer value is greater than TAxCCR0, the
timer immediately restarts counting from zero.
TAxCCR0
The TAxCCR0 CCIFG interrupt flag is set when the timer counts to the TAxCCR0 value. The TAIFG
interrupt flag is set when the timer counts from TAxCCR0 to zero. Figure 14-3 shows the flag set cycle.
Timer Clock
Continuous Mode
In the continuous mode, the timer repeatedly counts up to 0FFFFh and restarts from zero as shown in
Figure 14-4. The capture/compare register TAxCCR0 works the same way as the other capture/compare
registers.
0FFFFh
0h
The TAIFG interrupt flag is set when the timer counts from 0FFFFh to zero. Figure 14-5 shows the flag set
cycle.
Timer Clock
TAxCCR1b TAxCCR1c
TAxCCR0d
TAxCCR0b TAxCCR0c
0FFFFh
TAxCCR1a TAxCCR1d
TAxCCR0a
t0 t0 t0
t1 t1 t1
Time intervals can be produced with other modes as well, where TAxCCR0 is used as the period register.
Their handling is more complex since the sum of the old TAxCCRn data and the new period can be higher
than the TAxCCR0 value. When the previous TAxCCRn value plus tx is greater than the TAxCCR0 data,
the TAxCCR0 value must be subtracted to obtain the correct time interval.
Up/Down Mode
The up/down mode is used if the timer period must be different from 0FFFFh counts, and if symmetrical
pulse generation is needed. The timer repeatedly counts up to the value of compare register TAxCCR0
and back down to zero (see Figure 14-7). The period is twice the value in TAxCCR0.
0FFFFh
TAxCCR0
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 TAxR value and the timer clock divider.
In up/down mode, the TAxCCR0 CCIFG interrupt flag and the TAIFG interrupt flag are set only once
during a period, separated by one-half the timer period. The TAxCCR0 CCIFG interrupt flag is set when
the timer counts from TAxCCR0-1 to TAxCCR0, and TAIFG is set when the timer completes counting
down from 0001h to 0000h. Figure 14-8 shows the flag set cycle.
Timer Clock
Up/Down
0FFFFh
TAxCCR0
TAxCCR1
TAxCCR2
0h
Dead Time
Output Mode 6: Toggle/Set
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 14-11. COV must be reset with software.
Idle
No Read
Capture Taken
Capture
Taken Capture
Taken
Capture
Capture
Clear Bit COV
in Register TAxCCTLn
Second
Capture Idle
Taken
COV = 1
Compare Mode
The compare mode is selected when CAP = 0. The compare mode is used to generate PWM output
signals or interrupts at specific time intervals. When TAxR counts to the value in a TAxCCRn, where n
represents the specific capture/compare register.
• Interrupt flag CCIFG is set.
• Internal signal EQUn = 1.
• EQUn affects the output according to the output mode.
• The input signal CCI is latched into SCCI.
Output Modes
The output modes are defined by the OUTMOD bits and are described in Table 14-2. The OUTn signal is
changed with the rising edge of the timer clock for all modes except mode 0. Output modes 2, 3, 6, and 7
are not useful for output unit 0 because EQUn = EQU0.
0FFFFh
TAxCCR0
TAxCCR1
0h
0FFFFh
TAxCCR0
TAxCCR1
0h
0FFFFh
TAxCCR0
TAxCCR2
0h
Capture
Set CCIE
EQU0 IRQ, Interrupt Service Requested
D Q
CAP
Timer Clock
Reset
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
7 6 5 4 3 2 1 0
ID MC Unused TACLR TAIE TAIFG
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) w-(0) rw-(0) rw-(0)
7 6 5 4 3 2 1 0
TAxR
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
TAxR Bits 15-0 Timer_A register. The TAxR register is the count of Timer_A.
7 6 5 4 3 2 1 0
OUTMOD CCIE CCI OUT COV CCIFG
rw-(0) rw-(0) rw-(0) rw-(0) r rw-(0) rw-(0) rw-(0)
7 6 5 4 3 2 1 0
0 0 0 0 TAIV 0
r0 r0 r0 r0 r-(0) r-(0) r-(0) r0
7 6 5 4 3 2 1 0
Unused Unused Unused Unused Unused IDEX
r0 r0 r0 r0 r0 rw-(0) rw-(0) rw-(0)
Chapter 15
SLAU259 – May 2009
The Real-Time Clock (RTC_A) module provides clock counters with a calendar, a flexible programmable
alarm, and calibration. This chapter describes the RTC_A module.
RT0PSHOLD
RT0SSEL
RT0IP
EN
ACLK RT0PS
0 3
SMCLK 1 Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
111
110
101 Set_RT0PSIFG
100
011
010
001
000
001
101
011
111
000
100
010
110
RT0PSDIV RTCCALS RTCCAL RTCMODE
3
5
Calibration
RT1SSEL RT1PSHOLD Logic EN
2 RT1IP
EN
00 RT1PS 3
01
10 Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
11 111
110
101 Set_RT1PSIFG
100
011
010
001
000
001
101
011
111
000
100
010
110
RT1PSDIV
3
Set_RTCRDYIFG
Keepout
RTCSSEL Logic
2 RTCBCD RTCHOLD
00
01 EN
10 31 ... 24 23 ... 16 15 ... 8 7 ... 0
11 RTCNT4/ RTCNT3/ RTCNT2/ RTCNT1/ RTCTEV
RTCDOW RTCHOUR RTCMIN RTCSEC
2
8-bit overflow/minute changed
00 Set_RTCTEVIFG
16-bit overflow/hour changed
01
24-bit overflow/midnight
10
32-bit overflow/noon
11
EN
Calendar
RTCYEARH RTCYEARL RTCMON RTCDAY
EN
Set_RTCAIFG
Alarm
RTCADOW RTCADAY RTCAHOUR RTCAMIN
Note: Accessing the RTCNT1, RTCNT2, RTCNT3, RTCNT4, RT0PS, RT1PS registers
When the counter clock is asynchronous to the CPU clock, any read from any RTCNT1,
RTCNT2, RTCNT3, RTCNT4, RT0PS, or RT1PS register should occur while the counter is
not operating. Otherwise, the results may be unpredictable. Alternatively, the counter may be
read multiple times while operating, and a majority vote taken in software to determine the
correct reading. Any write to these registers takes effect immediately.
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
RTCBCD Bit 7 Real-time clock BCD select. Selects BCD counting for real-time clock. Applies to calendar mode
(RTCMODE = 1) only; setting is ignored in counter mode. Changing this bit clears seconds, minutes,
hours, day of week, and year to 0 and sets day of month and month to 1. The real-time clock registers
must be set by software afterwards.
0 Binary/hexadecimal code selected
1 BCD Binary coded decimal (BCD) code selected
RTCHOLD Bit 6 Real-time clock hold
0 Real-time clock (32-bit counter or calendar mode) is operational.
1 In counter mode (RTCMODE = 0), only the 32-bit counter is stopped. In calendar mode
(RTCMODE = 1), the calendar is stopped as well as the prescale counters, RT0PS and RT1PS.
RT0PSHOLD and RT1PSHOLD are don't care.
RTCMODE Bit 5 Real-time clock mode
0 32-bit counter mode
1 Calendar mode. Switching between counter and calendar mode resets the real-time
clock/counter registers. Switching to calendar mode clears seconds, minutes, hours, day of
week, and year to 0 and sets day of month and month to 1. The real-time clock registers must
be set by software afterwards. RT0PS and RT1PS are also cleared.
RTCRDY Bit 4 Real-time clock ready
0 RTC time values in transition (calendar mode only)
1 RTC time values safe for reading (calendar mode only). This bit indicates when the real-time
clock time values are safe for reading (calendar mode only). In counter mode, RTCRDY signal
remains cleared.
RTCSSEL Bits 3-2 Real-time clock source select. Selects clock input source to the RTC/32-bit counter. In calendar mode,
these bits are don't care. The clock input is automatically set to the output of RT1PS.
00 ACLK
01 SMCLK
10 Output from RT1PS
11 Output from RT1PS
RTCTEV Bits 1-0 Real-time clock time event
Real-Time Clock Seconds Register (RTCSEC) – Calendar Mode With Hexadecimal Format
7 6 5 4 3 2 1 0
0 0 Seconds (0 to 59)
r-0 r-0 rw rw rw rw rw rw
Real-Time Clock Seconds Register (RTCSEC) – Calendar Mode With BCD Format
7 6 5 4 3 2 1 0
0 Seconds – high digit (0 to 5) Seconds – low digit (0 to 9)
r-0 rw rw rw rw rw rw rw
Real-Time Clock Minutes Register (RTCMIN) – Calendar Mode With Hexadecimal Format
7 6 5 4 3 2 1 0
0 0 Minutes (0 to 59)
r-0 r-0 rw rw rw rw rw rw
Real-Time Clock Minutes Register (RTCMIN) – Calendar Mode With BCD Format
7 6 5 4 3 2 1 0
0 Minutes – high digit (0 to 5) Minutes – low digit (0 to 9)
r-0 rw rw rw rw rw rw rw
Real-Time Clock Hours Register (RTCHOUR) – Calendar Mode With Hexadecimal Format
7 6 5 4 3 2 1 0
0 0 0 Hours (0 to 24)
r-0 r-0 r-0 rw rw rw rw rw
Real-Time Clock Hours Register (RTCHOUR) – Calendar Mode With BCD Format
7 6 5 4 3 2 1 0
0 0 Hours – high digit (0 to 2) Hours – low digit (0 to 9)
r-0 r-0 rw rw rw rw rw rw
Real-Time Clock Day of Month Register (RTCDAY) – Calendar Mode With Hexadecimal Format
7 6 5 4 3 2 1 0
0 0 0 Day of month (1 to 28, 29, 30, 31)
r-0 r-0 r-0 rw rw rw rw rw
Real-Time Clock Day of Month Register (RTCDAY) – Calendar Mode With BCD Format
7 6 5 4 3 2 1 0
0 0 Day of month – high digit Day of month – low digit (0 to 9)
(0 to 3)
r-0 r-0 rw rw rw rw rw rw
Real-Time Clock Month Register (RTCMON) – Calendar Mode With Hexadecimal Format
7 6 5 4 3 2 1 0
0 0 0 0 Month (1 to 12)
r-0 r-0 r-0 r-0 rw rw rw rw
Real-Time Clock Month Register (RTCMON) – Calendar Mode With BCD Format
7 6 5 4 3 2 1 0
0 0 0 Month – high Month – low digit (0 to 9)
digit (0 to 3)
r-0 r-0 r-0 rw rw rw rw rw
Real-Time Clock Year Low-Byte Register (RTCYEARL) – Calendar Mode With Hexadecimal Format
7 6 5 4 3 2 1 0
Year – low byte of 0 to 4095
rw rw rw rw rw rw rw rw
Real-Time Clock Year Low-Byte Register (RTCYEARL) – Calendar Mode With BCD Format
7 6 5 4 3 2 1 0
Decade (0 to 9) Year – lowest digit (0 to 9)
rw rw rw rw rw rw rw rw
Real-Time Clock Year High-Byte Register (RTCYEARH) – Calendar Mode With Hexadecimal Format
7 6 5 4 3 2 1 0
0 0 0 0 Year – high byte of 0 to 4095
r-0 r-0 r-0 r-0 rw rw rw rw
Real-Time Clock Year High-Byte Register (RTCYEARH) – Calendar Mode With BCD Format
7 6 5 4 3 2 1 0
0 Century – high digit (0 to 4) Century – low digit (0 to 9)
r-0 rw rw rw rw rw rw rw
Real-Time Clock Minutes Alarm Register (RTCAMIN) – Calendar Mode With Hexadecimal Format
7 6 5 4 3 2 1 0
AE 0 Minutes (0 to 59)
rw-0 r-0 rw rw rw rw rw rw
Real-Time Clock Minutes Alarm Register (RTCAMIN) – Calendar Mode With BCD Format
7 6 5 4 3 2 1 0
AE Minutes – high digit (0 to 5) Minutes – low digit (0 to 9)
rw-0 rw rw rw rw rw rw rw
Real-Time Clock Hours Alarm Register (RTCAHOUR) – Calendar Mode With Hexadecimal Format
7 6 5 4 3 2 1 0
AE 0 0 Hours (0 to 24)
rw-0 r-0 r-0 rw rw rw rw rw
Real-Time Clock Hours Alarm Register (RTCAHOUR) – Calendar Mode With BCD Format
7 6 5 4 3 2 1 0
AE 0 Hours – high digit (0 to 2) Hours – low digit (0 to 9)
rw-0 r-0 rw rw rw rw rw rw
Real-Time Clock Day of Month Alarm Register (RTCADAY) – Calendar Mode With Hexadecimal Format
7 6 5 4 3 2 1 0
AE 0 0 Day of month (1 to 28, 29, 30, 31)
rw-0 r-0 r-0 rw rw rw rw rw
Real-Time Clock Day of Month Alarm Register (RTCADAY) – Calendar Mode With BCD Format
7 6 5 4 3 2 1 0
AE 0 Day of month – high digit Day of month – low digit (0 to 9)
(0 to 3)
rw-0 r-0 rw rw rw rw rw rw
7 6 5 4 3 2 1 0
Reserved Reserved Reserved RT0IP RT0PSIE RT0PSIFG
r0 r0 r0 rw-0 rw-0 rw-0 rw-0 rw-(0)
7 6 5 4 3 2 1 0
Reserved Reserved Reserved RT1IP RT1PSIE RT1PSIFG
r0 r0 r0 rw-0 rw-0 rw-0 rw-0 rw-(0)
RT1SSEL Bits 15-14 Prescale timer 1 clock source select. Selects clock input source to the RT1PS counter. In real-time clock
calendar mode, these bits are do not care. RT1PS clock input is automatically set to the output of
RT0PS.
00 ACLK
01 SMCLK
10 Output from RT0PS
11 Output from RT0PS
RT1PSDIV Bits 13-11 Prescale timer 1 clock divide. These bits control the divide ratio of the RT0PS counter. In real-time clock
calendar mode, these bits are don't care for RT0PS and RT1PS. RT0PS clock output is automatically set
to /256. RT1PS clock output is automatically set to /128.
000 /2
001 /4
010 /8
011 /16
100 /32
101 /64
110 /128
111 /256
Reserved Bits 10-9 Reserved. Always read as 0.
RT1PSHOLD Bit 8 Prescale timer 1 hold. In real-time clock calendar mode, this bit is don't care. RT1PS is stopped via the
RTCHOLD bit.
0 RT1PS is operational.
1 RT1PS is held.
Reserved Bits 7-5 Reserved. Always read as 0.
RT1IP Bits 4-2 Prescale timer 1 interrupt interval
000 /2
001 /4
010 /8
011 /16
100 /32
101 /64
110 /128
111 /256
RT1PSIE Bit 1 Prescale timer 1 interrupt enable
0 Interrupt not enabled
1 Interrupt enabled
RT1PSIFG Bit 0 Prescale timer 1 interrupt flag
0 No time event occurred.
1 Time event occurred.
7 6 5 4 3 2 1 0
0 0 RTCIV 0
r0 r0 r0 r-(0) r-(0) r-(0) r-(0) r0
RTCIV Interrupt
Interrupt Source Interrupt Flag
Contents Priority
00h No interrupt pending
02h RTC ready RTCRDYIFG Highest
04h RTC interval timer RTCTEVIFG
06h RTC user alarm RTCAIFG
08h RTC prescaler 0 RT0PSIFG
0Ah RTC prescaler 1 RT1PSIFG
0Ch Reserved
0Eh Reserved
10h Reserved Lowest
Chapter 16
SLAU259 – May 2009
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.
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 409
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
410 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 411
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Figure 16-1 shows the USCI_Ax when configured for 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
412 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 413
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
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, UCRXIFG 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 UCRXIFG 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 are received. When UCDORM is cleared
during the reception of a character, the receive interrupt flag is 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.
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 (UCTXIFG = 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 (UCTXIFG =
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 is misinterpreted as an address.
414 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCAxTXD/UCAxRXD
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 415
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
For LIN conformance, the character format should be set to eight 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 (see Figure 16-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 UCRXIFG interrupt flag is set. Any applicable error flag is also set. If the UCBRKIE
bit is set, reception of the break/synch sets the UCRXIFG. 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 is received. The
UCDORM bit is not modified by the USCI hardware automatically.
When UCDORM = 0, all received characters set the receive interrupt flag UCRXIFG. If UCDORM is
cleared during the reception of a character, the receive interrupt flag is set after the reception is complete.
The counter used to detect the baud rate is limited to 07FFFh (32767) counts. This means the minimum
baud rate detectable is 488 baud in oversampling mode and 30 baud in low-frequency mode.
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.
416 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
IrDA Encoding
The encoder sends a pulse for every zero bit in the transmit bit stream coming from the UART (see
Figure 16-7). The pulse duration is defined by UCIRTXPLx bits specifying the number of one-half clock
periods of the clock selected by UCIRTXCLK.
Start Stop
Bit Data Bits Bit
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 six one-half clock cycles with UCIRTXPLx = 6 – 1 = 5.
When UCIRTXCLK = 0, the pulse length tPULSE is based on BRCLK and is calculated as:
UCIRTXPLx = tPULSE × 2 × fBRCLK – 1
When UCIRTXCLK = 0 ,the prescaler UCBRx must to be set to a value greater or equal to 5.
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 width
tWAKE = Wake time from any low-power mode. Zero when the device is in active mode.
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 417
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
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 any of the UCFE, UCPE, UCOE, UCBRK, or UCRXERR bit is set, the bit remains set until user
software resets it or UCAxRXBUF is read. UCOE must be reset by reading UCAxRXBUF. Otherwise, it
does not function properly. To detect overflows reliably the following flow is recommended. After a
character was received and UCAxRXIFG is set, first read UCAxSTAT to check the error flags including the
overflow flag UCOE. Read UCAxRXBUF next. This clears all error flags except UCOE, if UCAxRXBUF
was overwritten between the read access to UCAxSTAT and to UCAxRXBUF. Therefore, the UCOE flag
should be checked after reading UCAxRXBUF to detect this condition. Note that, in this case, the
UCRXERR flag is not set.
418 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCAxRXD
URXS
tt
When a glitch is longer than tt, or a valid start bit occurs on UCAxRXD, the USCI receive operation is
started and a majority vote is taken (see Figure 16-9). If the majority vote fails to detect a start bit, the
USCI halts character reception.
Majority Vote Taken
URXS
tt
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 419
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
BRCLK
BITCLK
Bit Period
m: corresponding modulation bit
R: Remainder from N/2 division
Modulation is based on the UCBRSx setting (see Table 16-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 eight bits but restarts with each new start bit.
420 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 421
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Sm
j=0
UCBRFx [j]
= Sum of ones from the corresponding row in Table 16-3
mUCBRSx[i] = Modulation of bit i from Table 16-2
422 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
To calculate bit error, this time is compared to the ideal bit time tbit,ideal,TX[i]:
tbit,ideal,TX[i] = (1/Baudrate)(i + 1)
This results in an error normalized to one ideal bit time (1/baudrate):
ErrorTX[i] = (tbit,TX[i] – tbit,ideal,TX[i]) × Baudrate × 100%
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.
Where:
Tbit,RX[i] = (1/fBRCLK)(UCBRx + mUCBRSx[i])
mUCBRSx[i] = Modulation of bit i from Table 16-2
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 423
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
S mUCBRFx[j]
j=0 = Sum of ones from columns 0 to (7 + mUCBRSx[i]) from the corresponding row in
Table 16-3.
mUCBRSx[i] = Modulation of bit i from Table 16-2
This results in an error normalized to one ideal bit time (1/baudrate) according to the following formula:
ErrorRX[i] = (tbit,RX[i] – tbit,ideal,RX[i]) × Baudrate × 100%
Table 16-4. Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 0
BRCLK
Baud Rate Maximum TX Error Maximum RX Error
Frequency UCBRx UCBRSx UCBRFx
(baud) (%) (%)
(Hz)
32,768 1200 27 2 0 -2.8 1.4 -5.9 2.0
32,768 2400 13 6 0 -4.8 6.0 -9.7 8.3
32,768 4800 6 7 0 -12.1 5.7 -13.4 19.0
32,768 9600 3 3 0 -21.1 15.2 -44.3 21.3
1,000,000 9600 104 1 0 -0.5 0.6 -0.9 1.2
1,000,000 19200 52 0 0 -1.8 0 -2.6 0.9
1,000,000 38400 26 0 0 -1.8 0 -3.6 1.8
1,000,000 57600 17 3 0 -2.1 4.8 -6.8 5.8
1,000,000 115200 8 6 0 -7.8 6.4 -9.7 16.1
1,048,576 9600 109 2 0 -0.2 0.7 -1.0 0.8
1,048,576 19200 54 5 0 -1.1 1.0 -1.5 2.5
1,048,576 38400 27 2 0 -2.8 1.4 -5.9 2.0
1,048,576 57600 18 1 0 -4.6 3.3 -6.8 6.6
1,048,576 115200 9 1 0 -1.1 10.7 -11.5 11.3
4,000,000 9600 416 6 0 -0.2 0.2 -0.2 0.4
4,000,000 19200 208 3 0 -0.2 0.5 -0.3 0.8
4,000,000 38400 104 1 0 -0.5 0.6 -0.9 1.2
4,000,000 57600 69 4 0 -0.6 0.8 -1.8 1.1
4,000,000 115200 34 6 0 -2.1 0.6 -2.5 3.1
4,000,000 230400 17 3 0 -2.1 4.8 -6.8 5.8
424 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Table 16-4. Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 0 (continued)
BRCLK
Baud Rate Maximum TX Error Maximum RX Error
Frequency UCBRx UCBRSx UCBRFx
(baud) (%) (%)
(Hz)
4,194,304 9600 436 7 0 -0.3 0 -0.3 0.2
4,194,304 19200 218 4 0 -0.2 0.2 -0.3 0.6
4,194,304 57600 72 7 0 -1.1 0.6 -1.3 1.9
4,194,304 115200 36 3 0 -1.9 1.5 -2.7 3.4
8,000,000 9600 833 2 0 -0.1 0 -0.2 0.1
8,000,000 19200 416 6 0 -0.2 0.2 -0.2 0.4
8,000,000 38400 208 3 0 -0.2 0.5 -0.3 0.8
8,000,000 57600 138 7 0 -0.7 0 -0.8 0.6
8,000,000 115200 69 4 0 -0.6 0.8 -1.8 1.1
8,000,000 230400 34 6 0 -2.1 0.6 -2.5 3.1
8,000,000 460800 17 3 0 -2.1 4.8 -6.8 5.8
8,388,608 9600 873 7 0 -0.1 0.06 -0.2 0,1
8,388,608 19200 436 7 0 -0.3 0 -0.3 0.2
8,388,608 57600 145 5 0 -0.5 0.3 -1.0 0.5
8,388,608 115200 72 7 0 -1.1 0.6 -1.3 1.9
12,000,000 9600 1250 0 0 0 0 -0.05 0.05
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 57600 208 2 0 -0.5 0.2 -0.6 0.5
12,000,000 115200 104 1 0 -0.5 0.6 -0.9 1.2
12,000,000 230400 52 0 0 -1.8 0 -2.6 0.9
12,000,000 460800 26 0 0 -1.8 0 -3.6 1.8
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 57600 277 7 0 -0.3 0.3 -0.5 0.4
16,000,000 115200 138 7 0 -0.7 0 -0.8 0.6
16,000,000 230400 69 4 0 -0.6 0.8 -1.8 1.1
16,000,000 460800 34 6 0 -2.1 0.6 -2.5 3.1
16,777,216 9600 1747 5 0 -0.04 0.03 -0.08 0.05
16,777,216 19200 873 7 0 -0.09 0.06 -0.2 0.1
16,777,216 57600 291 2 0 -0.2 0.2 -0.5 0.2
16,777,216 115200 145 5 0 -0.5 0.3 -1.0 0.5
20,000,000 9600 2083 2 0 -0.05 0.02 -0.09 0.02
20,000,000 19200 1041 6 0 -0.06 0.06 -0.1 0.1
20,000,000 38400 520 7 0 -0.2 0.06 -0.2 0.2
20,000,000 57600 347 2 0 -0.06 0.2 -0.3 0.3
20,000,000 115200 173 5 0 -0.4 0.3 -0.8 0.5
20,000,000 230400 86 7 0 -1.0 0.6 -1.0 1.7
20,000,000 460800 43 3 0 -1.4 1.3 -3.3 1.8
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 425
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Table 16-5. Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 1
BRCLK
Baud Rate Maximum TX Error Maximum RX Error
Frequency UCBRx UCBRSx UCBRFx
(baud) (%) (%)
(Hz)
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,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
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,194,304 9600 27 0 5 0 0.2 0 0.5
4,194,304 19200 13 0 10 -2.3 0 -2.4 0.1
4,194,304 57600 4 4 7 -2.5 2.5 -1.3 5.1
4,194,304 115200 2 6 3 -3.9 2.0 -1.9 6.7
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,388,608 9600 54 0 10 0 0.2 -0.05 0.3
8,388,608 19200 27 0 5 0 0.2 0 0.5
8,388,608 57600 9 0 2 0 2.8 -0.2 3.0
8,388,608 115200 4 4 7 -2.5 2.5 -1.3 5.1
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
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
16,777,216 9600 109 0 4 0 0.2 -0.02 0.3
16,777,216 19200 54 0 10 0 0.2 -0.05 0.3
16,777,216 57600 18 0 3 -1.0 0 -1.0 0.3
16,777,216 115200 9 0 2 0 2.8 -0.2 3.0
20,000,000 9600 130 0 3 -0.2 0 -0.2 0.04
20,000,000 19200 65 0 2 0 0.4 -0.03 0.4
20,000,000 38400 32 0 9 0 0.4 0 0.5
20,000,000 57600 21 0 11 -0.7 0 -0.7 0.3
20,000,000 115200 10 0 14 0 2.5 -0.2 2.6
426 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Table 16-5. Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 1 (continued)
BRCLK
Baud Rate Maximum TX Error Maximum RX Error
Frequency UCBRx UCBRSx UCBRFx
(baud) (%) (%)
(Hz)
20,000,000 230400 5 0 7 0 2.5 0 3.5
20,000,000 460800 2 6 10 -3.2 1.8 -2.8 4.6
16.3.14 Using the USCI Module in UART Mode With Low-Power Modes
The USCI module provides automatic clock activation for use with low-power modes. When the USCI
clock source 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.
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 427
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
428 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 429
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
430 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCSSELx Bits 7-6 USCI clock source select. These bits select the BRCLK source clock.
00 UCLK
01 ACLK
10 SMCLK
11 SMCLK
UCRXEIE Bit 5 Receive erroneous-character interrupt enable
0 Erroneous characters rejected and UCRXIFG is not set.
1 Erroneous characters received set UCRXIFG.
UCBRKIE Bit 4 Receive break character interrupt enable
0 Received break characters do not set UCRXIFG.
1 Received break characters set UCRXIFG.
UCDORM Bit 3 Dormant. Puts USCI into sleep mode.
0 Not dormant. All received characters set UCRXIFG.
1 Dormant. Only characters that are preceded by an idle-line or with address bit set UCRXIFG. In UART
mode with automatic baud-rate detection, only the combination of a break and synch field sets
UCRXIFG.
UCTXADDR Bit 2 Transmit address. Next frame to be transmitted is marked as address, depending on the selected
multiprocessor mode.
0 Next frame transmitted is data.
1 Next frame transmitted is an address.
UCTXBRK Bit 1 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 fields.
Otherwise, 0h must be written into the transmit buffer.
0 Next frame transmitted is not a break.
1 Next frame transmitted is a break or a break/synch.
UCSWRST Bit 0 Software reset enable
0 Disabled. USCI reset released for operation.
1 Enabled. USCI logic held in reset state.
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 431
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCBRx Clock prescaler setting of the baud-rate generator. The 16-bit value of (UCAxBR0 + UCAxBR1 × 256) forms the prescaler
value UCBRx.
UCBRFx Bits 7-4 First modulation stage select. These bits determine the modulation pattern for BITCLK16 when UCOS16 = 1.
Ignored with UCOS16 = 0. Table 16-3 shows the modulation pattern.
UCBRSx Bits 3-1 Second modulation stage select. These bits determine the modulation pattern for BITCLK. Table 16-2 shows
the modulation pattern.
UCOS16 Bit 0 Oversampling mode enabled
0 Disabled
1 Enabled
432 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCLISTEN Bit 7 Listen enable. The UCLISTEN bit selects loopback mode.
0 Disabled
1 Enabled. UCAxTXD is internally fed back to the receiver.
UCFE Bit 6 Framing error flag
0 No error
1 Character received with low stop bit
UCOE Bit 5 Overrun error flag. This bit is set when a character is transferred into UCAxRXBUF before the previous
character was read. UCOE is cleared automatically when UCxRXBUF is read, and must not be cleared by
software. Otherwise, it does not function correctly.
0 No error
1 Overrun error occurred.
UCPE Bit 4 Parity error flag. When UCPEN = 0, UCPE is read as 0.
0 No error
1 Character received with parity error
UCBRK Bit 3 Break detect flag
0 No break condition
1 Break condition occurred.
UCRXERR Bit 2 Receive error flag. This bit indicates a character was received with error(s). When UCRXERR = 1, on or more
error flags, UCFE, UCPE, or UCOE is also set. UCRXERR is cleared when UCAxRXBUF is read.
0 No receive errors detected
1 Receive error detected
UCADDR Bit 1 Address received in address-bit multiprocessor mode. UCADDR is cleared when UCAxRXBUF is read.
0 Received character is data.
1 Received character is an address.
UCIDLE Idle line detected in idle-line multiprocessor mode. UCIDLE is cleared when UCAxRXBUF is read.
0 No idle line detected
1 Idle line detected
UCBUSY Bit 0 USCI busy. This bit indicates if a transmit or receive operation is in progress.
0 USCI inactive
1 USCI transmitting or receiving
UCRXBUFx Bits 7-0 The receive-data buffer is user accessible and contains the last received character from the receive shift
register. Reading UCAxRXBUF resets the receive-error bits, the UCADDR or UCIDLE bit, and UCRXIFG. In
7-bit data mode, UCAxRXBUF is LSB justified and the MSB is always reset.
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 433
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCTXBUFx Bits 7-0 The transmit data buffer is user accessible and holds the data waiting to be moved into the transmit shift
register and transmitted on UCAxTXD. Writing to the transmit data buffer clears UCTXIFG. The MSB of
UCAxTXBUF is not used for 7-bit data and is reset.
UCIRRXFLx Bits 7-2 Receive filter length. The minimum pulse length for receive is given by:
tMIN = (UCIRRXFLx + 4) / (2 × fIRTXCLK)
UCIRRXPL Bit 1 IrDA receive input UCAxRXD polarity
0 IrDA transceiver delivers a high pulse when a light pulse is seen.
1 IrDA transceiver delivers a low pulse when a light pulse is seen.
UCIRRXFE Bit 0 IrDA receive filter enabled
0 Receive filter disabled
1 Receive filter enabled
434 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – UART Mode 435
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
0 0 0 0 0 UCIVx 0
r0 r0 r0 r-0 r-0 r-0 r-0 r0
UCAxIV
Interrupt Source Interrupt Flag Interrupt Priority
Contents
000h No interrupt pending
002h Data received UCRXIFG Highest
004h Transmit buffer empty UCTXIFG Lowest
436 Universal Serial Communication Interface – UART Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Chapter 17
SLAU259 – May 2009
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 (SPI)
mode.
SLAU259 – May 2009 Universal Serial Communication Interface – SPI Mode 437
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
438 Universal Serial Communication Interface – SPI Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – SPI Mode 439
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
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
440 Universal Serial Communication Interface – SPI Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – SPI Mode 441
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
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
Figure 17-2 shows the USCI as a master in both 3-pin and 4-pin configurations. The USCI initiates data
transfer when data is moved to the transmit data buffer UCxTXBUF. The UCxTXBUF data is moved to the
transmit (TX) shift register when the TX shift register is empty, initiating data transfer on UCxSIMO starting
with either the MSB or LSB, depending on the UCMSB setting. Data on UCxSOMI is shifted into the
receive shift register on the opposite clock edge. When the character is received, the receive data is
moved from the receive (RX) shift register to the received data buffer UCxRXBUF and the receive
interrupt flag UCRXIFG is set, indicating the RX/TX operation is complete.
A set transmit interrupt flag, UCTXIFG, 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.
4-Pin SPI Master Mode
In 4-pin master mode, UCxSTE is used to prevent conflicts with another master and controls the master
as described in Table 17-1. When UCxSTE is in the master-inactive state:
• UCxSIMO and UCxCLK are set to inputs and no longer drive the bus.
• The error bit UCFE is set, indicating a communication integrity violation to be handled by the user.
• The internal state machines are reset and the shift operation is aborted.
If data is written into UCxTXBUF while the master is held inactive by UCxSTE, it is transmit as soon as
UCxSTE transitions to the master-active state. If an active transfer is aborted by UCxSTE transitioning to
the master-inactive state, the data must be rewritten into UCxTXBUF to be transferred when UCxSTE
transitions back to the master-active state. The UCxSTE input signal is not used in 3-pin master mode.
442 Universal Serial Communication Interface – SPI Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Receive Buffer
SPI Receive Buffer Transmit Buffer UCxTXBUF UCxRXBUF
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
Figure 17-3 shows the USCI as a slave in both 3-pin and 4-pin configurations. UCxCLK 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 bit clock generator. Data written to UCxTXBUF and moved to the TX
shift register before the start of UCxCLK is transmitted on UCxSOMI. Data on UCxSIMO is shifted into the
receive shift register on the opposite edge of UCxCLK and moved to UCxRXBUF when the set number of
bits are received. When data is moved from the RX shift register to UCxRXBUF, the UCRXIFG interrupt
flag is set, indicating that data has been received. The overrun error bit UCOE is set when the previously
received data is not read from UCxRXBUF before new data is moved to UCxRXBUF.
4-Pin SPI Slave Mode
In 4-pin slave mode, UCxSTE is used by the slave to enable the transmit and receive operations and is
provided by the SPI master. When UCxSTE is in the slave-active state, the slave operates normally.
When UCxSTE is in the slave- inactive state:
• Any receive operation in progress on UCxSIMO is halted.
• UCxSOMI is set to the input direction.
• The shift operation is halted until the UCxSTE line transitions into the slave transmit active state.
The UCxSTE input signal is not used in 3-pin slave mode.
SLAU259 – May 2009 Universal Serial Communication Interface – SPI Mode 443
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
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
444 Universal Serial Communication Interface – SPI Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – SPI Mode 445
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
446 Universal Serial Communication Interface – SPI Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCSSELx Bits 7-6 USCI clock source select. These bits select the BRCLK source clock in master mode. UCxCLK is
always used in slave mode.
00 NA
01 ACLK
10 SMCLK
11 SMCLK
Unused Bits 5-1 Unused
UCSWRST Bit 0 Software reset enable
0 Disabled. USCI reset released for operation.
1 Enabled. USCI logic held in reset state.
(1)
UCAxCTL1 (USCI_Ax)
(2)
UCBxCTL1 (USCI_Bx)
SLAU259 – May 2009 Universal Serial Communication Interface – SPI Mode 447
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCBRx Bits 7-0 Bit clock prescaler. The 16-bit value of (UCxxBR0 + UCxxBR1 × 256) forms the prescaler value UCBRx.
448 Universal Serial Communication Interface – SPI Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCLISTEN Bit 7 Listen enable. The UCLISTEN bit selects loopback mode.
0 Disabled
1 Enabled. The transmitter output is internally fed back to the receiver.
UCFE Bit 6 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.
0 No error
1 Bus conflict occurred.
UCOE Bit 5 Overrun error flag. This bit is set when a character is transferred into UCxRXBUF before the previous
character was read. UCOE is cleared automatically when UCxRXBUF is read, and must not be cleared
by software. Otherwise, it does not function correctly.
0 No error
1 Overrun error occurred.
Unused Bits 4-1 Unused
UCBUSY Bit 0 USCI busy. This bit indicates if a transmit or receive operation is in progress.
0 USCI inactive
1 USCI transmitting or receiving
(1)
UCAxSTAT (USCI_Ax)
(2)
UCBxSTAT (USCI_Bx)
UCRXBUFx Bits 7-0 The receive-data buffer is user accessible and contains the last received character from the receive shift
register. Reading UCxRXBUF resets the receive-error bits and UCRXIFG. In 7-bit data mode,
UCxRXBUF is LSB justified and the MSB is always reset.
UCTXBUFx Bits 7-0 The transmit data buffer is user accessible and holds the data waiting to be moved into the transmit shift
register and transmitted. Writing to the transmit data buffer clears UCTXIFG. The MSB of UCxTXBUF is
not used for 7-bit data and is reset.
SLAU259 – May 2009 Universal Serial Communication Interface – SPI Mode 449
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
0 0 0 0 0 UCIVx 0
r0 r0 r0 r-0 r-0 r-0 r-0 r0
UCAxIV/
UCBxIV Interrupt Source Interrupt Flag Interrupt Priority
Contents
000h No interrupt pending –
002h Data received UCRXIFG Highest
004h Transmit buffer empty UCTXIFG Lowest
450 Universal Serial Communication Interface – SPI Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Chapter 18
SLAU259 – May 2009
The universal serial communication interface (USCI) supports multiple serial communication modes with
one hardware module. This chapter discusses the operation of the I2C mode.
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 451
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
452 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 453
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
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
454 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
VCC
MSP430 Device A
Device B Device C
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 455
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SDA
MSB Acknowledgement Acknowledgement
Signal From Receiver Signal From Receiver
SCL
START 1 2 7 8 9 1 2 8 9 STOP
Condition (S) R/W ACK ACK Condition (P)
START and STOP conditions are generated by the master and are shown in Figure 18-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 (see Figure 18-4). The high and low state of
SDA can only change when SCL is low, otherwise START or STOP conditions are generated.
Data Line
Stable Data
SDA
SCL
456 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
10-Bit Addressing
In the 10-bit addressing format (see Figure 18-6), the first byte is made up of 11110b plus the two MSBs
of the 10-bit slave address and the R/W bit. The ACK bit is sent from the receiver after each byte. The
next byte is the remaining eight bits of the 10-bit slave address, followed by the ACK bit and the 8-bit data.
See I2C Slave 10-bit Addressing Mode and I2C Master 10-bit Addressing Mode for details how to use the
10-bit addressing mode with the USCI module.
1 7 1 1 8 1 8 1 1
S Slave Address 1st byte R/W ACK Slave Address 2nd byte ACK Data ACK P
1 1 1 1 0 X X
S Slave Address R/W ACK Data ACK S Slave Address R/W ACK Data ACK P
1 Any 1 Any Number
Number
Figure 18-7. I2C Module Addressing Format With Repeated START Condition
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 457
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Other Master
Other Slave
USCI Master
USCI Slave
Slave Mode
The USCI module is configured as an I2C slave by selecting the I2C mode with UCMODEx = 11 and
UCSYNC = 1 and clearing the UCMST bit.
Initially, the USCI module must to be configured in receiver mode by clearing the UCTR bit to receive the
I2C address. Afterwards, transmit and receive operations are controlled automatically, depending on the
R/W bit received together with the slave address.
The USCI slave address is programmed with the UCBxI2COA register. When UCA10 = 0, 7-bit addressing
is selected. When UCA10 = 1, 10-bit addressing is selected. The UCGCEN bit selects if the slave
responds to a general call.
When a START condition is detected on the bus, the USCI module receives 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.
458 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCTXIFG=0
UCTR=1 (Transmitter)
UCSTTIFG=1
UCTXIFG=1
UCBxTXBUF discarded
UCTXIFG=0
UCALIFG=1
UCMST=0
UCTR=1 (Transmitter)
UCSTTIFG=1
UCTXIFG=1
UCSTPIFG=0
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 459
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
460 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
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)
UCTXIFG=0
UCSTPIFG=0
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 461
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Slave Transmitter
UCTR=1 (Transmitter)
UCSTTIFG=1
UCTXIFG=1
UCSTPIFG=0
Master Mode
The USCI module is configured as an I2C master by selecting the I2C mode with UCMODEx = 11 and
UCSYNC = 1 and setting the UCMST bit. When the master is part of a multi-master system, UCMM must
be set and its own address must be programmed into the UCBxI2COA register. When UCA10 = 0, 7-bit
addressing is selected. When UCA10 = 1, 10-bit addressing is selected. The UCGCEN bit selects if the
USCI module responds to a general call.
462 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
The data written into UCBxTXBUF is transmitted if arbitration is not lost during transmission of the slave
address. UCTXIFG is set again as soon as the data is transferred from the buffer into the shift register. If
there is no data loaded to UCBxTXBUF before the acknowledge cycle, the bus is held during the
acknowledge cycle with SCL low until data is written into UCBxTXBUF. Data is transmitted or the bus is
held, as long as the UCTXSTP bit or UCTXSTT bit is not set.
Setting UCTXSTP generates a STOP condition after the next acknowledge from the slave. If UCTXSTP is
set during the transmission of the slave's address or while the USCI module waits for data to be written
into UCBxTXBUF, a STOP condition is generated, even if no data was transmitted to the slave. When
transmitting a single byte of data, the UCTXSTP bit must be set while the byte is being transmitted or
anytime after transmission begins, without writing new data into UCBxTXBUF. Otherwise, only the
address is transmitted. When the data is transferred from the buffer to the shift register, UCTXIFG is set,
indicating data transmission has begun, and the UCTXSTP bit may be set.
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.
If the slave does not acknowledge the transmitted data, the not-acknowledge interrupt flag UCNACKIFG is
set. The master must react with either a STOP condition or a repeated START condition. If data was
already written into UCBxTXBUF, it is discarded. If this data should be transmitted after a repeated
START, it must be written into UCBxTXBUF again. Any set UCTXSTT is also discarded. To trigger a
repeated START, UCTXSTT must be set again.
Figure 18-12 shows the I2C master transmitter operation.
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 463
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
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
UCTXIFG=0
UCBxTXBUF discarded
1) UCTR=0 (Receiver)
2) UCTXSTT=1
UCTXSTP=1 3) UCTXIFG=0
Not acknowledge A P
received after slave UCTXSTP=0
address
1) UCTR=1 (Transmitter)
2) UCTXSTT=1
S SLA/W
UCTXIFG=1
UCBxTXBUF discarded
UCNACKIFG=1
UCTXIFG=0
UCBxTXBUF discarded
UCALIFG=1
UCMST=0
(UCSTTIFG=0)
UCALIFG=1
UCMST=0
UCTR=0 (Receiver)
UCSTTIFG=1
(UCGC=1 if general call)
UCTXIFG=0
UCSTPIFG=0
USCI continues as Slave Receiver
464 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 465
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
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
UCTXIFG=1
UCALIFG=1
UCMST=0
(UCSTTIFG=0)
UCALIFG=1
UCMST=0
UCTR=1 (Transmitter)
UCSTTIFG=1
UCTXIFG=1
UCSTPIFG=0
USCI continues as Slave Transmitter
466 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Successful A A A A
transmission to a S 11110xx/W SLA(2.) DATA DATA P
slave receiver
Master Receiver
UCTXSTP=1
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 467
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Arbitration www.ti.com
Arbitration
If two or more master transmitters simultaneously start a transmission on the bus, an arbitration procedure
is invoked. Figure 18-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
n and Switches Off
Data From
Device #1
1
0 0 0
Data From
Device #2
1 1 1
0 0 0
Bus Line
SDA
1 1 1
Figure 18-15. Arbitration Procedure Between Two Master Transmitters
468 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
www.ti.com Arbitration
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
SCL From
Device #2
Bus Line
SCL
Figure 18-16. Synchronization of Two I2C Clock Generators During Arbitration
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 469
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Clock Stretching
The USCI module supports clock stretching and also makes use of this feature as described in the
Operation Mode sections.
The UCSCLLOW bit can be used to observe if another device pulls SCL low while the USCI module
already released SCL due to the following conditions:
• USCI is acting as master and a connected slave drives SCL low.
• USCI is acting as master and another master drives SCL low during arbitration.
The UCSCLLOW bit is also active if the USCI holds SCL low because it is waiting as transmitter for data
being written into UCBxTXBUF or as receiver for the data being read from UCBxRXBUF.
The UCSCLLOW bit might get set for a short time with each rising SCL edge because the logic observes
the external SCL and compares it to the internally generated SCL.
18.3.6 Using the USCI Module in I2C Mode With Low-Power Modes
The USCI module provides automatic clock activation for use with low-power modes. When the USCI
clock source 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.
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.
470 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 471
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
472 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 473
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
474 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCSSELx Bits 7-6 USCI clock source select. These bits select the BRCLK source clock.
00 UCLKI
01 ACLK
10 SMCLK
11 SMCLK
Unused Bit 5 Unused
UCTR Bit 4 Transmitter/receiver
0 Receiver
1 Transmitter
UCTXNACK Bit 3 Transmit a NACK. UCTXNACK is automatically cleared after a NACK is transmitted.
0 Acknowledge normally
1 Generate NACK
UCTXSTP Bit 2 Transmit STOP condition in master mode. Ignored in slave mode. In master receiver mode, the STOP
condition is preceded by a NACK. UCTXSTP is automatically cleared after STOP is generated.
0 No STOP generated
1 Generate STOP
UCTXSTT Bit 1 Transmit START condition in master mode. Ignored in slave mode. In master receiver mode, a repeated
START condition is preceded by a NACK. UCTXSTT is automatically cleared after START condition and
address information is transmitted. Ignored in slave mode.
0 Do not generate START condition
1 Generate START condition
UCSWRST Bit 0 Software reset enable
0 Disabled. USCI reset released for operation.
1 Enabled. USCI logic held in reset state.
UCBRx Bits 7-0 Bit clock prescaler. The 16-bit value of (UCxxBR0 + UCxxBR1 × 256) forms the prescaler value UCBRx.
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 475
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
UCRXBUFx Bits 7-0 The receive-data buffer is user accessible and contains the last received character from the receive shift
register. Reading UCBxRXBUF resets UCRXIFG.
UCTXBUFx Bits 7-0 The transmit data buffer is user accessible and holds the data waiting to be moved into the transmit shift
register and transmitted. Writing to the transmit data buffer clears UCTXIFG.
476 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
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
I2CSAx Bits 9-0 I2C slave address. The I2CSAx bits contain the slave address of the external device to be addressed by
the USCI_Bx module. It is only used in master mode. The address is right justified. In 7-bit slave
addressing mode, bit 6 is the MSB and bits 9-7 are ignored. In 10-bit slave addressing mode, bit 9 is the
MSB.
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 477
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
478 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
7 6 5 4 3 2 1 0
0 0 0 0 UCIVx 0
r0 r0 r0 r0 r-0 r-0 r-0 r0
UCBxIV
Interrupt Source Interrupt Flag Interrupt Priority
Contents
000h No interrupt pending –
002h Arbitration lost UCALIFG Highest
004h Not acknowledgement UCNACKIFG
006h Start condition received UCSTTIFG
008h Stop condition received UCSTPIFG
00Ah Data received UCRXIFG
00Ch Transmit buffer empty UCTXIFG Lowest
SLAU259 – May 2009 Universal Serial Communication Interface – I2C Mode 479
Submit Documentation Feedback
480 Universal Serial Communication Interface – I2C Mode SLAU259 – May 2009
Submit Documentation Feedback
ECCN 5E002 TSPA - Technology / Software Publicly Available.
Chapter 19
SLAU259 – May 2009
This chapter describes the RF1A module for frequencies below 1 GHz, which is based on the stand-alone
radio device CC1101.
Radio Control
Demodulator
ADC
RX FIFO
LNA
ADC
Inteface to MCU
Packet Handler
RF_P 0 Frequency
Synthesizer
RF_N 90
PA
Modulator
TX FIFO
INSTRB DINB
INSTRW DINW
GDO0
Direct access to CCIO
TX FIFO Interrupt
Logic
TXFIFO GDOx
CC Radio Core
TX FIFO RX FIFO
RXFIFO
Direct access to
RX FIFO
STATW DOUTW
STATB DOUTB
The communication between the radio interface and the radio core takes place via the logical channels
shown in Figure 19-3. Every instruction presented to the core results in a status update sent to the
interface, and every data byte sent to the radio core results in a data byte transmitted back to the
interface. Depending on the instruction, some data in either direction can be "dummy" or "don't care" data.
To avoid "dummy" writes, an auto-read feature is implemented.
Logical Channels
Radio Core
Registers
STATW STATB Status (8 bit)
(accessible via
instructions)
DINB
Data In
DINW
RX TX
DOUTB FIFO FIFO
Data Out
DOUTW
Figure 19-3. Logical Channels Between Radio Interface and Radio Core
Data can be read from the radio core using the word data register RF1ADOUTW or the byte data register
RF1ADOUTB. Using these registers, the same amount of data that should be read needs to written to the
RF1ADIN registers before reading the RF1ADOUT registers (even though the written data might be
ignored by the radio core). Otherwise the OUTERR flag is set. Also, if the radio core is still processing the
instruction and has not provided any data yet, the OUTERR flag is set.
For word reads, the endianness of the data can be selected with RFENDIAN, similar to the process
described previously.
A 16-bit word is read from the radio core by reading it from RF1ADOUTW.
A byte is read from the radio core by reading it from RF1ADOUTB. A byte access to the low byte of the
RF1ADOUTW register behaves identical to accessing RF1ADOUTB.
Delayed Write/Read
If a read or write access from the CPU to one of the radio interface registers would cause an error
condition, the CPU is stalled for up to four CPU clock cycles or until the error condition is resolved. If the
four CPU clock cycles expire without the error condition being resolved, the read or write access is
executed to avoid possible deadlock situations. This causes the corresponding error flag to be set.
Error Flags
Table 19-3 lists the interface error conditions and its flags. There is also a error vector generator register,
RF1AERRV, that allows decoding the error condition using the same mechanisms as with the interrupt
vector word registers. Any read access of the RF1AERRV register automatically resets the highest
pending error flag. If another error flag is set, the RFERRIFG interrupt flag remains set, and another
interrupt is immediately generated after servicing the initial interrupt. A write access to the RF1AERRV
register automatically resets all error flags. In addition, all error flags can be cleared via software.
The flags are provided to easy software debugging. Ideally a production ready software should never see
any radio interface errors.
Examples
// OPERR - not enough operands
RF1AINSTRB = SNGLREGWR+0x00; // Write radio core register IOCFG2, expects 1 byte
RF1AINSTRB = SNOP; // Error!
//=> OPERR flag set,
// no operand provided for previous instruction
// OPOVERR
RF1AINSTRB = REGWR+0x00; // Write radio core registers starting with IOCFG2
RF1ADINB = 0x00;
RF1ADINB = 0x01;
//=> OPOVERR flag set and data ignored,
// if synchronization of data between the interface and the core takes too long
// OUTERR
RF1AINSTRB = REGRD+0x00; // Read radio core registers starting with IOCFG2
data= RF1ADOUTB; // Error!
//=> OUTERR flag set, because dummy data write is missing
The radio core interrupt flags are prioritized and combined to source a single interrupt vector together with
the radio interface interrupts. The interrupt vector register RF1AIV is used to determine which radio core
interrupt flag requested an interrupt. The highest priority enabled interrupt generates a number in the
RF1AIV register that can be evaluated or added to the program counter to automatically enter the
appropriate software routine. Disabled interrupts do not affect the RF1AIV value.
Any read access of the RF1AIV register automatically resets the highest pending interrupt flag. If another
interrupt flag is set, another interrupt is generated immediately after servicing the initial interrupt. A write
access to the RF1AIV register automatically resets all pending interrupt flags.
Table 19-5 lists the available CC1101 radio core interrupt sources and the associated flags. It also lists for
the hardwired interrupt sources what event causes a low-to-high transition and what causes a high-to-low
transition.
RETI 5
Status Byte
With each instruction sent to the radio core, the status is updated and can be read back using the
RF1ASTAT registers. Table 19-8 summarizes the information available in the status byte.
(19-1)
Equation 19-2 can be used to find suitable values for a given data rate:
ê æR ´220 öú
DRATE_E = êlog2 ç DATA ÷ú
ê ç f XOSC ÷ú
ë è øû
RDATA ´228
DRATE_M = -256
f XOSC ´2DRATE_E (19-2)
If DRATE_M is rounded to the nearest integer and becomes 256, increment DRATE_E and use
DRATE_M = 0.
The data rate can be set from 0.8 kBaud to 500 kBaud with the minimum step as shown in Table 19-9.
For best performance, the channel filter bandwidth should be selected so that the signal bandwidth
occupies at most 80% of the channel filter bandwidth. The channel center tolerance due to crystal
inaccuracy should also be subtracted from the channel filter bandwidth, as shown in the following
example.
With the channel filter bandwidth set to 500 kHz, the signal should stay within 80% of 500 kHz, which is
400 kHz. Assuming 915-MHz frequency and ±20-ppm frequency uncertainty for both the transmitting
device and the receiving device, the total frequency uncertainty is ±40 ppm of 915 MHz, which is ±37 kHz.
If the whole transmitted signal bandwidth is to be received within 400 kHz, the transmitted signal
bandwidth should be maximum 400 kHz – (2 × 37 kHz), which is 326 kHz.
By compensating for a frequency offset between the transmitter and the receiver, the filter bandwidth can
be reduced and the sensitivity can be improved, see more in DN005 - CC11xx Sensitivity versus
Frequency Offset and Crystal Accuracy (SWRA122) and in Section 19.3.5.1.
Note: Frequency offset compensation is not supported for ASK or OOK modulation.
The estimated frequency offset value is available in the FREQEST status register. This can be used for
permanent frequency offset compensation. By writing the value from FREQEST into FSCTRL0.FREQOFF,
the frequency synthesizer will automatically be adjusted according to the estimated frequency offset. More
details regarding this permanent frequency compensation algorithm can be found in DN015 - Permanent
Frequency Offset Compensation (SWRA159).
Bit Synchronization
The bit synchronization algorithm extracts the clock from the incoming symbols. The algorithm requires
that the expected data rate is programmed as described in Section 19.3.3. Resynchronization is
performed continuously to adjust for error in the incoming symbol rate.
Byte Synchronization
Byte synchronization is achieved by a continuous sync word search. The sync word is a 16-bit
configurable field (can be repeated to get a 32-bit field) that is automatically inserted at the start of the
packet by the modulator in transmit mode. The demodulator uses this field to find the byte boundaries in
the stream of bits. The sync word also functions as a system identifier, because only packets with the
correct predefined sync word are received if the sync word detection in RX is enabled in register
MDMCFG2 (see Section 19.3.8.1). The sync word detector correlates against the user-configured 16- or
32-bit sync word. The correlation threshold can be set to 15/16, 16/16, or 30/32 bits match. The sync word
can be further qualified using the preamble quality indicator mechanism described below and/or a carrier
sense condition. The sync word is configured through the SYNC1 and SYNC0 registers.
To make false detections of sync words less likely, a mechanism called preamble quality indication (PQI)
can be used to qualify the sync word. A threshold value for the preamble quality must be exceeded in
order for a detected sync word to be accepted. See Section 19.3.8.2 for more details.
Table 19-11. Received Packet Status Byte 1 (First Byte Appended After Data)
BIT FIELD NAME DESCRIPTION
7:0 RSSI RSSI value
Table 19-12. Received Packet Status Byte 2 (Second Byte Appended After
Data)
BIT FIELD NAME DESCRIPTION
7 CRC_OK 1: CRC for received data OK (or CRC disabled)
0: CRC error in received data
6:0 LQI Indicating the link quality
Note: Register fields that control the packet handling features should be altered only when the
radio is in the IDLE state.
Packet Format
The format of the data packet can be configured and consists of the following items (see Figure 19-5):
• Preamble
• Synchronization word
• Optional length byte
• Optional address byte
• Payload
• Optional 2-byte CRC
The preamble pattern is an alternating sequence of ones and zeros (10101010…). The minimum length of
the preamble is programmed with the MDMCFG1.NUM_PREAMBLE value. When enabling TX, the
modulator starts transmitting the preamble. When the programmed number of preamble bytes has been
transmitted, the modulator sends the sync word and then data from the TX FIFO if data is available. If the
TX FIFO is empty, the modulator continues to send preamble bytes until the first byte is written to the TX
FIFO. The modulator then sends the sync word and then the data bytes.
The synchronization word is a two-byte value set in the SYNC1 and SYNC0 registers. The sync word
provides byte synchronization of the incoming packet. A one-byte synch word can be emulated by setting
the SYNC1 value to the preamble pattern. It is also possible to emulate a 32-bit sync word by setting
MDMCFG2.SYNC_MODE to 3 or 7. The sync word is then repeated twice.
The radio supports both constant packet length protocols and variable length protocols. Variable or fixed
packet length mode can be used for packets up to 255 bytes. For longer packets, infinite packet length
mode must be used.
Fixed packet length mode is selected by setting PKTCTRL0.LENGTH_CONFIG = 0. The desired packet
length is set by the PKTLEN register.
In variable packet length mode, PKTCTRL0.LENGTH_CONFIG = 1, the packet length is configured by the
first byte after the sync word. The packet length is defined as the payload data, excluding the length byte
and the optional CRC. The PKTLEN register is used to set the maximum packet length allowed in RX. Any
packet received with a length byte with a value greater than PKTLEN is discarded.
With PKTCTRL0.LENGTH_CONFIG = 2, the packet length is set to infinite, and transmission and
reception continues until turned off manually. As described in the next section, this can be used to support
packet formats with different length configuration than natively supported. One should make sure that TX
mode is not turned off during the transmission of the first half of any byte.
Note: The minimum packet length supported (excluding the optional length byte and CRC) is one
byte of payload data.
Address Filtering
Setting PKTCTRL1.ADR_CHK to any other value than zero enables the packet address filter. The packet
handler engine compares the destination address byte in the packet with the programmed node address
in the ADDR register and the 0x00 broadcast address when PKTCTRL1.ADR_CHK = 10 or both 0x00 and
0xFF broadcast addresses when PKTCTRL1.ADR_CHK = 11. If the received address matches a valid
address, the packet is received and written into the RX FIFO. If the address match fails, the packet is
discarded and receive mode restarted (regardless of the MCSM1.RXOFF_MODE setting).
If the received address matches a valid address when using infinite packet length mode and address
filtering is enabled, 0xFF is written into the RX FIFO followed by the address byte and then the payload
data.
CRC Filtering
The filtering of a packet when CRC check fails is enabled by setting PKTCTRL1.CRC_AUTOFLUSH = 1.
The CRC auto flush function flushes the entire RX FIFO if the CRC check fails. After auto flushing the RX
FIFO, the next state depends on the MCSM1.RXOFF_MODE setting.
When using the auto flush function, the maximum packet length is 63 bytes in variable packet length mode
and 64 bytes in fixed packet length mode. Note that the maximum allowed packet length is reduced by
two bytes when PKTCTRL1.APPEND_STATUS is enabled, to make room in the RX FIFO for the two
status bytes appended at the end of the packet. Because the entire RX FIFO is flushed when the CRC
check fails, the previously received packet must be read out of the FIFO before receiving the current
packet. The CPU must not read from the current packet until the CRC has been checked as OK.
Amplitude Modulation
The radio supports two different forms of amplitude modulation: on-off keying (OOK) and amplitude shift
keying (ASK).
OOK modulation simply turns on or off the PA to modulate 1 and 0, respectively.
The ASK variant allows programming of the modulation depth (the difference between 1 and 0) and
shaping of the pulse amplitude. Pulse shaping produces a more bandwidth-constrained output spectrum.
When using OOK/ASK, the AGC settings from the SmartRF® Studio preferred FSK/MSK settings are not
optimum. application note DN022 - CC11xx OOK/ASK Register Settings (SWRA215) provides guidelines
on how to find optimum OOK/ASK settings from the preferred settings in SmartRF Studio. The DEVIATN
register setting has no effect in either TX or RX when using OOK/ASK.
Note: It takes some time from the radio enters RX mode until a valid RSSI value is present in the
RSSI register. Please refer to DN505 - RSSI interpretation and timing (SWRA114) for details
on how the RSSI response time can be estimated.
The RSSI value is in dBm with ½-dB resolution. The RSSI update rate, fRSSI, depends on the receiver filter
bandwidth (BWchannel defined in Section 19.3.4) and AGCCTRL0.FILTER_LENGTH.
2´ BWchannel
fRSSI =
8´2FILTER_LEN GTH (19-5)
If PKTCTRL1.APPEND_STATUS is enabled the last RSSI value of the packet is automatically added to
the first byte appended after the payload.
The RSSI value read from the RSSI status register is a 2s complement number. The following procedure
can be used to convert the RSSI reading to an absolute power level (RSSI_dBm).
1. Read the RSSI status register
2. Convert the reading from a hexadecimal number to a decimal number (RSSI_dec)
3. If RSSI_dec ≥ 128 then RSSI_dBm = (RSSI_dec – 256)/2 – RSSI_offset
4. If RSSI_dec < 128 then RSSI_dBm = (RSSI_dec)/2 – RSSI_offset
Table 19-15 gives typical values for the RSSI_offset. Figure 19-7 and Figure 19-8 shows typical plots of
RSSI reading as a function of input power level for different data rates.
-10
-20
-30
-40
RSSI Readout [dBm]
-50
-60
-70
-80
-90
-100
-110
-120
-120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0
Figure 19-7. Typical RSSI Value vs Input Power Level for Different Data Rates at 433 MHz
-10
-20
-30
-40
RSSI Readout [dBm]
-50
-60
-70
-80
-90
-100
-110
-120
-120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0
Input Power [dBm]
Figure 19-8. Typical RSSI Value vs Input Power Level for Different Data Rates at 868 MHz
CS Absolute Threshold
The absolute threshold related to the RSSI value depends on the following register fields:
• AGCCTRL2.MAX_LNA_GAIN
• AGCCTRL2.MAX_DVGA_GAIN
• AGCCTRL1.CARRIER_SENSE_ABS_THR
• AGCCTRL2.MAGN_TARGET
For a given AGCCTRL2.MAX_LNA_GAIN and AGCCTRL2.MAX_DVGA_GAIN setting the absolute
threshold can be adjusted ±7 dB in steps of 1 dB using CARRIER_SENSE_ABS_THR.
The MAGN_TARGET setting is a compromise between blocker tolerance/selectivity and sensitivity. The
value sets the desired signal level in the channel into the demodulator. Increasing this value reduces the
headroom for blockers, and therefore close-in selectivity.
It is strongly recommended to use SmartRF Studio to generate the correct MAGN_TARGET setting.
Table 19-16 and Table 19-17 show the typical RSSI readout values at the CS threshold at 2.4 kBaud and
250 kBaud data rate respectively. The default CARRIER_SENSE_ABS_THR = 0 (0 dB) and
MAGN_TARGET = 3 (33 dB) have been used.
For other data rates the user must generate similar tables to find the CS absolute threshold.
MAX_LNA_GAIN[2:0]
001 –88 –82 –76 –70
010 –84.5 –78.5 –72 –66
011 –82.5 –76.5 –70 –64
100 –80.5 –74.5 –68 –62
101 –78 –72 –66 –60
110 –76.5 –70 –64 –58
111 –74.5 –68 –62 –56
If the threshold is set high, i.e., only strong signals are wanted, the threshold should be adjusted upwards
by first reducing the MAX_LNA_GAIN value and then the MAX_DVGA_GAIN value. This reduces power
consumption in the receiver front end, because the highest gain settings are avoided.
CS Relative Threshold
The relative threshold detects sudden changes in the measured signal level. This setting is not dependent
on the absolute signal level and is thus useful to detect signals in environments with a time varying noise
floor. The register field AGCCTRL1.CARRIER_SENSE_REL_THR is used to enable/disable relative CS,
and to select threshold of 6 dB, 10 dB, or 14 dB RSSI change.
PUC | SRES
SID LE
SPWD | SWOR | SXOFF
CAL_COMPLETE
SLEEP
0
MANCAL IDLE
3,4,5 1
FS_WAKEUP
6,7
FS_AUTOCAL = 01
&
SRX | STX | SFSTXON | WOR
FS_AUTOCAL = 00 | 10 | 11
& CALIBRATE
SRX | STX | SFSTXON | WOR 8
CAL_COMPLETE
SETTLING
SFSTXON 9,10,11
FSTXON
18
STX SRX | WOR
SRX
STX
SFSTXON | RXOFF_MODE = 01
TXOFF_MODE=01
TXOFF_MODE = 00 RXOFF_MODE = 00
TXFIFO_UNDERFLOW RXFIFO_OVERFLOW
& &
FS_AUTOCAL = 10 | 11 FS_AUTOCAL = 10 | 11
CALIBRATE
TXOFF_MODE = 00 12 RXOFF_MODE = 00
&
&
FS_AUTOCAL = 00 | 01
TX_UNDERFLOW FS_AUTOCAL = 00 | 01 RX_OVERFLOW
22 17
SFTX SFRX
IDLE
1
Manual Reset
Use the SRES command strobe to globally reset the radio core . By issuing this strobe, all internal
registers are reset to their default states and the radio core will enter the SLEEP state.
Crystal Control
The crystal oscillator (XOSC) is either automatically controlled or always on, if
MCSM0.XOSC_FORCE_ON is set.
In the automatic mode, the XOSC is turned off if the SPWD, SWOR or SXOFF command strobes are
issued. The state machine then goes to SLEEP. This can be done only from the IDLE state.
If the XOSC is forced on, the crystal stays on, even in the SLEEP state.
After a reset the crystal oscillator is off because the state machine is in the SLEEP state and
XOSC_FORCE_ON = 0.
Crystal oscillator start-up time depends on crystal ESR and load capacitances.
Active Modes
The radio has two active modes: receive and transmit. These modes are activated directly by the CPU by
using the SRX and STX command strobes, or automatically by Wake on Radio.
The frequency synthesizer must be calibrated regularly. There is one manual calibration option (using the
SCAL strobe), and three automatic calibration options, controlled by the MCSM0.FS_AUTOCAL setting:
• Calibrate when going from IDLE to either RX or TX (or FSTXON)
• Calibrate when going from either RX or TX to IDLE automatically
• Calibrate every fourth time when going from either RX or TX to IDLE automatically
If the radio goes from TX or RX to IDLE by issuing an SIDLE strobe, calibration is not performed. The
calibration takes a constant number of XOSC cycles (see Table 19-18 for timing details).
When RX is activated, the radio remains in receive mode until a packet is successfully received or the RX
termination timer expires (see Section 19.3.9.5). The probability that a false sync word is detected can be
reduced by using PQT, CS, maximum sync word length, and sync word qualifier mode as described in
Section 19.3.8.
After a packet is successfully received, the radio controller goes to the state indicated by the
MCSM1.RXOFF_MODE setting. The possible destinations are:
• IDLE
• FSTXON: Frequency synthesizer on and ready at the TX frequency. Activate TX with STX.
• TX: Start sending preamble
• RX: Start search for a new packet
Note: When MCSM1.RXOFF_MODE=11 and a packet has been received, it takes some time
before a valid RSSI value is present in the RSSI register again even if the radio never exited
RX mode. This time is the same as the RSSI response time discussed in DN505 - RSSI
interpretation and timing (SWRA114).
Similarly, when TX is active the radio remains in the TX state until the current packet has been
successfully transmitted. Then the state changes as indicated by the MCSM1.TXOFF_MODE setting. The
possible destinations are the same as for RX.
The CPU can manually change the state from RX to TX and vice versa by using the command strobes. If
the radio controller is currently in transmit and the SRX strobe is used, the current transmission is ended
and the transition to RX is done.
If the radio controller is in RX when the STX or SFSTXON command strobes are used, the TX-if-CCA
function is used. If the channel is not clear, the radio remains in RX. The MCSM1.CCA_MODE setting
controls the conditions for clear channel assessment (see Section 19.3.8.5 for details).
The SIDLE command strobe can always be used to force the radio controller to go to the IDLE state.
The time from entering the SLEEP state until the next Event0 (tSLEEP in Figure 19-10) should be larger
than 11.72 ms when fACLK = 32.768kHz. If tSLEEP is less than 11.72 ms, there is a chance that the
consecutive Event 0 will occur (1 / fACLK ) × 128 seconds too early.
Timing
The radio controller controls most of the timing, such as synthesizer calibration, PLL lock time, and RX/TX
turnaround times. Timing from IDLE to RX and IDLE to TX is constant, dependent on the auto calibration
setting. RX/TX and TX/RX turnaround times are constant. The calibration time is constant 18739 clock
periods. Table 19-18 shows timing in crystal clock cycles for key state transitions. XOSC start-up times
are variable.
Note that in a frequency hopping spread spectrum or a multi-channel protocol the calibration time can be
reduced from 721 µs to approximately 150 µs (see Section 19.3.16.2).
RX Termination Timer
The radio has optional functions for automatic termination of RX after a programmable time. The main use
for this functionality is wake-on-radio (WOR), but it may be useful for other applications. The termination
timer starts when in RX state. The timeout is programmable with the MCSM2.RX_TIME setting. When the
timer expires, the radio controller checks the condition for staying in RX. If the condition is not met, RX
terminates.
The programmable conditions are:
• MCSM2.RX_TIME_QUAL = 0
Continue receive if sync word has been found
• MCSM2.RX_TIME_QUAL = 1
Continue receive if sync word has been found or preamble quality is above threshold (PQT)
If the system can expect the transmission to have started when enabling the receiver, the
MCSM2.RX_TIME_RSSI function can be used. The radio controller then terminates RX if the first valid
carrier sense sample indicates no carrier (RSSI below threshold) (see Section 19.3.8.4 for details on
Carrier Sense).
For ASK/OOK modulation, lack of carrier sense is only considered valid after eight symbol periods. Thus,
the MCSM2.RX_TIME_RSSI function can be used in ASK/OOK mode when the distance between "1"
symbols is 8 or less.
If RX terminates due to no carrier sense when the MCSM2.RX_TIME_RSSI function is used, or if no sync
word was found when using the MCSM2.RX_TIME timeout function, the radio goes back to IDLE if WOR
is disabled and back to SLEEP if WOR is enabled. Otherwise, the MCSM1.RXOFF_MODE setting
determines the state to go to when RX ends. This means that the radio does not automatically go back to
SLEEP once a sync word has been received. It is therefore recommended to always wake up the CPU on
sync word detection when using WOR mode (RFIFG9 or a GDO signal with GDOx_CFG=6).
GDO
NUM_TXBYTES 6 7 8 9 10 9 8 7 6
GDO
Overflow
margin
FIFO_THR=13
56 bytes
FIFO_THR=13
Underflow
margin 8 bytes
RXFIFO TXFIFO
Note: The SmartRF Studio software automatically calculates the optimum FSCTRL1.FREQ_IF
register setting based on channel spacing and channel filter bandwidth.
If any frequency programming register is altered when the frequency synthesizer is running, the
synthesizer may give an undesired response. Hence, the frequency programming should only be updated
when the radio is in the IDLE state.
19.3.12 VCO
The VCO is completely integrated on-chip.
PATABLE(7)[7:0]
The PA uses this
PATABLE(6)[7:0]
setting.
PATABLE(5)[7:0]
PATABLE(4)[7:0]
Settings 0 to PA_POWER are
PATABLE(3)[7:0] used during ramp-up at start of
transmission and ramp-down at
PATABLE(2)[7:0] end of transmission, and for
PATABLE(1)[7:0] ASK/OOK modulation.
PATABLE(0)[7:0]
Output P ower
P A TA B LE[ 7]
P A TA B LE[ 6]
P A TA B LE[ 5]
P A TA B LE[ 4]
P A TA B LE[ 3]
P A TA B LE[ 2]
P A TA B LE[ 1]
P A TA B LE[ 0]
Time
1 0 0 1 0 1 1 0 B it S equence
SRD Regulations
International regulations and national laws regulate the use of radio receivers and transmitters. Short
range devices (SRDs) for license-free operation below 1 GHz are usually operated in the 433 MHz, 868
MHz, or 915 MHz frequency bands. The CC1101 radio is specifically designed for such use with its
300 MHz to 348 MHz, 389 MHz to 464 MHz, and 779 MHz to 928 MHz operating ranges. The most
important regulations when using a CC1101-based radio in the 433 MHz, 868 MHz, or 915 MHz frequency
bands are EN 300 220 (Europe) and FCC CFR47 Part 15 (USA). A summary of the most important
aspects of these regulations can be found in SRD Regulations for Licence Free Transceiver Operation
(SWRA090).
frequency hop, the calibration process can then be replaced by writing the FSCAL3, FSCAL2 and
FSCAL1 register values that corresponds to the next RF frequency. The PLL turn on time is
approximately 90 µs. The blanking interval between each frequency hop is then approximately 90 µs.
3. Run calibration on a single frequency at startup. Next, write 0 to FSCAL3[5:4] to disable the
charge-pump calibration. After writing to FSCAL3[5:4], strobe SRX (or STX) with
MCSM0.FS_AUTOCAL = 1 for each new frequency hop. That is, VCO current and VCO capacitance
calibration are done but not charge-pump current calibration. When charge pump current calibration is
disabled, the calibration time is reduced from approximately 720 µs to approximately 150 µs. The
blanking interval between each frequency hop is then approximately 240 µs.
There is a trade off between blanking time and memory space needed for storing calibration data in
non-volatile memory. Solution 2 above gives the shortest blanking interval, but requires more memory
space to store calibration values. This solution also requires that the supply voltage and temperature do
not vary much in order to have a robust solution. Solution 3 gives approximately 570 µs smaller blanking
interval than solution 1.
The recommended settings for TEST0.VCO_SEL_CAL_EN change with frequency. Therefore, SmartRF
Studio should be used to determine the correct settings for a specific frequency before doing a calibration,
regardless of which calibration method is used.
Wireless MBUS
The wireless MBUS standard is a communication standard for meters and wireless readout of meters, and
specifies the physical and the data link layer. Power consumption is a critical parameter for the meter side,
since the communication link shall be operative for the full lifetime of the meter, without changing the
battery. MSP430 with an CC1101-based radio is an excellent choice for the Wireless MBUS standard. For
more information regarding see AN067 - Wireless MBUS Implementation with cc1101 and MSP430
(SWRA234) . Since the Wireless MBUS standard operates in the 868-870 ISM band, the radio
requirements must also comply with the ETSI EN 300 220 and CEPT/ERC/REC 70-03 E standards.
Note: The sensitivity and thus transmission range is reduced for high data rate bursts compared to
lower data rates.
Continuous Transmissions
In data streaming applications, the CC1101-based radio allows continuous transmissions at 500-kBaud
effective data rate. As the modulation is done with a closed-loop PLL, there is no limitation on the length of
a transmission (open-loop modulation used in some transceivers often prevents this continuous data
streaming and reduces the effective data rate).
Filter PA
CC1101-
Balun based
Radio
Figure 19-15. Block Diagram of CC1101-based Radio With External Power Amplifier
fXOSC
BWchannel =
CHANBW_E
8 × (4 + CHANBW_M) × 2
The default values give 203 kHz channel filter bandwidth, assuming a
26-MHz crystal.
3:0 DRATE_E[3:0] 12 (0x0C) R/W The exponent of the user specified symbol rate
The default values give a data rate of 115.051 kBaud (closest setting to
115.2 kBaud), assuming a 26-MHz crystal.
The default values give 199.951 kHz channel spacing (the closest
setting to 200 kHz), assuming 26-MHz crystal frequency.
f
fdev = xosc ´(8 +DEVIATION_ M) ´2DEVIATION_ E
217
The default values give ±47.607 kHz deviation,
assuming 26-MHz crystal frequency.
MSK Specifies the fraction of symbol period (1/8-8/8) during
which a phase change occurs (‘0’: +90deg, ‘1’:-90deg).
Refer to the SmartRF Studio software for correct
DEVIATN setting when using MSK.
ASK/OOK This setting has no effect.
In RX:
2-FSK/2-GFSK Specifies the expected frequency deviation of incoming
signal, must be approximately right for demodulation to
be performed reliably and robustly.
MSK/ASK/OO This setting has no effect.
K
7 6 5 4 3 2 1 0
Reserved RFENDIAN Reserved
r0 r0 r0 r0 r0 r0 rw-0 rw-0
7 6 5 4 3 2 1 0
RFDOUTIFG RFSTATIFG RFDINIFG RFINSTRIFG Reserved RFERRIFG RFTXIFG RFRXIFG
rw-0 rw-0 rw-0 rw-0 r0 r-0 rw-0 rw-0
7 6 5 4 3 2 1 0
Reserved OPOVERR OUTERR OPERR LVERR
r0 r0 r0 r0 rw-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
0 0 RF1AIFERRVx 0
r0 r0 r-(0) r-(0) r-(0) r-(0) r-(0) r0
RF1AIFERRV
Error Source Error Flag Error Priority
Contents
00h No error –
02h Low core voltage error LVERR Highest
04h Operand error OPERR
06h Output data not available error OUTERR
08h Operand overwrite error OPOVERR Lowest
7 6 5 4 3 2 1 0
0 0 RF1AIFIVx 0
r0 r0 r-(0) r-(0) r-(0) r-(0) r-(0) r0
RF1AIFIV Interrupt
Interrupt Source Interrupt Flag
Contents Priority
00h No interrupt pending –
02h Radio interface error RFERRIFG Highest
04h Radio interface data out RFDOUTIFG
06h Radio interface status out RFSTATIFG
08h Radio interface data in RFDINIFG
0Ah Radio interface instruction in RFINSTRIFG
0Ch Radio direct FIFO RX RFRXIFG
0Eh Radio direct FIFO TX RFTXIFG Lowest
7 6 5 4 3 2 1 0
RFINx
r r r r r r r r
7 6 5 4 3 2 1 0
RFIFGx
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
RFIESx
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
RFIEx
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
0 0 RF1AIVx 0
r0 r0 r-(0) r-(0) r-(0) r-(0) r-(0) r0
RF1AIV Interrupt
Interrupt Source Interrupt Flag
Contents Priority
00h No interrupt pending –
02h Radio core signal 0 RFIFG0 Highest
04h Radio core signal 1 RFIFG1
06h Radio core signal 2 RFIFG2
08h Radio core signal 3 RFIFG3
0Ah Radio core signal 4 RFIFG4
0Ch Radio core signal 5 RFIFG5
0Eh Radio core signal 6 RFIFG6
10h Radio core signal 7 RFIFG7
12h Radio core signal 8 RFIFG8
14h Radio core signal 9 RFIFG9
16h Radio core signal 10 RFIFG10
18h Radio core signal 11 RFIFG11
1Ah Radio core signal 12 RFIFG12
1Ch Radio core signal 13 RFIFG13
1Eh Radio core signal 14 RFIFG14
20h Radio core signal 15 RFIFG15 Lowest
Chapter 20
SLAU259 – May 2009
REF
The REF module is a general purpose reference system that is used to generate voltage references
required for other subsystems available on a given device such as digital-to-analog converters,
analog-to-digital converters, comparators, etc. This chapter describes the REF module.
REFGEN ADC12_A
+ ADC12REFOUT
− +
− To external pad
BANDGAP +
Vref
ADC12REFON
−
+
BIAS Vref/2 To DAC12
− To ADC12_A
Vref/3 To DAC12 capacitor array
Switch
Mux
1.5/2.0/2.5V DAC12_A
From REFGEN + Channel 0
REFGENREQ
−
REFBGREQ
DAC12OG
DAC12_A
From REFGEN + Channel 1
REFMODEREQ
DAC12OG
COMP_B0
Local
Buffer
COMP_B1
Local
Buffer
20.2.2 REFCTL
The REFCTL registers provide a way to control the reference system from one centralized set of registers.
By default, REFCTL is used as the primary control of the reference system. On legacy devices, the
ADC12_A provided the control bits necessary to configure the reference system, namely ADC12REFON,
ADC12REF2_5, ADC12TCOFF, ADC12REFOUT, ADC12SR, and ADC12REFBURST. The ADC12SR
and ADC12REFBURST bits are very specific to the ADC12 operation and therefore are not included in
REFCTL. All legacy control bits can still be used to configure the reference system allowing for backward
compatibility by clearing REFMSTR. In this case, the REFCTL register bits are a 'do not care'.
Setting the reference master bit (REFMSTR = 1), allows the reference system to be controlled via the
REFCTL register. This is the default setting. In this mode, the legacy control bits ADC12REFON,
ADC12REF2_5, ADC12TCOFF, and ADC12REFOUT are do not care. The ADC12SR and
ADC12REFBURST are still controlled via the ADC12_A since these are very specific to the ADC12_A
module. If REFMSTR set is cleared, all settings in the REFCTL are do not care and the reference system
is controlled completely by the legacy control bits inside the ADC12_A module. Table
Table 20-1summarizes the REFCTL bits and their effect on the REF module.
Table 20-2 summarizes the ADC12_A control bits and their effect on the REF module. Please see the
ADC12_A module description for further details.
Note: Although the REF module supports using the ADC12_A bits as control for the reference
system, it is recommended that the usage of the new REFCTL register be used and older
code migrated to this methodology. This allows the logical partitioning of the reference
system to be separate from the ADC12_A system and forms a more natural partitioning for
future products.
As stated previously, the ADC12REFBURST does have an effect on the reference system and can be
controlled via the ADC12_A. This bit is in effect regardless if REFCTL or the ADC12_A is controlling the
reference system. Setting ADC12REFBURST = 1 enables burst mode when REFON = 1 and REFMSTR =
1 or when ADC12REFON = 1 and REFMSTR = 0. In burst mode, the internal buffer (ADC12REFOUT = 0)
or the external buffer (ADC12REFOUT = 1) is enabled only during a conversion and disabled
automatically to conserve power.
Note: The legacy ADC12_A bit ADC12REF2_5 only allows for selecting either 1.5 V or 2.5 V. To
select 2.0 V, the REFVSEL control bits must be used (REFMSTR = 1).
ADC12_A
For devices that contain an ADC12_A module, the ADC12_A module contains two local buffers. The
larger buffer can be used to drive the reference voltage, present on the variable reference line, external to
the device. This buffer has larger power consumption due to a selectable burst mode, as well as, its need
to drive larger DC loads that may be present outside the device. The large buffer is enabled continuously
when REFON = 1, REFOUT =1, and ADC12REFBURST = 0. When ADC12REFBURST = 1, the buffer is
enabled only during an ADC conversion, shutting down automatically upon completion of a conversion to
save power. In addition, when REFON = 1 and REFOUT = 1, the second smaller buffer is automatically
disabled. In this case, the output of the large buffer is connected to the capacitor array via an internal
analog switch. This ensures the same reference is used throughout the system. If REFON = 1 and
REFOUT = 0, the internal buffer is used for ADC conversion and the large buffer remains disabled. The
small internal buffer can operate in burst mode as well by setting ADC12REFBURST = 1
DAC12_A
Some devices may contain a DAC12_A module. The DAC12_A can use the 1.5 V, 2.0 V, or 2.5 V from
the variable reference line for its reference. The DAC12_A can request its reference directly by the
settings within the DAC12_A module itself. Basically, if the DAC is enabled and the internal reference is
selected, it will request it from the REF module. In addition, as before, setting REFON = 1 (REFMSTR = 1)
or ADC12REFON = 1 (REFMSTR = 0) can enable the variable reference line independent of the
DAC12_A control bits.
The REGEN subsystem will provide divided versions of the variable reference line for usage in the
DAC12_A module. The DAC12_A module requires either /2 or /3 of the variable reference. The selection
of these depends on the control bits inside the DAC12_A module (DAC12IR, DAC12OG) and is handled
automatically by the REF module.
When the DAC12_A selects AVcc or VeREF+ as its reference, the DAC12_A has its own /2 and /3
resistor string available that scales the input reference appropriately based on the DAC12IR and
DAC12OG settings.
LCD_B
Devices that contain an LCD will utilize the LCD_B module. The LCD_B module requires a reference to
generate the proper LCD voltages. The bandgap reference line from the REFGEN sub-system is used for
this purpose. The LCD is enabled when LCDON = 1 of the LCD_B module. This causes a REFBGREQ
from the LCD module to be asserted. The buffered bandgap will be made available on the bandgap
reference line for usage inside the LCD_B module.
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
7 6 5 4 3 2 1 0
REFMSTR Reserved REFVSEL REFTCOFF Reserved REFOUT REFON
rw-(1) r0 rw-(0) rw-(0) rw-(0) r0 rw-(0) rw-(0)
Chapter 21
SLAU259 – May 2009
Comparator_B
Comparator_B is an analog voltage comparator. This chapter describes the Comparator_B. Comparator_B
covers general comparator functionality for up to 16 channels.
CB0 0000
CB1 0001
CB2
CB3 VCC
CBEX CBON
CB12
CB13
CB14 1110
CB15 1111 CBF
+
0
CBSHORT 0
1 Set CBIFG
- 1
CCI1B
CBIMSEL CBOUT
CB12
CB13
CB14 1110
CB15 1111
21.2.1 Comparator
The comparator compares the analog voltages at the + and – input terminals. If the + terminal is more
positive than the – terminal, the comparator output CBOUT is high. The comparator can be switched on or
off using control bit CBON. The comparator should be switched off when not in use to reduce current
consumption. When the comparator is switched off, CBOUT is always low. The bias current of the
comparator is programmable.
The CBEX bit controls the input multiplexer, permuting the input signals of the comparator's + and –
terminals. Additionally, when the comparator terminals are permuted, the output signal from the
comparator is inverted too. This allows the user to determine or compensate for the comparator input
offset voltage.
0000
Sampling capacitor, CS
1100
1101
1110
1111
CxSHORT
0000
0001
0010
0011
Analog Inputs
1100
1101
1110
1111
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 1 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) × 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 signals voltage level, with 5 Tau it is
charged to more than 99%, and with 10 Tau the sampled voltage is sufficient for 12-bit accuracy.
+ Terminal
Comparator Output
Unfiltered at CBOUT
Comparator Output
Filtered at CBOUT
2
1.2 V from the CBON
shared reference 00, 11
10 01
2
CBRSx
CBREF1 CBREF0
5 5
CBRS = 11
CBMRVL
CBMRVS
1 0
1
VREF1
VREF 1 0
0 1
VREF0
0
The voltage reference generator is used to generate VREF, which can be applied to either comparator
input terminal. The CBREF1x (VREF1) and CBREF0x (VREF0) bits control the output of the voltage
generator. The CBRSEL bit selects the comparator terminal to which VREF is applied. If external signals
are applied to both comparator input terminals, the internal reference generator should be turned off to
reduce current consumption. The voltage reference generator can generate a fraction of the device's VCC
or of the voltage reference of the integrated precision voltage reference source. Vref1 is used while
CBOUT is 1 and Vref0 is used while CBOUT is 0. This allows the generation of a hysteresis without using
external components.
VI VO ICC
ICC
VI
VCC
0 VCC
CBPD.x = 1 VSS
0.25 × VCC
Rmeas
VREF1
Rref
The VCC voltage and the capacitor value should remain constant during the conversion, but are not critical
since they cancel in the ratio:
Vref1
–Rmeas × C × ln
Nmeas VCC
=
Nref Vref1
–Rref × C × ln
VCC
Nmeas Rmeas
=
Nref Rref
Nmeas
Rmeas = Rref ×
Nref
7 6 5 4 3 2 1 0
CBIPEN Reserved CBIPSEL
rw-0 r-0 r-0 r-0 rw-0 rw-0 rw-0 rw-0
CBIMEN Bit 15 Channel input enable for the V– terminal of the comparator.
0 Selected analog input channel for V– terminal is disabled.
1 Selected analog input channel for V– terminal is enabled.
Reserved Bits 14-12 Reserved
CBIMSEL Bits 11-8 Channel input selected for the V– terminal of the comparator if CBIMEN is set to 1.
CBIPEN Bit 7 Channel input enable for the V+ terminal of the comparator.
0 Selected analog input channel for V+ terminal is disabled.
1 Selected analog input channel for V+ terminal is enabled.
Reserved Bits 6-4 Reserved
CBIPSEL Bits 3-0 Channel input selected for the V+ terminal of the comparator if CBIPEN is set to 1.
7 6 5 4 3 2 1 0
CBFDLY CBEX CBSHORT CBIES CBF CBOUTPOL CBOUT
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 r-0
7 6 5 4 3 2 1 0
CBRS CBRSEL CBREF0
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
CBREFACC Bit 15 Reference accuracy. A reference voltage is requested only if CBREFL > 0.
0 Static mode
1 Clocked (low-power, low-accuracy) mode
CBREFL Bits 14-13 Reference voltage level
00 Reference amplifier is disabled. No reference voltage is requested.
01 1.5 V is selected as shared reference voltage input
10 2.0 V is selected as shared reference voltage input
11 2.5 V is selected as shared reference voltage input
CBREF1 Bits 12-8 Reference resistor tap 1. This register defines the tap of the resistor string while CBOUT = 1.
CBRS Bits 7-6 Reference source. This bit define if the reference voltage is derived from VCC or from the precise
shared reference.
00 No current is drawn by the reference curcuitry.
01 VCC applied to the resistor ladder
10 Shared reference voltage applied to the resistor ladder.
11 Shared reference voltage supplied to VCREF. Resistor ladder is off.
CBRSEL Bit 5 Reference select. This bit selects which terminal the VCCREF is applied to.
When CBEX = 0:
0 VREF is applied to the + terminal
1 VREF is applied to the – terminal
When CBEX = 1:
0 VREF is applied to the – terminal
1 VREF is applied to the + terminal
CBREF0 Bits 4-0 Reference resistor tap 0. This register defines the tap of the resistor string while CBOUT = 0.
7 6 5 4 3 2 1 0
CBPD7 CBPD6 CBPD5 CBPD4 CBPD3 CBPD2 CBPD1 CBPD0
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
CBPDx Bit 15-0 Port disable. These bits individually disable the input buffer for the pins of the port associated with
Comparator_B. The bit CBPDx disabled the port of the comparator channel x.
0 The input buffer is enabled.
1 The input buffer is disabled.
7 6 5 4 3 2 1 0
Reserved CBIIFG CBIFG
r-0 r-0 r-0 r-0 r-0 r-0 rw-0 rw-0
7 6 5 4 3 2 1 0
0 0 0 0 0 CBIV 0
r0 r0 r0 r0 r0 r-(0) r-(0) r0
CBIV Bits 15-0 Comparator_B interrupt vector word register. The interrupt vector register reflects only interrupt flags whose
interrupt enable bit are set. Reading the CBIV register clears the pending interrupt flag with the highest
priority.
CBIV Interrupt
Interrupt Source Interrupt Flag
Contents Priority
00h No interrupt pending – –
02h CBOUT interrupt CBIFG Highest
04h CBOUT interrupt inverted polarity CBIIFG Lowest
Chapter 22
SLAU259 – May 2009
ADC12_A
The ADC12_A module is a high-performance 12-bit analog-to-digital converter (ADC). This chapter
describes the operation of the ADC12_A module.
REFOUT REFBURST
VeREF+ REFON
ADC12SR REF2_5V
INCHx = 0Ah
0
VREF+ on
1 1.5 V or 2.5 V VCC
VREF-/VeREF- Reference
Ref_x
AVCC
INCHx
11 10 01 00 SREF1 ADC12OSC
4 AVSS SREF0 (see Note A)
AVSS
A The MODOSC is part of the UCS. See the UCS chapter for more information.
B See the device-specific data sheet for timer sources available.
Input
Ax
ESD Protection
SHI
SAMPCON 13 × ADC12CLK
tsample tconvert
tsync
ADC12CLK
SHI
SAMPCON 13 × ADC12CLK
tsample tconvert
tsync
ADC12CLK
MSP430
VI = Input voltage at pin Ax
VS = External source voltage
RS VI RI 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 n-bit conversion, where n equals the bits of resolution:
tsample > (RS + RI) × ln(2n+1) × CI + 800 ns
Substituting the values for RI and CI given above, the equation becomes:
tsample > (RS + 1.8 kΩ) × ln(2n+1) × 25 pF + 800 ns
For example, for 12-bit resolution, if RS is 10 kΩ, tsample must be greater than 3.46 µs.
CONSEQx = 00
ADC12
ADC12ON = 1
off
ADC12ENC ¹
x = CSTARTADDx
Wait for Enable
ADC12ENC =
SHSx = 0
and ADC12ENC =
ADC12ENC = 1 or
and
ADC12SC = Wait for Trigger
SAMPCON =
ADC12ENC = 0
SAMPCON = 1
Sample, Input
Channel Defined in
ADC12ENC = 0 ADC12MCTLx
(see Note A)
SAMPCON =
12 × ADC12CLK
Convert
ADC12ENC = 0
(see Note A)
1 × ADC12CLK
Conversion
Completed,
Result Stored Into
ADC12MEMx,
ADC12IFG.x is Set
x = pointer to ADC12MCTLx
Sequence-of-Channels Mode
A sequence of channels is sampled and converted once. The ADC results are written to the conversion
memories starting with the ADCMEMx defined by the CSTARTADDx bits. The sequence stops after the
measurement of the channel with a set ADC12EOS bit. Figure 22-7 shows the sequence-of-channels
mode. When ADC12SC triggers a sequence, successive sequences can be triggered by the ADC12SC
bit. When any other trigger source is used, ADC12ENC must be toggled between each sequence.
CONSEQx = 01 ADC12
off
ADC12ON = 1
ADC12ENC ¹
x = CSTARTADDx
Wait for Enable
ADC12ENC =
SHSx = 0 ADC12ENC =
and
ADC12ENC = 1 or
and Wait for Trigger
ADC12SC =
SAMPCON =
ADC12EOS.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 × ADC12CLK
(ADC12MSC = 0
Convert or
ADC12MSC = 1
ADC12SHP = 0)
and
and
ADC12SHP = 1 1 × ADC12CLK ADC12EOS.x = 0
and
ADC12EOS.x = 0
Conversion
Completed,
Result Stored Into
ADC12MEMx,
ADC12IFG.x is Set
x = pointer to ADC12MCTLx
Repeat-Single-Channel Mode
A single channel is sampled and converted continuously. The ADC results are written to the ADC12MEMx
defined by the CSTARTADDx bits. It is necessary to read the result after the completed conversion
because only one ADC12MEMx memory is used and is overwritten by the next conversion. Figure 22-8
shows the repeat-single-channel mode.
CONSEQx = 10 ADC12
off
ADC12ON = 1
ADC12ENC ¹
x = CSTARTADDx
Wait for Enable
ADC12
SHSx = 0 ADC12 ENC =
and ENC =
ADC12ENC = 1 or
and
ADC12SC = Wait for Trigger
SAMPCON = ADC12ENC = 0
SAMPCON = 1
Sample, Input
Channel Defined in
ADC12MCTLx
SAMPCON = 12 × ADC12CLK
(ADC12MSC = 0
ADC12MSC = 1 Convert or
and ADC12SHP = 0)
ADC12SHP = 1 and
and 1 × ADC12CLK
ADC12ENC = 1
ADC12ENC = 1
Conversion
Completed,
Result Stored Into
ADC12MEMx,
ADC12IFG.x is Set
x = pointer to ADC12MCTLx
Repeat-Sequence-of-Channels Mode
A sequence of channels is sampled and converted repeatedly. The ADC results are written to the
conversion memories starting with the ADC12MEMx defined by the CSTARTADDx bits. The sequence
ends after the measurement of the channel with a set ADC12EOS bit and the next trigger signal restarts
the sequence. Figure 22-9 shows the repeat-sequence-of-channels mode.
CONSEQx = 11 ADC12
off
ADC12ON = 1
ADC12ENC ¹
x = CSTARTADDx
Wait for Enable
ADC12ENC =
SHSx = 0 ADC12ENC =
and
ADC12ENC = 1 or
and Wait for Trigger
ADC12SC =
ADC12ENC = 0
SAMPCON = and
ADC12EOS.x = 1
SAMPCON = 1
Sample, Input
Channel Defined in If ADC12EOS.x = 1 then
x =CSTARTADDx
ADC12MCTLx
else {if x < 15 then x = x + 1 else
x = 0}
SAMPCON =
If ADC12EOS.x = 1 then
x =CSTARTADDx
else {if x < 15 then x = x + 1 else 12 × ADC12CLK
(ADC12MSC = 0
x = 0} Convert or
ADC12SHP = 0)
and
(ADC12ENC = 1
ADC12MSC = 1 and ADC12SHP = 1 1 × ADC12CLK or
and (ADC12ENC = 1 or ADC12EOS.x = 0) ADC12EOS.x = 0)
Conversion Completed,
Result Stored Into
ADC12MEMx,
ADC12IFG.x is Set
x = pointer to ADC12MCTLx
1.300
1.200
1.100
1.000
0.900
VTEMP = 0.00366(TEMP°C) + 0.894
0.800
0.700
−40 −20 0 20 40 60 80 100
Ambient Temperature – °C
DVCC
Digital
+
Power Supply
Decoupling
DVSS
10 µF 100 nF
AVCC
Analog
Power Supply +
Decoupling
AVSS
10 µF 100 nF
VREF+/VeREF+
Using an
External +
Positive
Reference
10 µF 100 nF
VREF–/VeREF–
Using an
External +
Negative
Reference
10 µF 100 nF
Note: All registers have word or byte register access. For a generic register ANYREG, the suffix
"_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H"
(ANYREG_H) refers to the upper byte of the register (bits 8 through 15).
7 6 5 4 3 2 1 0
ADC12
ADC12MSC ADC12 REFON ADC12ON ADC12OVIE ADC12TOVIE ADC12ENC ADC12SC
REF2_5V
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
ADC12SHT1x Bits 15-12 ADC12_A sample-and-hold time. These bits define the number of ADC12CLK cycles in the sampling
period for registers ADC12MEM8 to ADC12MEM15.
ADC12SHT0x Bits 11-8 ADC12_A sample-and-hold time. These bits define the number of ADC12CLK cycles in the sampling
period for registers ADC12MEM0 to ADC12MEM7.
ADC12SHTx ADC12CLK
Bits Cycles
0000 4
0001 8
0010 16
0011 32
0100 64
0101 96
0110 128
0111 192
1000 256
1001 384
1010 512
1011 768
1100 1024
1101 1024
1110 1024
1111 1024
ADC12MSC Bit 7 ADC12_A multiple sample and conversion. Valid only for sequence or repeated modes.
0 The sampling timer requires a rising edge of the SHI signal to trigger each sample-and-convert.
1 The first rising edge of the SHI signal triggers the sampling timer, but further
sample-and-conversions are performed automatically as soon as the prior conversion is
completed.
ADC12REF2_5V Bit 6 ADC12_A reference generator voltage. ADC12REFON must also be set.
0 1.5 V
1 2.5 V
ADC12REFON Bit 5 ADC12_A reference generator on. In devices with the REF module, this bit is only valid if the REFMSTR
bit of the REF module is set to 0. In the 'F54xx device, the REF module is not available.
0 Reference off
1 Reference on
ADC12ON Bit 4 ADC12_A on
0 ADC12_A off
1 ADC12_A on
ADC12OVIE Bit 3 ADC12MEMx overflow-interrupt enable. The GIE bit must also be set to enable the interrupt.
0 Overflow interrupt disabled
1 Overflow interrupt enabled
ADC12TOVIE Bit 2 ADC12_A conversion-time-overflow interrupt enable. The GIE bit must also be set to enable the
interrupt.
0 Conversion time overflow interrupt disabled
1 Conversion time overflow interrupt enabled
ADC12ENC Bit 1 ADC12_A enable conversion
0 ADC12_A disabled
1 ADC12_A enabled
ADC12SC Bit 0 ADC12_A start conversion. Software-controlled sample-and-conversion start. ADC12SC and
ADC12ENC may be set together with one instruction. ADC12SC is reset automatically.
0 No sample-and-conversion-start
1 Start sample-and-conversion
7 6 5 4 3 2 1 0
ADC12DIVx ADC12SSELx ADC12CONSEQx ADC12BUSY
rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0) r-(0)
ADC12CSTARTADDx Bits 15-12 ADC12_A conversion start address. These bits select which ADC12_A conversion-memory register
is used for a single conversion or for the first conversion in a sequence. The value of CSTARTADDx
is 0 to 0Fh, corresponding to ADC12MEM0 to ADC12MEM15.
ADC12SHSx Bits 11-10 ADC12_A sample-and-hold source select
00 ADC12SC bit
01 Timer source (see device-specific data sheet for exact timer and locations)
10 Timer source (see device-specific data sheet for exact timer and locations)
11 Timer source (see device-specific data sheet for exact timer and locations)
ADC12SHP Bit 9 ADC12_A sample-and-hold pulse-mode select. This bit selects the source of the sampling signal
(SAMPCON) to be either the output of the sampling timer or the sample-input signal directly.
0 SAMPCON signal is sourced from the sample-input signal.
1 SAMPCON signal is sourced from the sampling timer.
ADC12ISSH Bit 8 ADC12_A invert signal sample-and-hold
0 The sample-input signal is not inverted.
1 The sample-input signal is inverted.
ADC12DIVx Bits 7-5 ADC12_A clock divider
000 /1
001 /2
010 /3
011 /4
100 /5
101 /6
110 /7
111 /8
ADC12SSELx Bits 4-3 ADC12_A clock source select
00 ADC12OSC (MODOSC)
01 ACLK
10 MCLK
11 SMCLK
ADC12CONSEQx Bits 2-1 ADC12_A conversion sequence mode select
00 Single-channel, single-conversion
01 Sequence-of-channels
10 Repeat-single-channel
11 Repeat-sequence-of-channels
ADC12BUSY Bit 0 ADC12_A busy. This bit indicates an active sample or conversion operation.
0 No operation is active.
1 A sequence, sample, or conversion is active.
7 6 5 4 3 2 1 0
ADC12 ADC12
ADC12TCOFF Reserved ADC12RES ADC12DF ADC12SR
REFOUT REFBURST
rw-(0) r-0 rw-(1) rw-(0) rw-(0) rw-(0) rw-(0) rw-(0)
7 6 5 4 3 2 1 0
Conversion Results
rw rw rw rw rw rw rw rw
Conversion Bits 15-0 The 12-bit conversion results are right justified. Bit 11 is the MSB. Bits 15–12 are 0 in 12-bit mode, bits
Results 15–10 are 0 in 10-bit mode, and bits 15–8 are 0 in 8-bit mode. Writing to the conversion memory
registers corrupts the results. This data format is used if ADC12DF = 0.
7 6 5 4 3 2 1 0
Conversion Results 0 0 0 0
rw rw rw rw r0 r0 r0 r0
Conversion Bits 15-0 The 12-bit conversion results are left justified, 2s-complement format. Bit 15 is the MSB. Bits 3–0 are 0 in
Results 12-bit mode, bits 5–0 are 0 in 10-bit mode, and bits 7–0 are 0 in 8-bit mode. This data format is used if
ADC12DF = 1. The data is stored in the right-justified format and is converted to the left-justified
2s-complement format during read back.
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)
ADC12IEx Bits 15-0 Interrupt enable. These bits enable or disable the interrupt request for the ADC12IFGx bits.
0 Interrupt disabled
1 Interrupt enabled
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)
ADC12IFGx Bits 15-0 ADC12MEMx interrupt flag. These bits are set when corresponding ADC12MEMx is loaded with a
conversion result. The ADC12IFGx bits are reset if the corresponding ADC12MEMx is accessed, or may
be reset with software.
0 No interrupt pending
1 Interrupt pending
7 6 5 4 3 2 1 0
0 0 ADC12IVx 0
r0 r0 r-(0) r-(0) r-(0) r-(0) r-(0) r0
ADC12IV
Interrupt Source Interrupt Flag Interrupt Priority
Contents
000h No interrupt pending –
002h ADC12MEMx overflow – Highest
004h Conversion time overflow –
006h ADC12MEM0 interrupt flag ADC12IFG0
008h ADC12MEM1 interrupt flag ADC12IFG1
00Ah ADC12MEM2 interrupt flag ADC12IFG2
00Ch ADC12MEM3 interrupt flag ADC12IFG3
00Eh ADC12MEM4 interrupt flag ADC12IFG4
010h ADC12MEM5 interrupt flag ADC12IFG5
012h ADC12MEM6 interrupt flag ADC12IFG6
014h ADC12MEM7 interrupt flag ADC12IFG7
016h ADC12MEM8 interrupt flag ADC12IFG8
018h ADC12MEM9 interrupt flag ADC12IFG9
01Ah ADC12MEM10 interrupt flag ADC12IFG10
01Ch ADC12MEM11 interrupt flag ADC12IFG11
01Eh ADC12MEM12 interrupt flag ADC12IFG12
020h ADC12MEM13 interrupt flag ADC12IFG13
022h ADC12MEM14 interrupt flag ADC12IFG14
024h ADC12MEM15 interrupt flag ADC12IFG15 Lowest
Chapter 23
SLAU259 – May 2009
LCD_B Controller
The LCD_B controller drives static, 2-mux, 3-mux, or 4-mux LCDs. This chapter describes the LCD_B
controller.
Blinking
Memory Segment
Registers LCD
Output
LCDBMx Memory
SEG1 Control
Registers
Mux S1
LCDMx
SEG0
Mux S0
COM3
Common COM2
LCDBLKMODx Blinking and Output
Display Control Control COM1
LCDDISP
COM0
Blinking BLKCLK
Frequency Divider
LCDBLKPREx LCDBLKDIVx
VA VB VC VD VLCD
LCDPREx LCDDIVx LCDON V1
LCDSSEL
V2
Analog
fLCD Voltage V3
ACLK 0 LCD Frequency Timing Multiplexer
VLOCLK 1 Divider Generator V4
V5
LCDMXx
LCDSIZEx OSCOFF
LCDMXx (from SR)
LCD
REXT R03EXT
VLCDREFx VLCDx
V1
4
VLCD V2
Regulated Charge
V3
Pump/ LCD Bias Generator
Contrast Control V4
V5
LCDCPEN LCDCAP/R33
R23
LCDREF/R13 LCD LCD2B
R03 EXTBIAS
Sn+1 Sn
Blinking Memory
To enable individual segments for blinking the corresponding bit in the blinking memory LCDBMx registers
needs to be set. The memory uses the same structure as the LCD memory shown in Figure 23-2. Each
memory bit corresponds to one LCD segment, or is not used, depending on the multiplexing mode
LCDMXx. To enable blinking for a LCD segment, its corresponding memory bit is set.
The blinking memory can also be accessed word-wise using the even addresses starting at LCDBM1,
LCDBM3, ...
Setting the bit LCDCLRBM clears all blinking memory registers at the next frame boundary. It is
automatically reset after the registers are cleared.
Blinking Frequency
The blinking frequency fBLINK is selected with the LCDBLKPREx and LCDBLKDIVx bits. The same clock is
used as selected for the LCD frequency fLCD. The resulting fBLINK frequency is calculated by:
fACLK/VLO
fBlink = 9+LCDBLKPREx
(LCDBLKDIVx + 1) × 2
The divider generating the blinking frequency fBLINK is reset while LCDBLKMODx = 00. After a blinking
mode LCDBLKMODx = 01 or 10 is selected, the enabled segments or all segments go blank at the next
frame boundary and stay off for half a BLKCLK period. Then they go active at the next frame boundary
and stay on for another half BLKCLK period before they go blank again at a frame boundary.
The internal charge pump may use an external reference voltage when VLCDREFx = 01. In this case, the
charge pump voltage is set to a multiply of the external reference voltage according to the VLCDx bits
setting.
When VLCDEXT = 1, VLCD is sourced externally from the LCDCAP, pin and the internal charge pump is
disabled.
0 Internal VLCD
Charge VLCD
1
Pump
V4 int
R R
V3 int
V2 int
V4 (1/3 VLCD)
R R
1
0
R03 V5
1
Rx Rx Rx
Optional external resistors R03EXT
Rx = Optional contrast control
The internal bias generator supports 1/2 bias LCDs when LCD2B = 1, and 1/3 bias LCDs when LCD2B =
0 in 2-mux, 3-mux, and 4-mux modes. In static mode, the internal divider is disabled.
Some devices share the LCDCAP, R33, and R23 functions. In this case, the charge pump cannot be used
together with an external resistor divider with 1/3 biasing. When R03 is not available externally, V5 is
always VSS.
A typical approach to determine the required VLCD is by equating VRMS,OFF with a defined LCD threshold
voltage, typically when the LCD exhibits approximately 10% contrast (Vth,10%): VRMS,OFF = Vth,10%. Using
the values for VRMS,OFF/VLCD provided in the table results in VLCD = Vth,10%/(VRMS,OFF/VLCD). In the static
mode, a suitable choice is VLCD greater or equal than 3 times Vth,10%.
In 3-mux and 4-mux mode typically a 1/3 biasing is used but a 1/2 biasing scheme is also possible. The
1/2 bias reduces the contrast ratio but the advantage is a reduction of the required full-scale LCD voltage
VLCD.
COM0 V1
SP2
V5
SP1
SP6 a
V1
b SP2 Resulting voltage for
Segment a (COM0-SP1) 0V
SP7
Segment is on.
SP3
V1
Figure 23-5 shows an example static LCD, pinout, LCD-to-MSP430 connections, and the resulting
segment mapping. This is only an example. Segment mapping in a user’s application depends on the LCD
pinout and on the MSP430-to-LCD connections.
LCD
a a a a
f g b f g b f g b f g b
e c e c e c e c
d h d h d h d h
DIGIT4 DIGIT1
Figure 23-5. Static LCD Example (MAB addresses need to be replaced with LCDMx)
...........
...........
;
Table DB a+b+c+d+e+f ; displays "0"
DB b+c; ; displays "1"
...........
...........
DB
...........
V1
SP2
b V5
SP1
V1
Resulting voltage for V3
h Segment h (COM0-SP2) 0V
SP4 Segment is on.
SP2 -V3
SP3 -V1
SP = Segment Pin
V1
Resulting voltage for V3
Segment b (COM1-SP2) 0V
Segment is Off. -V3
-V5
f g b f g b
e c e c
d h d h
DIGIT8 DIGIT1
Figure 23-7. 2-Mux LCD Example (MAB addresses need to be replaced with LCDMx)
Figure 23-9 shows an example 3-mux LCD, pinout, LCD-to-MSP430 connections, and the resulting
segment mapping. This is only an example. Segment mapping in a user’s application depends on the LCD
pinout and on the MSP430-to-LCD connections.
LCD
y a y a
f g b f g b
e c e c
d h d h
DIGIT10 DIGIT1
Figure 23-9. 3-Mux LCD Example (MAB addresses need to be replaced with LCDMx)
V1
Resulting voltage for
0V
Segment e (COM1-SP1)
Segment is off. -V1
V1
Resulting voltage for
Segment c (COM1-SP2) 0V
Segment is on.
-V1
f b f b
g g
e c e c
d h d h
DIGIT15 DIGIT1
Connections COM 3 2 1 0 3 2 1 0
MSP430 LCD Pinout
Pins
PIN COM0 COM1 COM2 COM3 MAB 09Fh a b c h f g e d n = 30 Digit 16
1g 1f 09Eh a b c h f g e d 28 Digit 15
S0 1 1d 1e
S1 2 1h 1c 1b 1a a b c h f g e d 26 Digit 14
09Dh
S2 3 2d 2e 2g 2f a b c h f g e d
09Ch 24 Digit 13
S3 4 2h 2c 2b 2a
S4 5 3d 3e 3g 3f a b c h f g e d 22 Digit 12
09Bh
S5 6 3h 3c 3b 3a a b c h f g e d 20 Digit 11
S6 7 4d 4e 4g 4f 09Ah
a b c h f g e d 18 Digit 10
S7 8 4h 4c 4b 4a 099h
S8 9 5d 5e 5g 5f a b c h f g e d 16 Digit 9
098h
S9 10 5h 5c 5b 5a a b c h f g e d 14 Digit 8
S10 11 6d 6e 6g 6f 097h
a b c h f g e d 12 Digit 7
S11 12 6h 6c 6b 6a
096h a b c h f g e d
S12 13 7d 7e 7g 7f 10 Digit 6
S13 14 7h 7c 7b 7a 095h
a b c h f g e d 8 Digit 5
S14 15 8d 8e 8g 8f 094h a b c h f g e d 6 Digit 4
S15 16 8h 8c 8b 8a
S16 17 9d 9e 9g 9f 093h a b c h f g e d 4 Digit 3
S17 18 9h 9c 9b 9a 092h a b c h f g e d 2 Digit 2
S18 19 10d 10e 10g 10f
091h a b c h f g e d 0 Digit 1
S19 20 10h 10c 10b 10a
S20 21 11d 11e 11g 11f
S21 22 11h 11c 11b 11a 3 2 1 0 3 2 1 0
A 0 A Parallel-Serial
S22 23 12d 12e 12g 12f 0
G G Conversion
S23 24 12h 12c 12b 12a B 3 3 B
S24 25 13d 13e 13g 13f
S25 26 13h 13c 13b 13a
S26 27 14d 14e 14g 14f
S27 28 14h 14c 14b 14a Sn+1 Sn
S28 29 15d 15e 15g 15f
S29 30 15h 15c 15b 15a
COM0 31 COM0
COM1 32 COM1
COM2 33 COM2
COM3 34 COM3
Figure 23-11. 4-Mux LCD Example (MAB addresses need to be replaced with LCDMx)
7 6 5 4 3 2 1 0
LCDSSEL Reserved LCDMXx LCDSON Reserved LCDON
rw-0 r0 r0 rw-0 rw-0 rw-0 r0 rw-0
LCDDIVx Bits 15-11 LCD frequency divider. Together with LCDPREx the LCD frequency fLCD is calculated as fLCD =
fACLK/VLO / ((LCDDIVx + 1) × 2LCDPREx).
00000 Divide by 1
00001 Divide by 2
⋮
11110 Divide by 31
11111 Divide by 32
LCDPREx Bits 10-8 LCD frequency pre-scaler. Together with LCDDIVx the LCD frequency fLCD is calculated as fLCD =
fACLK/VLO / ((LCDDIVx + 1) × 2LCDPREx).
000 Divide by 1
001 Divide by 2
010 Divide by 4
011 Divide by 8
100 Divide by 16
101 Divide by 32
110 Reserved - Defaults to divide by 32
111 Reserved - Defaults to divide by 32
LCDSSEL Bit 7 Clock source select for LCD and blinking frequency
0 ACLK (30 kHz to 40 kHz)
1 VLOCLK
Reserved Bits 6-5 Reserved
LCDMXx Bits 4-3 LCD mux rate. These bits select the LCD mode.
00 Static
01 2-mux
10 3-mux
11 4-mux
LCDSON Bit 2 LCD segments on. This bit supports flashing LCD applications by turning off all segment lines, while
leaving the LCD timing generator and R33 enabled.
0 All LCD segments are off.
1 All LCD segments are enabled and on or off according to their corresponding memory
location.
Reserved Bit 1 Reserved
LCDON Bit 0 LCD on. This bit turns the LCD_B module on or off.
0 LCD_B module off
1 LCD_B module on
Note: Settings for LCDDIVx, LCDPREx, LCDSSEL, and LCDMx should be changed only while
LCDON = 0.
7 6 5 4 3 2 1 0
Reserved LCD LCD LCD LCDFRMIFG
NOCAPIFG BLKONIFG BLKOFFIFG
r0 r0 r0 r0 rw-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
LCDBLKDIVx LCDBLKPREx LCDBLKMODx
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
Note: Settings for LCDBLKDIVx and LCDBLKPREx should only be changed while LCDBLKMODx = 00.
7 6 5 4 3 2 1 0
Reserved LCDCLRBM LCDCLRM LCDDISP
r0 r0 r0 r0 r0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
LCDREXT R03EXT LCDEXTBIAS VLCDEXT LCDCPEN VLCDREFx LCD2B
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
Note: Settings for LCDREXT, R03EXT, LCDEXTBIAS, VLCDEXT, VLCDREFx, and LCD2B should only
be changed while LCDON = 0.
7 6 5 4 3 2 1 0
LCDS7 LCDS6 LCDS5 LCDS4 LCDS3 LCDS2 LCDS1 LCDS0
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
LCDS23 LCDS22 LCDS21 LCDS20 LCDS19 LCDS18 LCDS17 LCDS16
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
LCDS39 LCDS38 LCDS37 LCDS36 LCDS35 LCDS34 LCDS33 LCDS32
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
Reserved LCDS50 LCDS49 LCDS48
r0 r0 r0 r0 r0 rw-0 rw-0 rw-0
7 6 5 4 3 2 1 0
LCDCPDISx
rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0 rw-0
CC430F62x1 Assignment
LCDCPDISx Bits 7-3 Reserved
LCDCPDIS2 Bit 2 LCD charge pump disable during ADC12 conversion
0 LCD charge pump not automatically disabled during conversion.
1 LCD charge pump automatically disabled during conversion.
LCDCPDIS1 Bit 1 LCD charge pump disable during radio transmit
0 LCD charge pump not automatically disabled during radio transmit.
1 LCD charge pump automatically disabled during radio transmit.
LCDCPDIS0 Bit 0 LCD charge pump disable during radio receive
0 LCD charge pump not automatically disabled during radio receive.
1 LCD charge pump automatically disabled during radio receive.
7 6 5 4 3 2 1 0
0 0 0 0 LCDBIVx 0
r0 r0 r0 r0 r0 r0 r0 r0
LCDBIV Interrupt
Interrupt Source Interrupt Flag
Contents Priority
00h No interrupt pending –
02h No capacitor connected LCDNOCAPIFG Highest
04h Blink, segments on LCDBLKONIFG
06h Blink, segments off LCDBLKOFFIFG
08h Frame interrupt LCDFRMIFG Lowest
Chapter 24
SLAU259 – May 2009
This chapter describes the embedded emulation module (EEM) that is implemented in all flash devices.
MB1
MB2
MB3
MB4
MB5
MB6
MB7
CPU0
CPU1
& & & & & & & & & &
Trigger Sequencer
OR CPU Stop
24.2.1 Triggers
The event control in the EEM of the MSP430 system consists of triggers, which are internal signals
indicating that a certain event has happened. These triggers may be used as simple breakpoints, but it is
also possible to combine two or more triggers to allow detection of complex events and cause various
reactions other than stopping the CPU.
In general, the triggers can be used to control the following functional blocks of the EEM:
• Breakpoints (CPU stop)
• State storage
• Sequencer
• Cycle counter
There are two different types of triggers – the memory trigger and the CPU register write trigger.
Each memory trigger block can be independently selected to compare either the MAB or the MDB with a
given value. Depending on the implemented EEM, the comparison can be =, ≠, ≥, or ≤. The comparison
can also be limited to certain bits with the use of a mask. The mask is either bit-wise or byte-wise,
depending upon the device. In addition to selecting the bus and the comparison, the condition under which
the trigger is active can be selected. The conditions include read access, write access, DMA access, and
instruction fetch.
Each CPU register write trigger block can be independently selected to compare what is written into a
selected register with a given value. The observed register can be selected for each trigger independently.
The comparison can be =, ≠, ≥, or ≤. The comparison can also be limited to certain bits with the use of a
bit mask.
Both types of triggers can be combined to form more complex triggers. For example, a complex trigger
can signal when a particular value is written into a user-specified address.