User’s Guide 2005 Mixed Signal Products SLAU049E
IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements, and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should obtain the latest relevant information before placing orders and should verify that such information is current and complete.
Related Documentation From Texas Instruments Preface About This Manual This manual discusses modules and peripherals of the MSP430x1xx family of devices. Each discussion presents the module or peripheral in a general sense. Not all features and functions of all modules or peripherals are present on all devices. In addition, modules or peripherals may differ in their exact implementation between device families, or may not be fully implemented on an individual device or device family.
Glossary Glossary ACLK Auxiliary Clock See Basic Clock Module ADC Analog-to-Digital Converter BOR Brown-Out Reset See System Resets, Interrupts, and Operating Modes BSL Bootstrap Loader See www.ti.
Register Bit Conventions Register Bit Conventions Each register is shown with a key indicating the accessibility of the each individual bit, and the initial condition: Register Bit Accessibility and Initial Condition Key Bit Accessibility rw Read/write r Read only r0 Read as 0 r1 Read as 1 w Write only w0 Write as 0 w1 Write as 1 (w) No register bit implemented; writing a 1 results in a pulse. The register bit is always read as 0.
vi
Contents 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Flexible Clock System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Embedded Emulation . . . . . . . . . . . . . . . . . . .
Contents 3 RISC 16-Bit CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1 3.1 CPU Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 3.2 CPU Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 3.2.1 Program Counter (PC) . . . . . . . . . . . . . . . . . .
Contents 6 Supply Voltage Supervisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1 SVS Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2 SVS Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2.1 Configuring the SVS . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents 10 Watchdog Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.1 Watchdog Timer Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.2 Watchdog Timer Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.2.1 Watchdog Timer Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents 14 USART Peripheral Interface, SPI Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1 14.1 USART Introduction: SPI Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-2 14.2 USART Operation: SPI Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4 14.2.1 USART Initialization and Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents 18 ADC10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-1 18.1 ADC10 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-2 18.2 ADC10 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-4 18.2.1 10-Bit ADC Core . . . . . . . . . . . . . . . . . .
Chapter 1 This chapter describes the architecture of the MSP430. Topic Page 1.1 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 1.2 Flexible Clock System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 1.3 Embedded Emulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 1.4 Address Space . . . . . . . . . . . . . . . . . . . . . . . . . . .
Architecture 1.1 Architecture The MSP430 incorporates a 16-bit RISC CPU, peripherals, and a flexible clock system that interconnect using a von-Neumann common memory address bus (MAB) and memory data bus (MDB). Partnering a modern CPU with modular memory-mapped analog and digital peripherals, the MSP430 offers solutions for demanding mixed-signal applications. Key features of the MSP430x1xx family include: - Ultralow-power architecture extends battery life J 0.1-µA RAM retention J 0.
Embedded Emulation Figure 1−1. MSP430 Architecture ACLK Clock System SMCLK Flash/ ROM RAM Peripheral Peripheral Peripheral RISC CPU 16-Bit JTAG/Debug MCLK MAB 16-Bit MDB 16-Bit Bus Conv. MDB 8-Bit JTAG ACLK SMCLK Watchdog Peripheral Peripheral Peripheral Peripheral 1.3 Embedded Emulation Dedicated embedded emulation logic resides on the device itself and is accessed via JTAG using no additional system resources.
Address Space 1.4 Address Space The MSP430 von-Neumann architecture has one address space shared with special function registers (SFRs), peripherals, RAM, and Flash/ROM memory as shown in Figure 1−2. See the device-specific data sheets for specific memory maps. Code access are always performed on even addresses. Data can be accessed as bytes or words. The addressable memory space is 64 KB with future expansion planned. Figure 1−2.
Address Space 1.4.3 Peripheral Modules Peripheral modules are mapped into the address space. The address space from 0100 to 01FFh is reserved for 16-bit peripheral modules. These modules should be accessed with word instructions. If byte instructions are used, only even addresses are permissible, and the high byte of the result is always 0. The address space from 010h to 0FFh is reserved for 8-bit peripheral modules. These modules should be accessed with byte instructions.
1-6 Introduction
Chapter 2 This chapter describes the MSP430x1xx system resets, interrupts, and operating modes. Topic Page 2.1 System Reset and Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 2.2 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 2.3 Operating Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14 2.
System Reset and Initialization 2.1 System Reset and Initialization The system reset circuitry shown in Figure 2−1 sources both a power-on reset (POR) and a power-up clear (PUC) signal. Different events trigger these reset signals and different initial conditions exist depending on which signal was generated. Figure 2−1.
System Reset and Initialization 2.1.1 Power-On Reset (POR) When the VCC rise time is slow, the POR detector holds the POR signal active until VCC has risen above the VPOR level, as shown in Figure 2−2. When the VCC supply provides a fast rise time the POR delay, t(POR_DELAY), provides active time on the POR signal to allow the MSP430 to initialize. If power to the MSP430 is cycled, the supply voltage VCC must fall below Vmin to ensure that another POR signal occurs when VCC is powered up again.
System Reset and Initialization 2.1.2 Brownout Reset (BOR) Some devices have a brownout reset circuit (see device-specific datasheet) that replaces the POR detect and POR delay circuits. The brownout reset circuit detects low supply voltages such as when a supply voltage is applied to or removed from the VCC terminal. The brownout reset circuit resets the device by triggering a POR signal when power is applied or removed. The operating levels are shown in Figure 2−3.
System Reset and Initialization 2.1.3 Device Initial Conditions After System Reset After a POR, the initial MSP430 conditions are: - The RST/NMI pin is configured in the reset mode. - I/O pins are switched to input mode as described in the Digital I/O chapter. - Other peripheral modules and registers are initialized as described in their respective chapters in this manual. - Status register (SR) is reset. - The watchdog timer powers up active in watchdog mode.
System Reset and Initialization 2.2 Interrupts The interrupt priorities are fixed and defined by the arrangement of the modules in the connection chain as shown in Figure 2−4. The nearer a module is to the CPU/NMIRS, the higher the priority. Interrupt priorities determine what interrupt is taken when more than one interrupt is pending simultaneously. There are three types of interrupts: - System reset - (Non)-maskable NMI - Maskable Figure 2−4.
System Reset and Initialization 2.2.1 (Non)-Maskable Interrupts (NMI) (Non)-maskable NMI interrupts are not masked by the general interrupt enable bit (GIE), but are enabled by individual interrupt enable bits (NMIIE, ACCVIE, OFIE). When a NMI interrupt is accepted, all NMI interrupt enable bits are automatically reset. Program execution begins at the address stored in the (non)-maskable interrupt vector, 0FFFCh.
System Reset and Initialization Figure 2−5. Block Diagram of (Non)-Maskable Interrupt Sources ACCV S ACCVIFG FCTL1.1 ACCVIE IE1.5 Clear Flash Module PUC RST/NMI POR PUC KEYV VCC PUC System Reset Generator POR S NMIIFG NMIRS IFG1.4 WDTTMSEL Clear WDTNMIES WDTNMI WDTQn EQU PUC POR PUC NMIIE S IE1.4 Clear WDTIFG IRQ IFG1.0 Clear PUC WDT Counter OSCFault POR S OFIFG IFG1.1 IRQA WDTTMSEL OFIE WDTIE IE1.1 Clear IE1.
System Reset and Initialization Flash Access Violation The flash ACCVIFG flag is set when a flash access violation occurs. The flash access violation can be enabled to generate an NMI interrupt by setting the ACCVIE bit. The ACCVIFG flag can then be tested by NMI the interrupt service routine to determine if the NMI was caused by a flash access violation. Oscillator Fault The oscillator fault signal warns of a possible error condition with the crystal oscillator.
System Reset and Initialization Example of an NMI Interrupt Handler The NMI interrupt is a multiple-source interrupt. An NMI interrupt automatically resets the NMIIE, OFIE and ACCVIE interrupt-enable bits. The user NMI service routine resets the interrupt flags and re-enables the interrupt-enable bits according to the application needs as shown in Figure 2−6. Figure 2−6.
System Reset and Initialization Each individual peripheral interrupt is discussed in the associated peripheral module chapter in this manual. 2.2.3 Interrupt Processing When an interrupt is requested from a peripheral and the peripheral interrupt enable bit and GIE bit are set, the interrupt service routine is requested. Only the individual enable bit must be set for (non)-maskable interrupts to be requested.
System Reset and Initialization Return From Interrupt The interrupt handling routine terminates with the instruction: RETI (return from an interrupt service routine) The return from the interrupt takes 5 cycles to execute the following actions and is illustrated in Figure 2−8. 1) The SR with all 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.
System Reset and Initialization 2.2.4 Interrupt Vectors The interrupt vectors and the power-up starting address are located in the address range 0FFFFh − 0FFE0h as described in Table 2−1. A vector is programmed by the user with the 16-bit address of the corresponding interrupt service routine. See the device-specific data sheet for the complete interrupt vector list. Table 2−1.
Operating Modes 2.3 Operating Modes The MSP430 family is designed for ultralow-power applications and uses different operating modes shown in Figure 2−10. The operating modes take into account three different needs: - Ultralow-power - Speed and data throughput - Minimization of individual peripheral current consumption The MSP430 typical current consumption is shown in Figure 2−9. Figure 2−9.
Operating Modes Figure 2−10.
Operating Modes 2.3.1 Entering and Exiting Low-Power Modes An enabled interrupt event wakes the MSP430 from any of the low-power operating modes. The program flow is: - Enter interrupt service routine: J The PC and SR are stored on the stack J The CPUOFF, SCG1, and OSCOFF bits are automatically reset - Options for returning from the interrupt service routine: J The original SR is popped from the stack, restoring the previous operating mode.
Principles for Low-Power Applications 2.4 Principles for Low-Power Applications Often, the most important factor for reducing power consumption is using the MSP430’s clock system to maximize the time in LPM3. LPM3 power consumption is less than 2 µA typical with both a real-time clock function and all interrupts active. A 32-kHz watch crystal is used for the ACLK and the CPU is clocked from the DCO (normally off) which has a 6-µs wake-up. - Use interrupts to wake the processor and control program flow.
2-18 System Resets, Interrupts, and Operating Modes
Chapter 3 ! This chapter describes the MSP430 CPU, addressing modes, and instruction set. Topic Page 3.1 CPU Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 3.2 CPU Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 3.3 Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 3.4 Instruction Set . . . . . . . . . . .
CPU Introduction 3.1 CPU Introduction The CPU incorporates features specifically designed for modern programming techniques such as calculated branching, table processing and the use of high-level languages such as C. The CPU can address the complete address range without paging. The CPU features include: - RISC architecture with 27 instructions and 7 addressing modes. - Orthogonal architecture with every instruction usable with every addressing mode.
CPU Introduction Figure 3−1.
CPU Registers 3.2 CPU Registers The CPU incorporates sixteen 16-bit registers. R0, R1, R2 and R3 have dedicated functions. R4 to R15 are working registers for general use. 3.2.1 Program Counter (PC) The 16-bit program counter (PC/R0) points to the next instruction to be executed. Each instruction uses an even number of bytes (two, four, or six), and the PC is incremented accordingly. Instruction accesses in the 64-KB address space are performed on word boundaries, and the PC is aligned to even addresses.
CPU Registers 3.2.2 Stack Pointer (SP) The stack pointer (SP/R1) is used by the CPU to store the return addresses of subroutine calls and interrupts. It uses a predecrement, postincrement scheme. In addition, the SP can be used by software with all instructions and addressing modes. Figure 3−3 shows the SP. The SP is initialized into RAM by the user, and is aligned to even addresses. Figure 3−4 shows stack usage. Figure 3−3.
CPU Registers 3.2.3 Status Register (SR) The status register (SR/R2), used as a source or destination register, can be used in the register mode only addressed with word instructions. The remaining combinations of addressing modes are used to support the constant generator. Figure 3−6 shows the SR bits. Figure 3−6. Status Register Bits 15 9 Reserved 8 V 7 SCG1 0 OSC CPU SCG0 GIE OFF OFF N Z C rw-0 Table 3−1 describes the status register bits. Table 3−1.
CPU Registers 3.2.4 Constant Generator Registers CG1 and CG2 Six commonly-used constants are generated with the constant generator registers R2 and R3, without requiring an additional 16-bit word of program code. The constants are selected with the source-register addressing modes (As), as described in Table 3−2. Table 3−2.
CPU Registers 3.2.5 General−Purpose Registers R4 - R15 The twelve registers, R4−R15, are general-purpose registers. All of these registers can be used as data registers, address pointers, or index values and can be accessed with byte or word instructions as shown in Figure 3−7. Figure 3−7.
Addressing Modes 3.3 Addressing Modes Seven addressing modes for the source operand and four addressing modes for the destination operand can address the complete address space with no exceptions. The bit numbers in Table 3−3 describe the contents of the As (source) and Ad (destination) mode bits. Table 3−3.
Addressing Modes 3.3.1 Register Mode The register mode is described in Table 3−4. Table 3−4. Register Mode Description Assembler Code MOV Content of ROM R10,R11 MOV R10,R11 Length: One or two words Operation: Move the content of R10 to R11. R10 is not affected.
Addressing Modes 3.3.2 Indexed Mode The indexed mode is described in Table 3−5. Table 3−5. Indexed Mode Description Assembler Code MOV Content of ROM 2(R5),6(R6) MOV X(R5),Y(R6) X=2 Y=6 Length: Two or three words Operation: Move the contents of the source address (contents of R5 + 2) to the destination address (contents of R6 + 6). The source and destination registers (R5 and R6) are not affected.
Addressing Modes 3.3.3 Symbolic Mode The symbolic mode is described in Table 3−6. Table 3−6. Symbolic Mode Description Assembler Code Content of ROM MOV EDE,TONI MOV X(PC),Y(PC) X = EDE − PC Y = TONI − PC Length: Two or three words Operation: Move the contents of the source address EDE (contents of PC + X) to the destination address TONI (contents of PC + Y). The words after the instruction contain the differences between the PC and the source or destination addresses.
Addressing Modes 3.3.4 Absolute Mode The absolute mode is described in Table 3−7. Table 3−7. Absolute Mode Description Assembler Code MOV &EDE,&TONI Content of ROM MOV X(0),Y(0) X = EDE Y = TONI Length: Two or three words Operation: Move the contents of the source address EDE to the destination address TONI. The words after the instruction contain the absolute address of the source and destination addresses.
Addressing Modes 3.3.5 Indirect Register Mode The indirect register mode is described in Table 3−8. Table 3−8. Indirect Mode Description Assembler Code MOV @R10,0(R11) MOV @R10,0(R11) Length: One or two words Operation: Move the contents of the source address (contents of R10) to the destination address (contents of R11). The registers are not modified. Comment: Valid only for source operand. The substitute for destination operand is 0(Rd). Example: MOV.
Addressing Modes 3.3.6 Indirect Autoincrement Mode The indirect autoincrement mode is described in Table 3−9. Table 3−9. Indirect Autoincrement Mode Description Assembler Code MOV Content of ROM @R10+,0(R11) MOV @R10+,0(R11) Length: One or two words Operation: Move the contents of the source address (contents of R10) to the destination address (contents of R11).
Addressing Modes 3.3.7 Immediate Mode The immediate mode is described in Table 3−10. Table 3−10.Immediate Mode Description Assembler Code MOV Content of ROM #45h,TONI MOV @PC+,X(PC) 45 X = TONI − PC Length: Two or three words It is one word less if a constant of CG1 or CG2 can be used. Operation: Move the immediate constant 45h, which is contained in the word following the instruction, to destination address TONI.
Instruction Set 3.4 Instruction Set The complete MSP430 instruction set consists of 27 core instructions and 24 emulated instructions. The core instructions are instructions that have unique op-codes decoded by the CPU. The emulated instructions are instructions that make code easier to write and read, but do not have op-codes themselves, instead they are replaced automatically by the assembler with an equivalent core instruction. There is no code or performance penalty for using emulated instruction.
Instruction Set 3.4.1 Double-Operand (Format I) Instructions Figure 3−9 illustrates the double-operand instruction format. Figure 3−9. Double Operand Instruction Format 15 14 13 12 11 10 9 8 S-Reg Op-code 7 6 Ad B/W 5 4 3 2 0 1 D-Reg As Table 3−11 lists and describes the double operand instructions. Table 3−11. Double Operand Instructions Mnemonic S-Reg, D-Reg Operation MOV(.B) src,dst ADD(.B) ADDC(.
Instruction Set 3.4.2 Single-Operand (Format II) Instructions Figure 3−10 illustrates the single-operand instruction format. Figure 3−10. Single Operand Instruction Format 15 14 13 12 11 10 9 8 7 Op-code 6 5 B/W 4 3 2 0 1 D/S-Reg Ad Table 3−12 lists and describes the single operand instructions. Table 3−12.Single Operand Instructions S-Reg, D-Reg Operation RRC(.B) dst C → MSB →.......LSB → C * * * * RRA(.B) dst MSB → MSB →....LSB → C 0 * * * PUSH(.
Instruction Set 3.4.3 Jumps Figure 3−11 shows the conditional-jump instruction format. Figure 3−11. Jump Instruction Format 15 14 13 Op-code 12 11 10 9 8 7 C 6 5 4 3 2 1 0 10-Bit PC Offset Table 3−13 lists and describes the jump instructions. Table 3−13.
Instruction Set ADC[.W] ADC.B Add carry to destination Add carry to destination Syntax ADC ADC.B Operation dst + C −> dst Emulation ADDC ADDC.B Description The carry bit (C) is added to the destination operand. The previous contents of the destination are lost.
Instruction Set ADD[.W] ADD.B Add source to destination Add source to destination Syntax ADD ADD.B Operation src + dst −> dst Description The source operand is added to the destination operand. The source operand is not affected. The previous contents of the destination are lost. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example R5 is increased by 10. The jump to TONI is performed on a carry. ADD.
Instruction Set ADDC[.W] ADDC.B Add source and carry to destination Add source and carry to destination Syntax ADDC ADDC.B Operation src + dst + C −> dst Description The source operand and the carry bit (C) are added to the destination operand. The source operand is not affected. The previous contents of the destination are lost. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Instruction Set AND[.W] AND.B Source AND destination Source AND destination Syntax AND AND.B Operation src .AND. dst −> dst Description The source operand and the destination operand are logically ANDed. The result is placed into the destination. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example The bits set in R5 are used as a mask (#0AA55h) for the word addressed by TOM. If the result is zero, a branch is taken to label TONI.
Instruction Set BIC[.W] BIC.B Clear bits in destination Clear bits in destination Syntax BIC BIC.B Operation .NOT.src .AND. dst −> dst Description The inverted source operand and the destination operand are logically ANDed. The result is placed into the destination. The source operand is not affected. Status Bits Status bits are not affected. Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example The six MSBs of the RAM word LEO are cleared. BIC Example src,dst src,dst or BIC.
Instruction Set BIS[.W] BIS.B Set bits in destination Set bits in destination Syntax BIS BIS.B Operation src .OR. dst −> dst Description The source operand and the destination operand are logically ORed. The result is placed into the destination. The source operand is not affected. Status Bits Status bits are not affected. Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example The six LSBs of the RAM word TOM are set. BIS Example or BIS.
Instruction Set BIT[.W] BIT.B Test bits in destination Test bits in destination Syntax BIT Operation src .AND. dst Description The source and destination operands are logically ANDed. The result affects only the status bits. The source and destination operands are not affected. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example If bit 9 of R8 is set, a branch is taken to label TOM.
Instruction Set * BR, BRANCH Branch to .......... destination Syntax BR Operation dst −> PC Emulation MOV Description An unconditional branch is taken to an address anywhere in the 64K address space. All source addressing modes can be used. The branch instruction is a word instruction. Status Bits Status bits are not affected. Example Examples for all addressing modes are given. 3-28 dst dst,PC BR #EXEC ;Branch to label EXEC or direct branch (e.g.
Instruction Set CALL Subroutine Syntax CALL dst Operation dst SP − 2 PC tmp −> tmp −> SP −> @SP −> PC dst is evaluated and stored PC updated to TOS dst saved to PC Description A subroutine call is made to an address anywhere in the 64K address space. All addressing modes can be used. The return address (the address of the following instruction) is stored on the stack. The call instruction is a word instruction. Status Bits Status bits are not affected.
Instruction Set * CLR[.W] * CLR.B Clear destination Clear destination Syntax CLR CLR.B Operation 0 −> dst Emulation MOV MOV.B Description The destination operand is cleared. Status Bits Status bits are not affected. Example RAM word TONI is cleared. CLR Example #0,dst #0,dst TONI ; 0 −> TONI R5 RAM byte TONI is cleared. CLR.B 3-30 or CLR.W dst Register R5 is cleared.
Instruction Set * CLRC Clear carry bit Syntax CLRC Operation 0 −> C Emulation BIC Description The carry bit (C) is cleared. The clear carry instruction is a word instruction. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example The 16-bit decimal counter pointed to by R13 is added to a 32-bit counter pointed to by R12.
Instruction Set * CLRN Clear negative bit Syntax CLRN Operation 0→N or (.NOT.src .AND. dst −> dst) Emulation BIC Description The constant 04h is inverted (0FFFBh) and is logically ANDed with the destination operand. The result is placed into the destination. The clear negative bit instruction is a word instruction. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example The Negative bit in the status register is cleared.
Instruction Set * CLRZ Clear zero bit Syntax CLRZ Operation 0→Z or (.NOT.src .AND. dst −> dst) Emulation BIC Description The constant 02h is inverted (0FFFDh) and logically ANDed with the destination operand. The result is placed into the destination. The clear zero bit instruction is a word instruction. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example The zero bit in the status register is cleared.
Instruction Set CMP[.W] CMP.B Compare source and destination Compare source and destination Syntax CMP CMP.B Operation dst + .NOT.src + 1 or (dst − src) Description The source operand is subtracted from the destination operand. This is accomplished by adding the 1s complement of the source operand plus 1. The two operands are not affected and the result is not stored; only the status bits are affected. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Instruction Set * DADC[.W] * DADC.B Add carry decimally to destination Add carry decimally to destination Syntax DADC DADC.B Operation dst + C −> dst (decimally) Emulation DADD DADD.B Description The carry bit (C) is added decimally to the destination.
Instruction Set DADD[.W] DADD.B Source and carry added decimally to destination Source and carry added decimally to destination Syntax DADD DADD.B Operation src + dst + C −> dst (decimally) Description The source operand and the destination operand are treated as four binary coded decimals (BCD) with positive signs. The source operand and the carry bit (C) are added decimally to the destination operand. The source operand is not affected. The previous contents of the destination are lost.
Instruction Set * DEC[.W] * DEC.B Decrement destination Decrement destination Syntax DEC DEC.B Operation dst − 1 −> dst Emulation Emulation SUB SUB.B Description The destination operand is decremented by one. The original contents are lost. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example R10 is decremented by 1 dst dst or DEC.
Instruction Set * DECD[.W] * DECD.B Double-decrement destination Double-decrement destination Syntax DECD DECD.B Operation dst − 2 −> dst Emulation Emulation SUB SUB.B Description The destination operand is decremented by two. The original contents are lost. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example R10 is decremented by 2. dst dst or DECD.
Instruction Set * DINT Disable (general) interrupts Syntax DINT Operation 0 → GIE or (0FFF7h .AND. SR → SR / .NOT.src .AND. dst −> dst) Emulation BIC Description All interrupts are disabled. The constant 08h is inverted and logically ANDed with the status register (SR). The result is placed into the SR. Status Bits Status bits are not affected. Mode Bits GIE is reset. OSCOFF and CPUOFF are not affected.
Instruction Set * EINT Enable (general) interrupts Syntax EINT Operation 1 → GIE or (0008h .OR. SR −> SR / .src .OR. dst −> dst) Emulation BIS Description All interrupts are enabled. The constant #08h and the status register SR are logically ORed. The result is placed into the SR. Status Bits Status bits are not affected. Mode Bits GIE is set. OSCOFF and CPUOFF are not affected. Example The general interrupt enable (GIE) bit in the status register is set.
Instruction Set * INC[.W] * INC.B Increment destination Increment destination Syntax INC INC.B Operation dst + 1 −> dst Emulation ADD Description The destination operand is incremented by one. The original contents are lost.
Instruction Set * INCD[.W] * INCD.B Double-increment destination Double-increment destination Syntax INCD INCD.B Operation dst + 2 −> dst Emulation Emulation ADD ADD.B Example The destination operand is incremented by two. The original contents are lost.
Instruction Set * INV[.W] * INV.B Invert destination Invert destination Syntax INV INV.B Operation .NOT.dst −> dst Emulation Emulation XOR XOR.B Description The destination operand is inverted. The original contents are lost. Status Bits N: Set if result is negative, reset if positive Z: Set if dst contained 0FFFFh, reset otherwise Set if dst contained 0FFh, reset otherwise C: Set if result is not zero, reset otherwise ( = .NOT. Zero) Set if result is not zero, reset otherwise ( = .NOT.
Instruction Set JC JHS Jump if carry set Jump if higher or same Syntax JC JHS Operation If C = 1: PC + 2 × offset −> PC If C = 0: execute following instruction Description The status register carry bit (C) is tested. If it is set, the 10-bit signed offset contained in the instruction LSBs is added to the program counter. If C is reset, the next instruction following the jump is executed. JC (jump if carry/higher or same) is used for the comparison of unsigned numbers (0 to 65536).
Instruction Set JEQ, JZ Jump if equal, jump if zero Syntax JEQ Operation If Z = 1: PC + 2 × offset −> PC If Z = 0: execute following instruction Description The status register zero bit (Z) is tested. If it is set, the 10-bit signed offset contained in the instruction LSBs is added to the program counter. If Z is not set, the instruction following the jump is executed. Status Bits Status bits are not affected. Example Jump to address TONI if R7 contains zero.
Instruction Set JGE Jump if greater or equal Syntax JGE Operation If (N .XOR. V) = 0 then jump to label: PC + 2 × offset −> PC If (N .XOR. V) = 1 then execute the following instruction Description The status register negative bit (N) and overflow bit (V) are tested. If both N and V are set or reset, the 10-bit signed offset contained in the instruction LSBs is added to the program counter. If only one is set, the instruction following the jump is executed.
Instruction Set JL Jump if less Syntax JL Operation If (N .XOR. V) = 1 then jump to label: PC + 2 × offset −> PC If (N .XOR. V) = 0 then execute following instruction Description The status register negative bit (N) and overflow bit (V) are tested. If only one is set, the 10-bit signed offset contained in the instruction LSBs is added to the program counter. If both N and V are set or reset, the instruction following the jump is executed. label This allows comparison of signed integers.
Instruction Set JMP Jump unconditionally Syntax JMP Operation PC + 2 × offset −> PC Description The 10-bit signed offset contained in the instruction LSBs is added to the program counter. Status Bits Status bits are not affected. Hint: This one-word instruction replaces the BRANCH instruction in the range of −511 to +512 words relative to the current program counter.
Instruction Set JN Jump if negative Syntax JN Operation if N = 1: PC + 2 × offset −> PC if N = 0: execute following instruction Description The negative bit (N) of the status register is tested. If it is set, the 10-bit signed offset contained in the instruction LSBs is added to the program counter. If N is reset, the next instruction following the jump is executed. Status Bits Status bits are not affected. Example The result of a computation in R5 is to be subtracted from COUNT.
Instruction Set JNC JLO Jump if carry not set Jump if lower Syntax JNC JLO Operation if C = 0: PC + 2 × offset −> PC if C = 1: execute following instruction Description The status register carry bit (C) is tested. If it is reset, the 10-bit signed offset contained in the instruction LSBs is added to the program counter. If C is set, the next instruction following the jump is executed. JNC (jump if no carry/lower) is used for the comparison of unsigned numbers (0 to 65536).
Instruction Set JNE JNZ Jump if not equal Jump if not zero Syntax JNE JNZ Operation If Z = 0: PC + 2 × offset −> PC If Z = 1: execute following instruction Description The status register zero bit (Z) is tested. If it is reset, the 10-bit signed offset contained in the instruction LSBs is added to the program counter. If Z is set, the next instruction following the jump is executed. Status Bits Status bits are not affected. Example Jump to address TONI if R7 and R8 have different contents.
Instruction Set MOV[.W] MOV.B Move source to destination Move source to destination Syntax MOV MOV.B Operation src −> dst Description The source operand is moved to the destination. The source operand is not affected. The previous contents of the destination are lost. Status Bits Status bits are not affected. Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example The contents of table EDE (word data) are copied to table TOM. The length of the tables must be 020h locations.
Instruction Set * NOP No operation Syntax NOP Operation None Emulation MOV 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.
Instruction Set * POP[.W] * POP.B Pop word from stack to destination Pop byte from stack to destination Syntax POP POP.B Operation @SP −> temp SP + 2 −> SP temp −> dst Emulation Emulation MOV MOV.B Description The stack location pointed to by the stack pointer (TOS) is moved to the destination. The stack pointer is incremented by two afterwards. Status Bits Status bits are not affected. Example The contents of R7 and the status register are restored from the stack.
Instruction Set PUSH[.W] PUSH.B Push word onto stack Push byte onto stack Syntax PUSH PUSH.B Operation SP − 2 → SP src → @SP Description The stack pointer is decremented by two, then the source operand is moved to the RAM word addressed by the stack pointer (TOS). Status Bits Status bits are not affected. Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example The contents of the status register and R8 are saved on the stack. PUSH PUSH Example src src or SR R8 PUSH.
Instruction Set * RET Return from subroutine Syntax RET Operation @SP→ PC SP + 2 → SP Emulation MOV Description The return address pushed onto the stack by a CALL instruction is moved to the program counter. The program continues at the code address following the subroutine call. Status Bits Status bits are not affected.
Instruction Set RETI Return from interrupt Syntax RETI Operation TOS SP + 2 TOS SP + 2 Description The status register is restored to the value at the beginning of the interrupt service routine by replacing the present SR contents with the TOS contents. The stack pointer (SP) is incremented by two. → SR → SP → PC → SP The program counter is restored to the value at the beginning of interrupt service. This is the consecutive step after the interrupted program flow.
Instruction Set * RLA[.W] * RLA.B Rotate left arithmetically Rotate left arithmetically Syntax RLA RLA.B Operation C <− MSB <− MSB−1 .... LSB+1 <− LSB <− 0 Emulation ADD ADD.B Description The destination operand is shifted left one position as shown in Figure 3−14. The MSB is shifted into the carry bit (C) and the LSB is filled with 0. The RLA instruction acts as a signed multiplication by 2. dst dst or RLA.
Instruction Set * RLC[.W] * RLC.B Rotate left through carry Rotate left through carry Syntax RLC RLC.B Operation C <− MSB <− MSB−1 .... LSB+1 <− LSB <− C Emulation ADDC Description The destination operand is shifted left one position as shown in Figure 3−15. The carry bit (C) is shifted into the LSB and the MSB is shifted into the carry bit (C). dst dst or RLC.W dst dst,dst Figure 3−15.
Instruction Set RRA[.W] RRA.B Rotate right arithmetically Rotate right arithmetically Syntax RRA RRA.B Operation MSB −> MSB, MSB −> MSB−1, ... LSB+1 −> LSB, Description The destination operand is shifted right one position as shown in Figure 3−16. The MSB is shifted into the MSB, the MSB is shifted into the MSB−1, and the LSB+1 is shifted into the LSB. dst dst or RRA.W dst LSB −> C Figure 3−16.
Instruction Set RRC[.W] RRC.B Rotate right through carry Rotate right through carry Syntax RRC RRC Operation C −> MSB −> MSB−1 .... LSB+1 −> LSB −> C Description The destination operand is shifted right one position as shown in Figure 3−17. The carry bit (C) is shifted into the MSB, the LSB is shifted into the carry bit (C). dst dst or RRC.W dst Figure 3−17.
Instruction Set * SBC[.W] * SBC.B Subtract source and borrow/.NOT. carry from destination Subtract source and borrow/.NOT. carry from destination Syntax SBC SBC.B Operation dst + 0FFFFh + C −> dst dst + 0FFh + C −> dst Emulation SUBC SUBC.B Description The carry bit (C) is added to the destination operand minus one. The previous contents of the destination are lost.
Instruction Set * SETC Set carry bit Syntax SETC Operation 1 −> C Emulation BIS Description The carry bit (C) is set. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Instruction Set * SETN Set negative bit Syntax SETN Operation 1 −> N Emulation BIS Description The negative bit (N) is set. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Instruction Set * SETZ Set zero bit Syntax SETZ Operation 1 −> Z Emulation BIS Description The zero bit (Z) is set. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected.
Instruction Set SUB[.W] SUB.B Subtract source from destination Subtract source from destination Syntax SUB SUB.B Operation dst + .NOT.src + 1 −> dst or [(dst − src −> dst)] Description The source operand is subtracted from the destination operand by adding the source operand’s 1s complement and the constant 1. The source operand is not affected. The previous contents of the destination are lost.
Instruction Set SUBC[.W]SBB[.W] SUBC.B,SBB.B Subtract source and borrow/.NOT. carry from destination Subtract source and borrow/.NOT. carry from destination Syntax SUBC SBB SUBC.B Operation dst + .NOT.src + C −> dst or (dst − src − 1 + C −> dst) Description The source operand is subtracted from the destination operand by adding the source operand’s 1s complement and the carry bit (C). The source operand is not affected. The previous contents of the destination are lost.
Instruction Set SWPB Swap bytes Syntax SWPB Operation Bits 15 to 8 <−> bits 7 to 0 Description The destination operand high and low bytes are exchanged as shown in Figure 3−18. Status Bits Status bits are not affected. Mode Bits OSCOFF, CPUOFF, and GIE are not affected. dst Figure 3−18. Destination Operand Byte Swap 15 8 7 Example MOV SWPB Example ; 0100000010111111 −> R7 ; 1011111101000000 in R7 The value in R5 is multiplied by 256. The result is stored in R5,R4.
Instruction Set SXT Extend Sign Syntax SXT Operation Bit 7 −> Bit 8 ......... Bit 15 Description The sign of the low byte is extended into the high byte as shown in Figure 3−19. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected. dst Set if result is negative, reset if positive Set if result is zero, reset otherwise Set if result is not zero, reset otherwise (.NOT. Zero) Reset Figure 3−19.
Instruction Set * TST[.W] * TST.B Test destination Test destination Syntax TST TST.B Operation dst + 0FFFFh + 1 dst + 0FFh + 1 Emulation CMP CMP.B Description The destination operand is compared with zero. The status bits are set according to the result. The destination is not affected. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example R7 is tested. If it is negative, continue at R7NEG; if it is positive but not zero, continue at R7POS.
Instruction Set XOR[.W] XOR.B Exclusive OR of source with destination Exclusive OR of source with destination Syntax XOR XOR.B Operation src .XOR. dst −> dst Description The source and destination operands are exclusive ORed. The result is placed into the destination. The source operand is not affected. Status Bits N: Z: C: V: Mode Bits OSCOFF, CPUOFF, and GIE are not affected. Example The bits set in R6 toggle the bits in the RAM word TONI. XOR.
Instruction Set 3.4.4 Instruction Cycles and Lengths The number of CPU clock cycles required for an instruction depends on the instruction format and the addressing modes used - not the instruction itself. The number of clock cycles refers to the MCLK. Interrupt and Reset Cycles Table 3−14 lists the CPU cycles for interrupt overhead and reset. Table 3−14.Interrupt and Reset Cycles No.
Instruction Set Format-I (Double Operand) Instruction Cycles and Lengths Table 3−16 lists the length and CPU cycles for all addressing modes of format-I instructions. Table 3−16.Format 1 Instruction Cycles and Lengths No.
Instruction Set 3.4.5 Instruction Set Description The instruction map is shown in Figure 3−20 and the complete instruction set is summarized in Table 3−17. Figure 3−20. Core Instruction Map 000 0xxx 4xxx 8xxx Cxxx 1xxx 14xx 18xx 1Cxx 20xx 24xx 28xx 2Cxx 30xx 34xx 38xx 3Cxx 4xxx 5xxx 6xxx 7xxx 8xxx 9xxx Axxx Bxxx Cxxx Dxxx Exxx Fxxx 3-74 040 080 0C0 RRC RRC.B SWPB 100 RRA 140 180 RRA.B SXT 1C0 200 240 280 PUSH PUSH.B CALL JNE/JNZ JEQ/JZ JNC JC JN JGE JL JMP MOV, MOV.B ADD, ADD.
Instruction Set Table 3−17.MSP430 Instruction Set Mnemonic ADC(.B)† V N Z dst Description Add C to destination dst + C → dst * * * C * ADD(.B) src,dst Add source to destination src + dst → dst * * * * ADDC(.B) src,dst Add source and C to destination src + dst + C → dst * * * * AND(.B) src,dst AND source and destination src .and. dst → dst 0 * * * BIC(.B) src,dst Clear bits in destination .not.src .and. dst → dst − − − − BIS(.
3-76
Chapter 4 " # " The basic clock module provides the clocks for MSP430x1xx devices. This chapter describes the operation of the basic clock module. The basic clock module is implemented in all MSP430x1xx devices. Topic Page 4.1 Basic Clock Module Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4−2 4.2 Basic Clock Module Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4−4 4.3 Basic Clock Module Registers . . . . . . . . . . . . . . .
Basic Clock Module Introduction 4.1 Basic Clock Module Introduction The basic clock module supports low system cost and ultralow-power consumption. Using three internal clock signals, the user can select the best balance of performance and low power consumption. The basic clock module can be configured to operate without any external components, with one external resistor, with one or two external crystals, or with resonators, under full software control.
Basic Clock Module Introduction Figure 4−1. Basic Clock Block Diagram DIVAx LFXT1CLK Divider /1/2/4/8 OSCOFF XTS ACLK Auxillary Clock 0V XIN 12pF LF 12pF XOUT XT LFOff XT1Off 0V SELMx LFXT1 Oscillator DIVMx CPUOFF 00 XT2CLK 01 10 Divider /1/2/4/8 0 1 11 XT2OFF XT2IN MCLK Main System Clock XT XT2OUT XT2 Oscillator MODx VCC Modulator DCOR SCG0 RSELx DCOx SELS DIVSx SCG1 0 1 off DC Generator n DCO n+1 0 1 DCOCLK 0 1 Divider /1/2/4/8 0 1 P2.
Basic Clock Module Operation 4.2 Basic Clock Module Operation After a PUC, MCLK and SMCLK are sourced from DCOCLK at ~800 kHz (see device-specific datasheet for parameters) and ACLK is sourced from LFXT1 in LF mode. Status register control bits SCG0, SCG1, OSCOFF, and CPUOFF configure the MSP430 operating modes and enable or disable portions of the basic clock module. See Chapter System Resets, Interrupts and Operating Modes.
Basic Clock Module Operation 4.2.2 LFXT1 Oscillator The LFXT1 oscillator supports ultralow-current consumption using a 32,768-Hz watch crystal in LF mode (XTS = 0). A watch crystal connects to XIN and XOUT without any other external components. Internal 12-pF load capacitors are provided for LFXT1 in LF mode. The capacitors add serially, providing a match for standard 32,768-Hz crystals requiring a 6-pF load. Additional capacitors can be added if necessary.
Basic Clock Module Operation 4.2.3 XT2 Oscillator Some devices have a second crystal oscillator, XT2. XT2 sources XT2CLK and its characteristics are identical to LFXT1 in HF mode. The XT2OFF bit disables the XT2 oscillator if XT2CLK is not used for MCLK or SMCLK as shown in Figure 4−3. XT2 may be used with external clock signals on the XT2IN pin. When used with an external signal, the external frequency must meet the datasheet parameters for XT2. Figure 4−3.
Basic Clock Module Operation Adjusting the DCO frequency After a PUC, the internal resistor is selected for the DC generator, RSELx = 4, and DCOx = 3, allowing the DCO to start at a mid-range frequency. MCLK and SMCLK are sourced from DCOCLK. Because the CPU executes code from MCLK, which is sourced from the fast-starting DCO, code execution begins from PUC in less than 6 µs. The typical DCOx and RSELx ranges and steps are shown in Figure 4−5.
Basic Clock Module Operation Using an External Resistor (ROSC) for the DCO The DCO temperature coefficient can be reduced by using an external resistor ROSC tied to DVCC to source the current for the DC generator. Figure 4−6 shows the typical relationship of fDCO vs. temperature for both the internal and external resistor options. Using an external ROSC reduces the DCO temperature coefficient to approximately 0.1%/C. See the device-specific data sheet for parameters.
Basic Clock Module Operation 4.2.5 DCO Modulator The modulator mixes two DCO frequencies, fDCO and fDCO+1 to produce an intermediate effective frequency between fDCO and fDCO+1 and spread the clock energy, reducing electromagnetic interference (EMI). The modulator mixes fDCO and fDCO+1 for 32 DCOCLK clock cycles and is configured with the MODx bits. When MODx = 0 the modulator is off.
Basic Clock Module Operation 4.2.6 Basic Clock Module Fail-Safe Operation The basic clock module incorporates an oscillator-fault detection fail-safe feature. The oscillator fault detector is an analog circuit that monitors the LFXT1CLK (in HF mode) and the XT2CLK. An oscillator fault is detected when either clock signal is not present for approximately 50 µs.
Basic Clock Module Operation Oscillator Fault Detection Signal XT_OscFault triggers the OFIFG flag as shown in Figure 4−10. The LFXT1_OscFault signal is low when LFXT1 is in LF mode. On devices without XT2, the OFIFG flag cannot be cleared when LFXT1 is in LF mode. MCLK may be sourced by LFXT1CLK in LF mode by setting the SELMx bits, even though OFIFG remains set. On devices with XT2, the OFIFG flag can be cleared by software when LFXT1 is in LF mode and it remains cleared.
Basic Clock Module Operation Sourcing MCLK from a Crystal After a PUC, the basic clock module uses DCOCLK for MCLK. If required, MCLK may be sourced from LFXT1 or XT2. The sequence to switch the MCLK source from the DCO clock to the crystal clock (LFXT1CLK or XT2CLK) is: 1) Switch on the crystal oscillator 2) Clear the OFIFG flag 3) Wait at least 50 µs 4) Test OFIFG, and repeat steps 1-4 until OFIFG remains cleared. ; Select BIC BIS.B L1 BIC.B MOV L2 DEC JNZ BIT.B JNZ BIS.
Basic Clock Module Operation 4.2.7 Synchronization of Clock Signals When switching MCLK or SMCLK from one clock source to the another, the switch is synchronized to avoid critical race conditions as shown in Figure 4−11: 1) The current clock cycle continues until the next rising edge. 2) The clock remains high until the next rising edge of the new clock. 3) The new clock source is selected and continues with a full high period. Figure 4−11.
Basic Clock Module Registers 4.3 Basic Clock Module Registers The basic clock module registers are listed in Table 4−1: Table 4−1.
Basic Clock Module Registers DCOCTL, DCO Control Register 7 6 5 4 3 DCOx rw−0 rw−1 2 1 0 rw−0 rw−0 MODx rw−1 rw−0 rw−0 rw−0 DCOx Bits 7-5 DCO frequency select. These bits select which of the eight discrete DCO frequencies of the RSELx setting is selected. MODx Bits 4-0 Modulator selection. These bits define how often the fDCO+1 frequency is used within a period of 32 DCOCLK cycles. During the remaining clock cycles (32−MOD) the fDCO frequency is used. Not useable when DCOx=7.
Basic Clock Module Registers BCSCTL2, Basic Clock System Control Register 2 7 6 5 SELMx rw−(0) 4 DIVMx rw−(0) rw−(0) 3 2 SELS rw−(0) rw−0 1 DIVSx rw−0 0 DCOR rw−0 rw−0 SELMx Bits 7-6 Select MCLK. These bits select the MCLK source. 00 DCOCLK 01 DCOCLK 10 XT2CLK when XT2 oscillator present on-chip. LFXT1CLK when XT2 oscillator not present on-chip. 11 LFXT1CLK DIVMx BitS 5-4 Divider for MCLK 00 /1 01 /2 10 /4 11 /8 SELS Bit 3 Select SMCLK. This bit selects the SMCLK source.
Basic Clock Module Registers IE1, Interrupt Enable Register 1 7 6 5 4 3 2 1 0 OFIE rw−0 OFIE Bits 7-2 These bits may be used by other modules. See device-specific datasheet. Bit 1 Oscillator fault interrupt enable. This bit enables the OFIFG interrupt. Because other bits in IE1 may be used for other modules, it is recommended to set or clear this bit using BIS.B or BIC.B instructions, rather than MOV.B or CLR.B instructions.
4-18 Basic Clock Module
Chapter 5 " "" This chapter describes the operation of the MSP430 flash memory controller. Topic Page 5.1 Flash Memory Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 5.2 Flash Memory Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 5.3 Flash Memory Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 5.4 Flash Memory Registers . . . . . . . . . . . . . . . . . . . .
Flash Memory Introduction 5.1 Flash Memory Introduction The MSP430 flash memory is bit-, byte-, and word-addressable and programmable. The flash memory module has an integrated controller that controls programming and erase operations. The controller has three registers, a timing generator, and a voltage generator to supply program and erase voltages.
Flash Memory Segmentation 5.2 Flash Memory Segmentation MSP430 flash memory is partitioned into segments. Single bits, bytes, or words can be written to flash memory, but the segment is the smallest size of flash memory that can be erased. The flash memory is partitioned into main and information memory sections. There is no difference in the operation of the main and information memory sections. Code or data can be located in either section.
Flash Memory Operation 5.3 Flash Memory Operation The default mode of the flash memory is read mode. In read mode, the flash memory is not being erased or written, the flash timing generator and voltage generator are off, and the memory operates identically to ROM. MSP430 flash memory is in-system programmable (ISP) without the need for additional external voltage. The CPU can program its own flash memory.
Flash Memory Operation 5.3.2 Erasing Flash Memory The erased level of a flash memory bit is 1. Each bit can be programmed from 1 to 0 individually but to reprogram from 0 to 1 requires an erase cycle. The smallest amount of flash that can be erased is a segment. There are three erase modes selected with the ERASE and MERAS bits listed in Table 5−1. Table 5−1.
Flash Memory Operation Initiating an Erase from Within Flash Memory Any erase cycle can be initiated from within flash memory or from RAM. When a flash segment erase operation is initiated from within flash memory, all timing is controlled by the flash controller, and the CPU is held while the erase cycle completes. After the erase cycle completes, the CPU resumes code execution with the instruction following the dummy write.
Flash Memory Operation Initiating an Erase from RAM Any erase cycle may be initiated from RAM. In this case, the CPU is not held and can continue to execute code from RAM. The BUSY bit must be polled to determine the end of the erase cycle before the CPU can access any flash address again. If a flash access occurs while BUSY=1, it is an access violation, ACCVIFG will be set, and the erase results will be unpredictable. The flow to initiate an erase from flash from RAM is shown in Figure 5−6. Figure 5−6.
Flash Memory Operation 5.3.3 Writing Flash Memory The write modes, selected by the WRT and BLKWRT bits, are listed in Table 5−1. Table 5−2. Write Modes Write Mode BLKWRT WRT 0 1 Byte/word write 1 1 Block write Both write modes use a sequence of individual write instructions, but using the block write mode is approximately twice as fast as byte/word mode, because the voltage generator remains on for the complete block write.
Flash Memory Operation In byte/word mode, the internally-generated programming voltage is applied to the complete 64-byte block, each time a byte or word is written, for 32 of the 35 fFTG cycles. With each byte or word write, the amount of time the block is subjected to the programming voltage accumulates. The cumulative programming time, tCPT, must not be exceeded for any block.
Flash Memory Operation Initiating a Byte/Word Write from RAM The flow to initiate a byte/word write from RAM is shown in Figure 5−9. Figure 5−9. Initiating a Byte/Word Write from RAM Disable all interrupts and watchdog yes BUSY = 1 Setup flash controller and set WRT=1 Write byte or word yes BUSY = 1 Set WRT=0, LOCK = 1 re-enable interrupts and watchdog ; Byte/word write from RAM. 514 kHz < SMCLK < 952 kHz ; Assumes 0FF1Eh is already erased ; Assumes ACCVIE = NMIIE = OFIE = 0.
Flash Memory Operation Block Write The block write can be used to accelerate the flash write process when many sequential bytes or words need to be programmed. The flash programming voltage remains on for the duration of writing the 64-byte block. The cumulative programming time tCPT must not be exceeded for any block during a block write. A block write cannot be initiated from within flash memory. The block write must be initiated from RAM only.
Flash Memory Operation Block Write Flow and Example A block write flow is shown in Figure 5−8 and the following example. Figure 5−11.
Flash Memory Operation ; Write one block starting at 0F000h. ; Must be executed from RAM, Assumes Flash is already erased. ; 514 kHz < SMCLK < 952 kHz ; Assumes ACCVIE = NMIIE = OFIE = 0. MOV #32,R5 ; Use as write counter MOV #0F000h,R6 ; Write pointer MOV DINT L1 BIT JNZ MOV MOV MOV L2 MOV L3 BIT JZ INCD DEC JNZ MOV L4 BIT JNZ MOV ...
Flash Memory Operation 5.3.4 Flash Memory Access During Write or Erase When any write or any erase operation is initiated from RAM and while BUSY=1, the CPU may not read or write to or from any flash location. Otherwise, an access violation occurs, ACCVIFG is set, and the result is unpredictable. Also if a write to flash is attempted with WRT=0, the ACCVIFG interrupt flag is set, and the flash memory is unaffected.
Flash Memory Operation 5.3.5 Stopping a Write or Erase Cycle Any write or erase operation can be stopped before its normal completion by setting the emergency exit bit EMEX. Setting the EMEX bit stops the active operation immediately and stops the flash controller. All flash operations cease, the flash returns to read mode, and all bits in the FCTL1 register are reset. The result of the intended operation is unpredictable. 5.3.
Flash Memory Operation Programming Flash Memory via JTAG MSP430 devices can be programmed via the JTAG port. The JTAG interface requires four signals (5 signals on 20- and 28-pin devices), ground and optionally VCC and RST/NMI. The JTAG port is protected with a fuse. Blowing the fuse completely disables the JTAG port and is not reversible. Further access to the device via JTAG is not possible For more details see the Application report Programming a Flash-Based MSP430 Using the JTAG Interface at www.ti.
Flash Memory Registers 5.4 Flash Memory Registers The flash memory registers are listed in Table 5−4. Table 5−4.
Flash Memory Registers FCTL1, Flash Memory Control Register 15 14 13 12 11 10 9 8 FRKEY, Read as 096h FWKEY, Must be written as 0A5h 7 6 5 4 3 2 1 0 BLKWRT WRT Reserved Reserved Reserved MERAS ERASE Reserved rw−0 rw−0 r0 r0 r0 rw−0 rw−0 r0 FRKEY/ FWKEY Bits 15-8 FCTLx password. Always read as 096h. Must be written as 0A5h or a PUC will be generated. BLKWRT Bit 7 Block write mode. WRT must also be set for block write mode. BLKWRT is automatically reset when EMEX is set.
Flash Memory Registers FCTL2, Flash Memory Control Register 15 14 13 12 11 10 9 8 2 1 0 rw−0 rw-1 rw−0 FWKEYx, Read as 096h Must be written as 0A5h 7 6 5 4 3 FSSELx rw−0 FNx rw−1 rw-0 rw-0 rw-0 FWKEYx Bits 15-8 FCTLx password. Always read as 096h. Must be written as 0A5h or a PUC will be generated. FSSELx Bits 7−6 Flash controller clock source select 00 ACLK 01 MCLK 10 SMCLK 11 SMCLK FNx Bits 5-0 Flash controller clock divider.
Flash Memory Registers FCTL3, Flash Memory Control Register FCTL3 15 14 13 12 11 10 9 8 FWKEYx, Read as 096h Must be written as 0A5h 7 6 5 4 3 2 1 0 Reserved Reserved EMEX LOCK WAIT ACCVIFG KEYV BUSY r0 r0 rw-0 rw-1 r-1 rw−0 rw-(0) r(w)−0 FWKEYx Bits 15-8 FCTLx password. Always read as 096h. Must be written as 0A5h or a PUC will be generated. Reserved Bits 7-6 Reserved. Always read as 0.
Flash Memory Registers IE1, Interrupt Enable Register 1 7 6 5 4 3 2 1 0 ACCVIE rw−0 ACCVIE Bits 7-6, 4-0 These bits may be used by other modules. See device-specific datasheet. Bit 5 Flash memory access violation interrupt enable. This bit enables the ACCVIFG interrupt. Because other bits in IE1 may be used for other modules, it is recommended to set or clear this bit using BIS.B or BIC.B instructions, rather than MOV.B or CLR.B instructions.
5-22 Flash Memory Controller
Chapter 6 " $ " % This chapter describes the operation of the SVS. The SVS is implemented in MSP430x15x and MSP430x16x devices. Topic Page 6.1 SVS Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6−2 6.2 SVS Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6−4 6.3 SVS Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SVS Introduction 6.1 SVS Introduction The supply voltage supervisor (SVS) is used to monitor the AVCC supply voltage or an external voltage. The SVS can be configured to set a flag or generate a POR reset when the supply voltage or external voltage drops below a user-selected threshold.
SVS Introduction Figure 6−1. SVS Block Diagram VCC AVCC Brownout Reset D AVCC G S SVSIN ~ 50us 1111 1101 − SVS_POR + 1100 tReset ~ 50us 0011 0010 SVSOUT 1.
SVS Operation 6.2 SVS Operation The SVS detects if the AVCC voltage drops below a selectable level. It can be configured to provide a POR or set a flag, when a low-voltage condition occurs. The SVS is disabled after a brownout reset to conserve current consumption. 6.2.1 Configuring the SVS The VLDx bits are used to enable/disable the SVS and select one of 14 threshold levels (V(SVS_IT−)) for comparison with AVCC. The SVS is off when VLDx = 0 and on when VLDx > 0. The SVSON bit does not turn on the SVS.
SVS Operation 6.2.3 Changing the VLDx Bits When the VLDx bits are changed, two settling delays are implemented to allows the SVS circuitry to settle. During each delay, the SVS will not set SVSFG. The delays, td(SVSon) and tsettle, are shown in Figure 6−2. The td(SVSon) delay takes affect when VLDx is changed from zero to any non-zero value and is a approximately 50 µs. The tsettle delay takes affect when the VLDx bits change from any non-zero value to any other non-zero value and is a maximum of ~12 µs.
SVS Operation 6.2.4 SVS Operating Range Each SVS level has hysteresis to reduce sensitivity to small supply voltage changes when AVCC is close to the threshold. The SVS operation and SVS/Brownout interoperation are shown in Figure 6−3. Figure 6−3.
SVS Registers 6.3 SVS Registers The SVS registers are listed in Table 6−1. Table 6−1. SVS Registers Register Short Form Register Type Address Initial State SVS Control Register SVSCTL Read/write Reset with BOR 055h SVSCTL, SVS Control Register 7 6 5 4 VLDx rw−0† rw−0† rw−0† rw−0† † Reset by a brownout reset only, not by a POR or PUC. 3 2 1 0 PORON SVSON SVSOP SVSFG rw−0† r r rw−0† VLDx Bits 7-4 Voltage level detect.
6-8 Supply Voltage Supervisor
Chapter 7 & ' " " This chapter describes the hardware multiplier. The hardware multiplier is implemented in MSP430x14x and MSP430x16x devices. Topic Page 7.1 Hardware Multiplier Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2 7.2 Hardware Multiplier Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3 7.3 Hardware Multiplier Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Hardware Multiplier Introduction 7.1 Hardware Multiplier Introduction The hardware multiplier is a peripheral and is not part of the MSP430 CPU. This means, its activities do not interfere with the CPU activities. The multiplier registers are peripheral registers that are loaded and read with CPU instructions.
Hardware Multiplier Operation 7.2 Hardware Multiplier Operation The hardware multiplier supports unsigned multiply, signed multiply, unsigned multiply accumulate, and signed multiply accumulate operations. The type of operation is selected by the address the first operand is written to. The hardware multiplier has two 16-bit operand registers, OP1 and OP2, and three result registers, RESLO, RESHI, and SUMEXT.
Hardware Multiplier Operation 7.2.2 Result Registers The result low register RESLO holds the lower 16-bits of the calculation result. The result high register RESHI contents depend on the multiply operation and are listed in Table 7−2. Table 7−2. RESHI Contents Mode RESHI Contents MPY Upper 16-bits of the result MPYS The MSB is the sign of the result. The remaining bits are the upper 15-bits of the result. Two’s complement notation is used for the result.
Hardware Multiplier Operation 7.2.3 Software Examples Examples for all multiplier modes follow. All 8x8 modes use the absolute address for the registers because the assembler will not allow .B access to word registers when using the labels from the standard definitions file. ; 16x16 Unsigned Multiply MOV #01234h,&MPY ; Load first operand MOV #05678h,&OP2 ; Load second operand ; ... ; Process results ; 8x8 Unsigned Multiply. Absolute addressing. MOV.B #012h,&0130h ; Load first operand MOV.
Hardware Multiplier Operation 7.2.4 Indirect Addressing of RESLO When using indirect or indirect autoincrement addressing mode to access the result registers, At least one instruction is needed between loading the second operand and accessing one of the result registers: ; Access MOV MOV MOV NOP MOV MOV 7.2.
Hardware Multiplier Registers 7.3 Hardware Multiplier Registers The hardware multiplier registers are listed in Table 7−4. Table 7−4.
7-8 Hardware Multiplier
Chapter 8 ( ) "" The DMA controller module transfers data from one address to another without CPU intervention. This chapter describes the operation of the DMA controller. The DMA controller is implemented in MSP430x15x and MSP430x16x devices. Topic Page 8.1 DMA Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2 8.2 DMA Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4 8.
8.1 DMA Introduction The direct memory access (DMA) controller transfers data from one address to another, without CPU intervention, across the entire address range. For example, the DMA controller can move data from the ADC12 conversion memory to RAM. Using the DMA controller can increase the throughput of peripheral modules. It can also reduce system power consumption by allowing the CPU to remain in a low-power mode without having to awaken to move data to or from a peripheral.
Figure 8−1.
8.2 DMA Operation The DMA controller is configured with user software. The setup and operation of the DMA is discussed in the following sections. 8.2.1 DMA Addressing Modes The DMA controller has four addressing modes. The addressing mode for each DMA channel is independently configurable. For example, channel 0 may transfer between two fixed addresses, while channel 1 transfers between two blocks of addresses. The addressing modes are shown in Figure 8−2.
8.2.2 DMA Transfer Modes The DMA controller has six transfer modes selected by the DMADTx bits as listed in Table 8−1. Each channel is individually configurable for its transfer mode. For example, channel 0 may be configured in single transfer mode, while channel 1 is configured for burst-block transfer mode, and channel 2 operates in repeated block mode. The transfer mode is configured independently from the addressing mode. Any addressing mode can be used with any transfer mode. Table 8−1.
Single Transfer In single transfer mode, each byte/word transfer requires a separate trigger. The single transfer state diagram is shown in Figure 8−3. The DMAxSZ register is used to define the number of transfers to be made. The DMADSTINCRx and DMASRCINCRx bits select if the destination address and the source address are incremented or decremented after each transfer. If DMAxSZ = 0, no transfers occur. The DMAxSA, DMAxDA, and DMAxSZ registers are copied into temporary registers.
Figure 8−3.
Block Transfers In block transfer mode, a transfer of a complete block of data occurs after one trigger. When DMADTx = 1, the DMAEN bit is cleared after the completion of the block transfer and must be set again before another block transfer can be triggered. After a block transfer has been triggered, further trigger signals occurring during the block transfer are ignored. The block transfer state diagram is shown in Figure 8−4.
Figure 8−4.
Burst-Block Transfers In burst-block mode, transfers are block transfers with CPU activity interleaved. The CPU executes 2 MCLK cycles after every four byte/word transfers of the block resulting in 20% CPU execution capacity. After the burst-block, CPU execution resumes at 100% capacity and the DMAEN bit is cleared. DMAEN must be set again before another burst-block transfer can be triggered.
Figure 8−5.
8.2.3 Initiating DMA Transfers Each DMA channel is independently configured for its trigger source with the DMAxTSELx bits as described in Table 8−2.The DMAxTSELx bits should be modified only when the DMACTLx DMAEN bit is 0. Otherwise, unpredictable DMA triggers may occur. When selecting the trigger, the trigger must not have already occurred, or the transfer will not take place.
Table 8−2. DMA Trigger Operation DMAxTSELx Operation 0000 A transfer is triggered when the DMAREQ bit is set. The DMAREQ bit is automatically reset when the transfer starts 0001 A transfer is triggered when the TACCR2 CCIFG flag is set. The TACCR2 CCIFG flag is automatically reset when the transfer starts. If the TACCR2 CCIE bit is set, the TACCR2 CCIFG flag will not trigger a transfer. 0010 A transfer is triggered when the TBCCR2 CCIFG flag is set.
8.2.4 Stopping DMA Transfers There are two ways to stop DMA transfers in progress: - A single, block, or burst-block transfer may be stopped with an NMI interrupt, if the ENNMI bit is set in register DMACTL1. - A burst-block transfer may be stopped by clearing the DMAEN bit. 8.2.5 DMA Channel Priorities The default DMA channel priorities are DMA0−DMA1−DMA2.
8.2.6 DMA Transfer Cycle Time The DMA controller requires one or two MCLK clock cycles to synchronize before each single transfer or complete block or burst-block transfer. Each byte/word transfer requires two MCLK cycles after synchronization, and one cycle of wait time after the transfer. Because the DMA controller uses MCLK, the DMA cycle time is dependent on the MSP430 operating mode and clock system setup.
8.2.7 Using DMA with System Interrupts DMA transfers are not interruptible by system interrupts. System interrupts remain pending until the completion of the transfer. NMI interrupts can interrupt the DMA controller if the ENNMI bit is set. System interrupt service routines are interrupted by DMA transfers. If an interrupt service routine or other routine must execute with no interruptions, the DMA controller should be disabled prior to executing the routine. 8.2.
8.2.9 Using the I2C Module with the DMA Controller The I2C module provides two trigger sources for the DMA controller. The I2C module can trigger a transfer when new I2C data is received and the when the transmit data is needed. The TXDMAEN and RXDMAEN bits enable or disable the use of the DMA controller with the I2C module. When RXDMAEN = 1, the DMA controller can be used to transfer data from the I2C module after the I2C modules receives data.
8.3 DMA Registers The DMA registers are listed in Table 8−4: Table 8−4.
DMACTL0, DMA Control Register 0 15 14 13 12 11 10 Reserved 9 8 DMA2TSELx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 7 6 5 4 3 2 1 0 rw−(0) rw−(0) DMA1TSELx rw−(0) rw−(0) rw−(0) DMA0TSELx rw−(0) rw−(0) rw−(0) Reserved Bits 15−12 Reserved DMA2 TSELx Bits 11−8 DMA trigger select. These bits select the DMA transfer trigger.
DMACTL1, DMA Control Register 1 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 7 6 5 4 3 2 1 0 0 0 0 0 0 DMA ONFETCH ROUND ROBIN ENNMI r0 r0 r0 r0 r0 rw−(0) rw−(0) rw−(0) Reserved Bits 15−3 Reserved. Read only. Always read as 0. DMA ONFETCH Bit 2 DMA on fetch 0 The DMA transfer occurs immediately 1 The DMA transfer occurs on next instruction fetch after the trigger ROUND ROBIN Bit 1 Round robin.
DMAxCTL, DMA Channel x Control Register 15 14 13 Reserved 12 DMADTx 11 10 DMADSTINCRx 9 8 DMASRCINCRx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 7 6 5 4 3 2 1 0 DMA DSTBYTE DMA SRCBYTE DMALEVEL DMAEN DMAIFG DMAIE DMA ABORT DMAREQ rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) Reserved Bit 15 Reserved DMADTx Bits 14−12 DMA Transfer mode.
DMA SRCBYTE Bit 6 DMA source byte. This bit selects the source as a byte or word. 0 Word 1 Byte DMA LEVEL Bit 5 DMA level. This bit selects between edge-sensitive and level-sensitive triggers. 0 Edge sensitive (rising edge) 1 Level sensitive (high level) DMAEN Bit 4 DMA enable 0 Disabled 1 Enabled DMAIFG Bit 3 DMA interrupt flag 0 No interrupt pending 1 Interrupt pending DMAIE Bit 2 DMA interrupt enable 0 Disabled 1 Enabled DMA ABORT Bit 1 DMA Abort.
DMAxDA, DMA Destination Address Register 15 14 13 12 11 10 9 8 DMAxDAx rw rw rw rw rw rw rw rw 7 6 5 4 3 2 1 0 rw rw rw rw DMAxDAx rw DMAxDAx rw Bits 15−0 rw rw DMA destination address. The destination address register points to the destination address for single transfers or the first address for block transfers. The DMAxDA register remains unchanged during block and burst-block transfers.
8-24
Chapter 9 ( " * This chapter describes the operation of the digital I/O ports. Ports P1-P2 are implemented in MSP430x11xx devices. Ports P1-P3 are implemented in MSP430x12xx devices. Ports P1-P6 are implemented in MSP430x13x, MSP430x14x, MSP430x15x, and MSP430x16x devices. Topic Page 9.1 Digital I/O Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2 9.2 Digital I/O Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Digital I/O Introduction 9.1 Digital I/O Introduction MSP430 devices have up to 6 digital I/O ports implemented, P1 - P6. Each port has eight I/O pins. Every I/O pin is individually configurable for input or output direction, and each I/O line can be individually read or written to. Ports P1 and P2 have interrupt capability. Each interrupt for the P1 and P2 I/O lines can be individually enabled and configured to provide an interrupt on a rising edge or falling edge of an input signal.
Digital I/O Operation 9.2 Digital I/O Operation The digital I/O is configured with user software. The setup and operation of the digital I/O is discussed in the following sections. 9.2.1 Input Register PxIN Each bit in each PxIN register reflects the value of the input signal at the corresponding I/O pin when the pin is configured as I/O function.
Digital I/O Operation 9.2.4 Function Select Registers PxSEL Port pins are often multiplexed with other peripheral module functions. See the device-specific data sheet to determine pin functions. Each PxSEL bit is used to select the pin function − I/O port or peripheral module function. Bit = 0: I/O Function is selected for the pin Bit = 1: Peripheral module function is selected for the pin Setting PxSELx = 1 does not automatically set the pin direction.
Digital I/O Operation 9.2.5 P1 and P2 Interrupts Each pin in ports P1 and P2 have interrupt capability, configured with the PxIFG, PxIE, and PxIES registers. All P1 pins source a single interrupt vector, and all P2 pins source a different single interrupt vector. The PxIFG register can be tested to determine the source of a P1 or P2 interrupt.
Digital I/O Operation Interrupt Edge Select Registers P1IES, P2IES Each PxIES bit selects the interrupt edge for the corresponding I/O pin. Bit = 0: The PxIFGx flag is set with a low-to-high transition Bit = 1: The PxIFGx flag is set with a high-to-low transition Note: Writing to PxIESx Writing to P1IES, or P2IES can result in setting the corresponding interrupt flags.
Digital I/O Registers 9.3 Digital I/O Registers Seven registers are used to configure P1 and P2. Four registers are used to configure ports P3 - P6. The digital I/O registers are listed in Table 9−1. Table 9−1.
9-8 Digital I/O
Chapter 10 + The watchdog timer is a 16-bit timer that can be used as a watchdog or as an interval timer. This chapter describes the watchdog timer. The watchdog timer is implemented in all MSP430x1xx devices. Topic Page 10.1 Watchdog Timer Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2 10.2 Watchdog Timer Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-4 10.2 Watchdog Timer Registers . . . . . . . . . . . . . . . . . .
Watchdog Timer Introduction 10.1 Watchdog Timer Introduction The primary function of the watchdog timer (WDT) module is to perform a controlled system restart after a software problem occurs. If the selected time interval expires, a system reset is generated. If the watchdog function is not needed in an application, the module can be configured as an interval timer and can generate interrupts at selected time intervals.
Watchdog Timer Introduction Figure 10−1. Watchdog Timer Block Diagram WDTCTL 4 Int.
Watchdog Timer Operation 10.2 Watchdog Timer Operation The WDT module can be configured as either a watchdog or interval timer with the WDTCTL register. The WDTCTL register also contains control bits to configure the RST/NMI pin. WDTCTL is a 16-bit, password-protected, read/write register. Any read or write access must use word instructions and write accesses must include the write password 05Ah in the upper byte.
Watchdog Timer Operation 10.2.4 Watchdog Timer Interrupts The WDT uses two bits in the SFRs for interrupt control. - The WDT interrupt flag, WDTIFG, located in IFG1.0 - The WDT interrupt enable, WDTIE, located in IE1.0 When using the WDT in the watchdog mode, the WDTIFG flag sources a reset vector interrupt. The WDTIFG can be used by the reset interrupt service routine to determine if the watchdog caused the device to reset.
Watchdog Timer Operation 10.2.5 Operation in Low-Power Modes The MSP430 devices have several low-power modes. Different clock signals are available in different low-power modes. The requirements of the user’s application and the type of clocking used determine how the WDT should be configured. For example, the WDT should not be configured in watchdog mode with SMCLK as its clock source if the user wants to use low-power mode 3 because SMCLK is not active in LPM3 and the WDT would not function.
Watchdog Timer Registers 10.3 Watchdog Timer Registers The watchdog timer module registers are listed in Table 10−1. Table 10−1.
Watchdog Timer Registers WDTCTL, Watchdog Timer Register 15 14 13 12 11 10 9 8 1 0 Read as 069h WDTPW, must be written as 05Ah 7 6 5 4 3 2 WDTHOLD WDTNMIES WDTNMI WDTTMSEL WDTCNTCL WDTSSEL rw−0 rw−0 rw−0 rw−0 r0(w) rw−0 WDTISx rw−0 rw−0 WDTPW Bits 15-8 Watchdog timer password. Always read as 069h. Must be written as 05Ah, or a PUC will be generated. WDTHOLD Bit 7 Watchdog timer hold. This bit stops the watchdog timer.
Watchdog Timer Registers IE1, Interrupt Enable Register 1 7 NMIIE WDTIE 6 5 4 3 2 1 0 NMIIE WDTIE rw−0 rw−0 Bits 7-5 These bits may be used by other modules. See device-specific datasheet. Bit 4 NMI interrupt enable. This bit enables the NMI interrupt. Because other bits in IE1 may be used for other modules, it is recommended to set or clear this bit using BIS.B or BIC.B instructions, rather than MOV.B or CLR.B instructions.
Watchdog Timer Registers IFG1, Interrupt Flag Register 1 7 NMIIFG WDTIFG 10-10 6 5 4 3 2 1 0 NMIIFG WDTIFG rw−(0) rw−(0) Bits 7-5 These bits may be used by other modules. See device-specific datasheet. Bit 4 NMI interrupt flag. NMIIFG must be reset by software. Because other bits in IFG1 may be used for other modules, it is recommended to clear NMIIFG by using BIS.B or BIC.B instructions, rather than MOV.B or CLR.B instructions.
Chapter 11 ,) Timer_A is a 16-bit timer/counter with three capture/compare registers. This chapter describes Timer_A. Timer_A is implemented in all MSP430x1xx devices. Topic Page 11.1 Timer_A Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2 11.2 Timer_A Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4 11.3 Timer_A Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Timer_A Introduction 11.1 Timer_A Introduction Timer_A is a 16-bit timer/counter with three capture/compare registers. Timer_A can support multiple capture/compares, PWM outputs, and interval timing. Timer_A also has extensive interrupt capabilities. Interrupts may be generated from the counter on overflow conditions and from each of the capture/compare registers.
Timer_A Introduction Figure 11−1.
Timer_A Operation 11.2 Timer_A Operation The Timer_A module is configured with user software. The setup and operation of Timer_A is discussed in the following sections. 11.2.1 16-Bit Timer Counter The 16-bit timer/counter register, TAR, increments or decrements (depending on mode of operation) with each rising edge of the clock signal. TAR can be read or written with software. Additionally, the timer can generate an interrupt when it overflows. TAR may be cleared by setting the TACLR bit.
Timer_A Operation 11.2.2 Starting the Timer The timer may be started, or restarted in the following ways: - The timer counts when MCx > 0 and the clock source is active. - When the timer mode is either up or up/down, the timer may be stopped by writing 0 to TACCR0. The timer may then be restarted by writing a nonzero value to TACCR0. In this scenario, the timer starts incrementing in the up direction from zero. 11.2.
Timer_A Operation Up Mode The up mode is used if the timer period must be different from 0FFFFh counts. The timer repeatedly counts up to the value of compare register TACCR0, which defines the period, as shown in Figure 11−2. The number of timer counts in the period is TACCR0+1. When the timer value equals TACCR0 the timer restarts counting from zero. If up mode is selected when the timer value is greater than TACCR0, the timer immediately restarts counting from zero. Figure 11−2.
Timer_A Operation Continuous Mode In the continuous mode, the timer repeatedly counts up to 0FFFFh and restarts from zero as shown in Figure 11−4. The capture/compare register TACCR0 works the same way as the other capture/compare registers. Figure 11−4. Continuous Mode 0FFFFh 0h The TAIFG interrupt flag is set when the timer counts from 0FFFFh to zero. Figure 11−5 shows the flag set cycle. Figure 11−5.
Timer_A Operation Use of the Continuous Mode The continuous mode can be used to generate independent time intervals and output frequencies. Each time an interval is completed, an interrupt is generated. The next time interval is added to the TACCRx register in the interrupt service routine. Figure 11−6 shows two separate time intervals t0 and t1 being added to the capture/compare registers. In this usage, the time interval is controlled by hardware, not software, without impact from interrupt latency.
Timer_A Operation 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 TACCR0 and back down to zero, as shown in Figure 11−7. The period is twice the value in TACCR0. Figure 11−7. Up/Down Mode 0FFFFh TACCR0 0h The count direction is latched.
Timer_A Operation Changing the Period Register TACCR0 When changing TACCR0 while the timer is running, and counting in the down direction, the timer continues its descent until it reaches zero. The new period takes affect after the counter counts down to zero. When the timer is counting in the up direction, and the new period is greater than or equal to the old period, or greater than the current count value, the timer counts up to the new period before counting down.
Timer_A Operation 11.2.4 Capture/Compare Blocks Three identical capture/compare blocks, TACCRx, are present in Timer_A. Any of the blocks may be used to capture the timer data, or to generate time intervals. Capture Mode The capture mode is selected when CAP = 1. Capture mode is used to record time events. It can be used for speed computations or time measurements. The capture inputs CCIxA and CCIxB are connected to external pins or internal signals and are selected with the CCISx bits.
Timer_A Operation Figure 11−11. Capture Cycle Idle Capture No Capture Taken Capture Read Read Taken Capture Capture Taken Capture Capture Read and No Capture Capture Clear Bit COV in Register TACCTLx Second Capture Taken COV = 1 Idle Capture Initiated by Software Captures can be initiated by software. The CMx bits can be set for capture on both edges.
Timer_A Operation 11.2.5 Output Unit Each capture/compare block contains an output unit. The output unit is used to generate output signals such as PWM signals. Each output unit has eight operating modes that generate signals based on the EQU0 and EQUx signals. Output Modes The output modes are defined by the OUTMODx bits and are described in Table 11−2. The OUTx signal is changed with the rising edge of the timer clock for all modes except mode 0.
Timer_A Operation Output Example—Timer in Up Mode The OUTx signal is changed when the timer counts up to the TACCRx value, and rolls from TACCR0 to zero, depending on the output mode. An example is shown in Figure 11−12 using TACCR0 and TACCR1. Figure 11−12.
Timer_A Operation Output Example—Timer in Continuous Mode The OUTx signal is changed when the timer reaches the TACCRx and TACCR0 values, depending on the output mode. An example is shown in Figure 11−13 using TACCR0 and TACCR1. Figure 11−13.
Timer_A Operation Output Example—Timer in Up/Down Mode The OUTx signal changes when the timer equals TACCRx in either count direction and when the timer equals TACCR0, depending on the output mode. An example is shown in Figure 11−14 using TACCR0 and TACCR2. Figure 11−14.
Timer_A Operation 11.2.6 Timer_A Interrupts Two interrupt vectors are associated with the 16-bit Timer_A module: - TACCR0 interrupt vector for TACCR0 CCIFG - TAIV interrupt vector for all other CCIFG flags and TAIFG In capture mode any CCIFG flag is set when a timer value is captured in the associated TACCRx register. In compare mode, any CCIFG flag is set if TAR counts to the associated TACCRx value. Software may also set or clear any CCIFG flag.
Timer_A Operation TAIV Software Example The following software example shows the recommended use of TAIV and the handling overhead. The TAIV value is added to the PC to automatically jump to the appropriate routine. The numbers at the right margin show the necessary CPU cycles for each instruction. The software overhead for different interrupt sources includes interrupt latency and return-from-interrupt cycles, but not the task handling itself.
Timer_A Registers 11.3 Timer_A Registers The Timer_A registers are listed in Table 11−3: Table 11−3.
Timer_A Registers TACTL, Timer_A Control Register 15 14 13 12 11 10 9 Unused 8 TASSELx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 7 6 5 4 3 2 1 0 Unused TACLR TAIE TAIFG rw−(0) w−(0) rw−(0) rw−(0) IDx rw−(0) MCx rw−(0) rw−(0) rw−(0) Unused Bits 15-10 Unused TASSELx Bits 9-8 Timer_A clock source select 00 TACLK 01 ACLK 10 SMCLK 11 INCLK IDx Bits 7-6 Input divider. These bits select the divider for the input clock.
Timer_A Registers TAR, Timer_A Register 15 14 13 12 11 10 9 8 TARx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 7 6 5 4 3 2 1 0 rw−(0) rw−(0) rw−(0) rw−(0) TARx rw−(0) TARx rw−(0) Bits 15-0 rw−(0) rw−(0) Timer_A register. The TAR register is the count of Timer_A.
Timer_A Registers TACCTLx, Capture/Compare Control Register 15 14 13 CMx 12 CCISx 11 10 9 8 SCS SCCI Unused CAP rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) r−(0) r−(0) rw−(0) 7 6 5 4 3 2 1 0 CCIE CCI OUT COV CCIFG rw−(0) r rw−(0) rw−(0) rw−(0) OUTMODx rw−(0) rw−(0) rw−(0) CMx Bit 15-14 Capture mode 00 No capture 01 Capture on rising edge 10 Capture on falling edge 11 Capture on both rising and falling edges CCISx Bit 13-12 Capture/compare input select.
Timer_A Registers CCIE Bit 4 Capture/compare interrupt enable. This bit enables the interrupt request of the corresponding CCIFG flag. 0 Interrupt disabled 1 Interrupt enabled CCI Bit 3 Capture/compare input. The selected input signal can be read by this bit. OUT Bit 2 Output. For output mode 0, this bit directly controls the state of the output. 0 Output low 1 Output high COV Bit 1 Capture overflow. This bit indicates a capture overflow occurred. COV must be reset with software.
11-24 Timer_A
Chapter 12 , Timer_B is a 16-bit timer/counter with multiple capture/compare registers. This chapter describes Timer_B. Timer_B3 (three capture/compare registers) is implemented in MSP430x13x and MSP430x15x devices. Timer_B7 (seven capture/compare registers) is implemented in MSP430x14x and MSP430x16x devices. Topic Page 12.1 Timer_B Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2 12.2 Timer_B Operation . . . . . . . . . . . . . . . . . . . . . .
Timer_B Introduction 12.1 Timer_B Introduction Timer_B is a 16-bit timer/counter with three or seven capture/compare registers. Timer_B can support multiple capture/compares, PWM outputs, and interval timing. Timer_B also has extensive interrupt capabilities. Interrupts may be generated from the counter on overflow conditions and from each of the capture/compare registers.
Timer_B Introduction Figure 12−1.
Timer_B Operation 12.2 Timer_B Operation The Timer_B module is configured with user software. The setup and operation of Timer_B is discussed in the following sections. 12.2.1 16-Bit Timer Counter The 16-bit timer/counter register, TBR, increments or decrements (depending on mode of operation) with each rising edge of the clock signal. TBR can be read or written with software. Additionally, the timer can generate an interrupt when it overflows. TBR may be cleared by setting the TBCLR bit.
Timer_B Operation 12.2.2 Starting the Timer The timer may be started or restarted in the following ways: - The timer counts when MCx > 0 and the clock source is active. - When the timer mode is either up or up/down, the timer may be stopped by loading 0 to TBCL0. The timer may then be restarted by loading a nonzero value to TBCL0. In this scenario, the timer starts incrementing in the up direction from zero. 12.2.
Timer_B Operation Up Mode The up mode is used if the timer period must be different from TBR(max) counts. The timer repeatedly counts up to the value of compare latch TBCL0, which defines the period, as shown in Figure 12−2. The number of timer counts in the period is TBCL0+1. When the timer value equals TBCL0 the timer restarts counting from zero. If up mode is selected when the timer value is greater than TBCL0, the timer immediately restarts counting from zero. Figure 12−2.
Timer_B Operation Continuous Mode In continuous mode the timer repeatedly counts up to TBR(max) and restarts from zero as shown in Figure 12−4. The compare latch TBCL0 works the same way as the other capture/compare registers. Figure 12−4. Continuous Mode TBR(max) 0h The TBIFG interrupt flag is set when the timer counts from TBR(max) to zero. Figure 12−5 shows the flag set cycle. Figure 12−5.
Timer_B Operation Use of the Continuous Mode The continuous mode can be used to generate independent time intervals and output frequencies. Each time an interval is completed, an interrupt is generated. The next time interval is added to the TBCLx latch in the interrupt service routine. Figure 12−6 shows two separate time intervals t0 and t1 being added to the capture/compare registers. The time interval is controlled by hardware, not software, without impact from interrupt latency.
Timer_B Operation Up/Down Mode The up/down mode is used if the timer period must be different from TBR(max) counts, and if symmetrical pulse generation is needed. The timer repeatedly counts up to the value of compare latch TBCL0, and back down to zero, as shown in Figure 12−7. The period is twice the value in TBCL0. Note: TBCL0 > TBR(max) If TBCL0 > TBR(max), the counter operates as if it were configured for continuous mode. It does not count down from TBR(max) to zero. Figure 12−7.
Timer_B Operation Changing the Value of Period Register TBCL0 When changing TBCL0 while the timer is running, and counting in the down direction, and when the TBCL0 load mode is immediate, the timer continues its descent until it reaches zero. The new period takes effect after the counter counts down to zero.
Timer_B Operation 12.2.4 Capture/Compare Blocks Three or seven identical capture/compare blocks, TBCCRx, are present in Timer_B. Any of the blocks may be used to capture the timer data or to generate time intervals. Capture Mode The capture mode is selected when CAP = 1. Capture mode is used to record time events. It can be used for speed computations or time measurements. The capture inputs CCIxA and CCIxB are connected to external pins or internal signals and are selected with the CCISx bits.
Timer_B Operation Figure 12−11.Capture Cycle Idle Capture No Capture Taken Capture Read Read Taken Capture Capture Taken Capture Capture Read and No Capture Capture Clear Bit COV in Register TBCCTLx Second Capture Taken COV = 1 Idle Capture Initiated by Software Captures can be initiated by software. The CMx bits can be set for capture on both edges.
Timer_B Operation Compare Latch TBCLx The TBCCRx compare latch, TBCLx, holds the data for the comparison to the timer value in compare mode. TBCLx is buffered by TBCCRx. The buffered compare latch gives the user control over when a compare period updates. The user cannot directly access TBCLx. Compare data is written to each TBCCRx and automatically transferred to TBCLx. The timing of the transfer from TBCCRx to TBCLx is user-selectable with the CLLDx bits as described in Table 12−2. Table 12−2.
Timer_B Operation 12.2.5 Output Unit Each capture/compare block contains an output unit. The output unit is used to generate output signals such as PWM signals. Each output unit has eight operating modes that generate signals based on the EQU0 and EQUx signals. The TBOUTH pin function can be used to put all Timer_B outputs into a high-impedance state. When the TBOUTH pin function is selected for the pin, and when the pin is pulled high, all Timer_B outputs are in a high-impedance state.
Timer_B Operation Output Example—Timer in Up Mode The OUTx signal is changed when the timer counts up to the TBCLx value, and rolls from TBCL0 to zero, depending on the output mode. An example is shown in Figure 12−12 using TBCL0 and TBCL1. Figure 12−12.
Timer_B Operation Output Example—Timer in Continuous Mode The OUTx signal is changed when the timer reaches the TBCLx and TBCL0 values, depending on the output mode, An example is shown in Figure 12−13 using TBCL0 and TBCL1. Figure 12−13.
Timer_B Operation Output Example − Timer in Up/Down Mode The OUTx signal changes when the timer equals TBCLx in either count direction and when the timer equals TBCL0, depending on the output mode. An example is shown in Figure 12−14 using TBCL0 and TBCL3. Figure 12−14.
Timer_B Operation 12.2.6 Timer_B Interrupts Two interrupt vectors are associated with the 16-bit Timer_B module: - TBCCR0 interrupt vector for TBCCR0 CCIFG - TBIV interrupt vector for all other CCIFG flags and TBIFG In capture mode, any CCIFG flag is set when a timer value is captured in the associated TBCCRx register. In compare mode, any CCIFG flag is set when TBR counts to the associated TBCLx value. Software may also set or clear any CCIFG flag.
Timer_B Operation TBIV, Interrupt Handler Examples The following software example shows the recommended use of TBIV and the handling overhead. The TBIV value is added to the PC to automatically jump to the appropriate routine. The numbers at the right margin show the necessary CPU clock cycles for each instruction. The software overhead for different interrupt sources includes interrupt latency and return-from-interrupt cycles, but not the task handling itself.
Timer_B Registers 12.3 Timer_B Registers The Timer_B registers are listed in Table 12−5: Table 12−5.
Timer_B Registers Timer_B Control Register TBCTL 15 14 Unused 13 12 TBCLGRPx 11 CNTLx 10 9 Unused 8 TBSSELx rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 7 6 5 4 3 2 1 0 Unused TBCLR TBIE TBIFG rw−(0) w−(0) rw−(0) rw−(0) IDx rw−(0) MCx rw−(0) rw−(0) rw−(0) Unused Bit 15 Unused TBCLGRP Bit 14-13 TBCLx group 00 Each TBCLx latch loads independently 01 TBCL1+TBCL2 (TBCCR1 CLLDx bits control the update) TBCL3+TBCL4 (TBCCR3 CLLDx bits control the update) TBCL
Timer_B Registers Unused Bit 3 Unused TBCLR Bit 2 Timer_B clear. Setting this bit resets TBR, the TBCLK divider, and the count direction. The TBCLR bit is automatically reset and is always read as zero. TBIE Bit 1 Timer_B interrupt enable. This bit enables the TBIFG interrupt request. 0 Interrupt disabled 1 Interrupt enabled TBIFG Bit 0 Timer_B interrupt flag.
Timer_B Registers TBCCTLx, Capture/Compare Control Register 15 14 13 CMx 12 CCISx 11 10 SCS 9 CLLDx 8 CAP rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) r−(0) rw−(0) 7 6 5 4 3 2 1 0 CCIE CCI OUT COV CCIFG rw−(0) r rw−(0) rw−(0) rw−(0) OUTMODx rw−(0) rw−(0) rw−(0) CMx Bit 15-14 Capture mode 00 No capture 01 Capture on rising edge 10 Capture on falling edge 11 Capture on both rising and falling edges CCISx Bit 13-12 Capture/compare input select.
Timer_B Registers CCIE Bit 4 Capture/compare interrupt enable. This bit enables the interrupt request of the corresponding CCIFG flag. 0 Interrupt disabled 1 Interrupt enabled CCI Bit 3 Capture/compare input. The selected input signal can be read by this bit. OUT Bit 2 Output. For output mode 0, this bit directly controls the state of the output. 0 Output low 1 Output high COV Bit 1 Capture overflow. This bit indicates a capture overflow occurred. COV must be reset with software.
Timer_B Registers TBIV, Timer_B Interrupt Vector Register 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 7 6 5 4 3 2 1 0 0 0 0 0 r0 r0 r0 r0 TBIVx Bits 15-0 TBIVx r−(0) 0 r−(0) r−(0) r0 Timer_B interrupt vector value TBIV Contents Interrupt Source 00h No interrupt pending 02h Capture/compare 1 Interrupt Priority Interrupt Flag − TBCCR1 CCIFG 04h Capture/compare 2 TBCCR2 CCIFG 06h Capture/compare 3† TBCCR3 CCIFG 08h Capture/compar
12-26 Timer_B
Chapter 13 ! ) " - !) The universal synchronous/asynchronous receive/transmit (USART) peripheral interface supports two serial modes with one hardware module. This chapter discusses the operation of the asynchronous UART mode. USART0 is implemented on the MSP430x12xx, MSP430x13xx, and MSP430x15x devices. In addition to USART0, the MSP430x14x and MSP430x16x devices implement a second identical USART module, USART1. Topic Page 13.1 USART Introduction: UART Mode . . . . . . . . .
USART Introduction: UART Mode 13.1 USART Introduction: UART Mode In asynchronous mode, the USART connects the MSP430 to an external system via two external pins, URXD and UTXD. UART mode is selected when the SYNC bit is cleared.
USART Introduction: UART Mode Figure 13−1.
USART Operation: UART Mode 13.2 USART Operation: UART Mode In UART mode, the USART transmits and receives characters at a bit rate asynchronous to another device. Timing for each character is based on the selected baud rate of the USART. The transmit and receive functions use the same baud rate frequency. 13.2.1 USART Initialization and Reset The USART is reset by a PUC or by setting the SWRST bit. After a PUC, the SWRST bit is automatically set, keeping the USART in a reset condition.
USART Operation: UART Mode 13.2.3 Asynchronous Communication Formats When two devices communicate asynchronously, the idle-line format is used for the protocol. When three or more devices communicate, the USART supports the idle-line and address-bit multiprocessor communication formats. Idle-Line Multiprocessor Format When MM = 0, the idle-line multiprocessor format is selected. Blocks of data are separated by an idle time on the transmit or receive lines as shown in Figure 13−3.
USART Operation: UART Mode The URXWIE bit is used to control data reception in the idle-line multiprocessor format. When the URXWIE bit is set, all non-address characters are assembled but not transferred into the UxRXBUF, and interrupts are not generated. When an address character is received, the receiver is temporarily activated to transfer the character to UxRXBUF and sets the URXIFGx interrupt flag. Any applicable error flag is also set. The user can then validate the received address.
USART Operation: UART Mode Address-Bit Multiprocessor Format When MM = 1, the address-bit multiprocessor format is selected. Each processed character contains an extra bit used as an address indicator shown in Figure 13−4. The first character in a block of characters carries a set address bit which indicates that the character is an address. The USART RXWAKE bit is set when a received character is a valid address character and is transferred to UxRXBUF.
USART Operation: UART Mode Automatic Error Detection Glitch suppression prevents the USART from being accidentally started. Any low-level on URXDx shorter than the deglitch time tτ (approximately 300 ns) will be ignored. See the device-specific datasheet for parameters. When a low period on URXDx exceeds tτ a majority vote is taken for the start bit. If the majority vote fails to detect a valid start bit the USART halts character reception and waits for the next low period on URXDx.
USART Operation: UART Mode 13.2.4 USART Receive Enable The receive enable bit, URXEx, enables or disables data reception on URXDx as shown in Figure 13−5. Disabling the USART receiver stops the receive operation following completion of any character currently being received or immediately if no receive operation is active. The receive-data buffer, UxRXBUF, contains the character moved from the RX shift register after the character is received. Figure 13−5.
USART Operation: UART Mode 13.2.5 USART Transmit Enable When UTXEx is set, the UART transmitter is enabled. Transmission is initiated by writing data to UxTXBUF. The data is then moved to the transmit shift register on the next BITCLK after the TX shift register is empty, and transmission begins. This process is shown in Figure 13−6. When the UTXEx bit is reset the transmitter is stopped.
USART Operation: UART Mode 13.2.6 UART Baud Rate Generation The USART baud rate generator is capable of producing standard baud rates from non-standard source frequencies. The baud rate generator uses one prescaler/divider and a modulator as shown in Figure 13−7. This combination supports fractional divisors for baud rate generation. The maximum USART baud rate is one-third the UART source clock frequency BRCLK. Figure 13−7. MSP430 Baud Rate Generator SSEL1 SSEL0 N = 215 28 ...
USART Operation: UART Mode Baud Rate Bit Timing The first stage of the baud rate generator is the 16-bit counter and comparator. At the beginning of each bit transmitted or received, the counter is loaded with INT(N/2) where N is the value stored in the combination of UxBR0 and UxBR1. The counter reloads INT(N/2) for each bit period half-cycle, giving a total bit period of N BRCLKs.
USART Operation: UART Mode Transmit Bit Timing The timing for each character is the sum of the individual bit timings. By modulating each bit, the cumulative bit error is reduced.
USART Operation: UART Mode Receive Bit Timing Receive timing consists of two error sources. The first is the bit-to-bit timing error. The second is the error between a start edge occurring and the start edge being accepted by the USART. Figure 13−9 shows the asynchronous timing errors between data on the URXDx pin and the internal baud-rate clock. Figure 13−9.
USART Operation: UART Mode For example, the receive errors for the following conditions are calculated: Baud rate = 2400 BRCLK = 32,768 Hz (ACLK) UxBR = 13, since the ideal division factor is 13.65 UxMCTL = 6B:m7 = 0, m6 = 1, m5 = 1, m4 = 0, m3 = 1, m2 = 0, m1 = 1 and m0 = 1 The LSB of UxMCTL is used first.
USART Operation: UART Mode Typical Baud Rates and Errors Standard baud rate frequency data for UxBRx and UxMCTL are listed in Table 13−2 for a 32,768-Hz watch crystal (ACLK) and a typical 1,048,576-Hz SMCLK. The receive error is the accumulated time versus the ideal scanning time in the middle of each bit. The transmit error is the accumulated timing error versus the ideal time of the bit period. Table 13−2.
USART Operation: UART Mode 13.2.7 USART Interrupts The USART has one interrupt vector for transmission and one interrupt vector for reception. USART Transmit Interrupt Operation The UTXIFGx interrupt flag is set by the transmitter to indicate that UxTXBUF is ready to accept another character. An interrupt request is generated if UTXIEx and GIE are also set. UTXIFGx is automatically reset if the interrupt request is serviced or if a character is written to UxTXBUF.
USART Operation: UART Mode USART Receive Interrupt Operation The URXIFGx interrupt flag is set each time a character is received and loaded into UxRXBUF. An interrupt request is generated if URXIEx and GIE are also set. URXIFGx and URXIEx are reset by a system reset PUC signal or when SWRST = 1. URXIFGx is automatically reset if the pending interrupt is served (when URXSE = 0) or when UxRXBUF is read. The operation is shown in Figure 13−11. Figure 13−11.
USART Operation: UART Mode Receive-Start Edge Detect Operation The URXSE bit enables the receive start-edge detection feature. The recommended usage of the receive-start edge feature is when BRCLK is sourced by the DCO and when the DCO is off because of low-power mode operation. The ultra-fast turn-on of the DCO allows character reception after the start edge detection. When URXSE, URXIEx and GIE are set and a start edge occurs on URXDx, the internal signal URXS will be set.
USART Operation: UART Mode Receive-Start Edge Detect Conditions When URXSE = 1, glitch suppression prevents the USART from being accidentally started. Any low-level on URXDx shorter than the deglitch time tτ (approximately 300 ns) will be ignored by the USART and no interrupt request will be generated as shown in Figure 13−12. See the device-specific datasheet for parameters. Figure 13−12.
USART Registers: UART Mode 13.3 USART Registers: UART Mode Table 13−3 lists the registers for all devices implementing a USART module. Table 13−4 applies only to devices with a second USART module, USART1. Table 13−3.
USART Registers: UART Mode UxCTL, USART Control Register 7 6 5 4 3 2 1 0 PENA PEV SPB CHAR LISTEN SYNC MM SWRST rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−1 PENA Bit 7 Parity enable 0 Parity disabled. 1 Parity enabled. Parity bit is generated (UTXDx) and expected (URXDx). In address-bit multiprocessor mode, the address bit is included in the parity calculation. PEV Bit 6 Parity select. PEV is not used when parity is disabled. 0 Odd parity 1 Even parity SPB Bit 5 Stop bit select.
USART Registers: UART Mode UxTCTL, USART Transmit Control Register 7 6 Unused CKPL rw−0 rw−0 5 4 SSELx rw−0 3 2 1 0 URXSE TXWAKE Unused TXEPT rw−0 rw−0 rw−0 rw−1 rw−0 Unused Bit 7 Unused CKPL Bit 6 Clock polarity select 0 UCLKI = UCLK 1 UCLKI = inverted UCLK SSELx Bits 5-4 Source select. These bits select the BRCLK source clock. 00 UCLKI 01 ACLK 10 SMCLK 11 SMCLK URXSE Bit 3 UART receive start-edge. The bit enables the UART receive start-edge feature.
USART Registers: UART Mode UxRCTL, USART Receive Control Register 7 6 5 4 3 2 1 0 FE PE OE BRK URXEIE URXWIE RXWAKE RXERR rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 FE Bit 7 Framing error flag 0 No error 1 Character received with low stop bit PE Bit 6 Parity error flag. When PENA = 0, PE is read as 0. 0 No error 1 Character received with parity error OE Bit 5 Overrun error flag. This bit is set when a character is transferred into UxRXBUF before the previous character was read.
USART Registers: UART Mode UxBR0, USART Baud Rate Control Register 0 7 6 5 4 3 2 1 0 27 26 25 24 23 22 21 20 rw rw rw rw rw rw rw rw UxBR1, USART Baud Rate Control Register 1 7 6 5 4 3 2 1 0 215 214 213 212 211 210 29 28 rw rw rw rw rw rw rw rw The valid baud-rate control range is 3 ≤ UxBR < 0FFFFh, where UxBR = {UxBR1+UxBR0}. Unpredictable receive and transmit timing occurs if UxBR <3.
USART Registers: UART Mode UxRXBUF, USART Receive Buffer Register 7 6 5 4 3 2 1 0 27 26 25 24 23 22 21 20 r r r r r r r r UxRXBUFx Bits 7−0 The receive-data buffer is user accessible and contains the last received character from the receive shift register. Reading UxRXBUF resets the receive-error bits, the RXWAKE bit, and URXIFGx. In 7-bit data mode, UxRXBUF is LSB justified and the MSB is always reset.
USART Registers: UART Mode ME1, Module Enable Register 1 7 6 UTXE0† URXE0† rw−0 rw−0 5 4 3 2 1 0 UTXE0† Bit 7 USART0 transmit enable. This bit enables the transmitter for USART0. 0 Module not enabled 1 Module enabled URXE0† Bit 6 USART0 receive enable. This bit enables the receiver for USART0. 0 Module not enabled 1 Module enabled Bits 5-0 These bits may be used by other modules. See device-specific datasheet. † Does not apply to MSP430x12xx devices.
USART Registers: UART Mode IE1, Interrupt Enable Register 1 7 6 UTXIE0† URXIE0† rw−0 rw−0 5 4 3 2 1 0 UTXIE0† Bit 7 USART0 transmit interrupt enable. This bit enables the UTXIFG0 interrupt. 0 Interrupt not enabled 1 Interrupt enabled URXIE0† Bit 6 USART0 receive interrupt enable. This bit enables the URXIFG0 interrupt. 0 Interrupt not enabled 1 Interrupt enabled Bits 5-0 These bits may be used by other modules. See device-specific datasheet. † Does not apply to MSP430x12xx devices.
USART Registers: UART Mode IFG1, Interrupt Flag Register 1 7 6 5 UTXIFG0† URXIFG0† rw−1 rw−0 4 3 2 1 0 UTXIFG0† Bit 7 USART0 transmit interrupt flag. UTXIFG0 is set when U0TXBUF is empty. 0 No interrupt pending 1 Interrupt pending URXIFG0† Bit 6 USART0 receive interrupt flag. URXIFG0 is set when U0RXBUF has received a complete character. 0 No interrupt pending 1 Interrupt pending Bits 5-0 These bits may be used by other modules. See device-specific datasheet.
USART Registers: UART Mode UTXIFG0‡ Bit 1 USART0 transmit interrupt flag. UTXIFG0 is set when U0TXBUF is empty. 0 No interrupt pending 1 Interrupt pending URXIFG0‡ Bit 0 USART0 receive interrupt flag. URXIFG0 is set when U0RXBUF has received a complete character.
USART Peripheral Interface, UART Mode 13-31
Chapter 14 ! ) " - The universal synchronous/asynchronous receive/transmit (USART) peripheral interface supports two serial modes with one hardware module. This chapter discusses the operation of the synchronous peripheral interface or SPI mode. USART0 is implemented on the MSP430x12xx, MSP430x13xx, and MSP430x15x devices. In addition to USART0, the MSP430x14x and MSP430x16x devices implement a second identical USART module, USART1. Topic Page 14.
USART Introduction: SPI Mode 14.1 USART Introduction: SPI Mode In synchronous mode, the USART connects the MSP430 to an external system via three or four pins: SIMO, SOMI, UCLK, and STE. SPI mode is selected when the SYNC bit is set and the I2C bit is cleared.
USART Introduction: SPI Mode Figure 14−1.
USART Operation: SPI Mode 14.2 USART Operation: SPI Mode In SPI mode, serial data is transmitted and received by multiple devices using a shared clock provided by the master. An additional pin, STE, is provided as to enable a device to receive and transmit data and is controlled by the master. Three or four signals are used for SPI data exchange: - SIMO Slave in, master out Master mode: SIMO is the data output line. Slave mode: SIMO is the data input line.
USART Operation: SPI Mode 14.2.2 Master Mode Figure 14−2. USART Master and External Slave MASTER Receive Buffer UxRXBUF SLAVE SIMO Transmit Buffer UxTXBUF Receive Shift Register MSB SIMO SPI Receive Buffer Px.x STE STE SS Port.x SOMI Transmit Shift Register LSB MSB LSB UCLK MSP430 USART SOMI Data Shift Register (DSR) LSB MSB SCLK COMMON SPI Figure 14−2 shows the USART as a master in both 3-pin and 4-pin configurations.
USART Operation: SPI Mode 14.2.3 Slave Mode Figure 14−3. USART Slave and External Master MASTER SIMO SPI Receive Buffer Transmit Buffer UxTXBUF Data Shift Register DSR MSB SLAVE SIMO Px.x STE STE SS Port.x SOMI SOMI LSB SCLK Receive Buffer UxRXBUF Transmit Shift Register Receive Shift Register MSB MSB LSB LSB UCLK COMMON SPI MSP430 USART Figure 14−3 shows the USART as a slave in both 3-pin and 4-pin configurations.
USART Operation: SPI Mode 14.2.4 SPI Enable The SPI transmit/receive enable bit USPIEx enables or disables the USART in SPI mode. When USPIEx = 0, the USART stops operation after the current transfer completes, or immediately if no operation is active. A PUC or set SWRST bit disables the USART immediately and any active transfer is terminated. Transmit Enable When USPIEx = 0, any further write to UxTXBUF does not transmit.
USART Operation: SPI Mode Receive Enable The SPI receive enable state diagrams are shown in Figure 14−6 and Figure 14−7. When USPIEx = 0, UCLK is disabled from shifting data into the RX shift register. Figure 14−6.
USART Operation: SPI Mode 14.2.5 Serial Clock Control UCLK is provided by the master on the SPI bus. When MM = 1, BITCLK is provided by the USART baud rate generator on the UCLK pin as shown in Figure 14−8. When MM = 0, the USART clock is provided on the UCLK pin by the master and, the baud rate generator is not used and the SSELx bits are don’t care. The SPI receiver and transmitter operate in parallel and use the same clock source for data transfer. Figure 14−8.
USART Operation: SPI Mode Serial Clock Polarity and Phase The polarity and phase of UCLK are independently configured via the CKPL and CKPH control bits of the USART. Timing for each case is shown in Figure 14−9. Figure 14−9.
USART Operation: SPI Mode 14.2.6 SPI Interrupts The USART has one interrupt vector for transmission and one interrupt vector for reception. SPI Transmit Interrupt Operation The UTXIFGx interrupt flag is set by the transmitter to indicate that UxTXBUF is ready to accept another character. An interrupt request is generated if UTXIEx and GIE are also set. UTXIFGx is automatically reset if the interrupt request is serviced or if a character is written to UxTXBUF. UTXIFGx is set after a PUC or when SWRST = 1.
USART Operation: SPI Mode SPI Receive Interrupt Operation The URXIFGx interrupt flag is set each time a character is received and loaded into UxRXBUF as shown in Figure 14−11 and Figure 14−12. An interrupt request is generated if URXIEx and GIE are also set. URXIFGx and URXIEx are reset by a system reset PUC signal or when SWRST = 1. URXIFGx is automatically reset if the pending interrupt is served or when UxRXBUF is read. Figure 14−11.
USART Registers: SPI Mode 14.3 USART Registers: SPI Mode The USART registers, shown in Table 14−1 and Table 14−2, are byte structured and should be accessed using byte instructions. Table 14−1.
USART Registers: SPI Mode UxCTL, USART Control Register 7 6 5 4 3 2 1 0 Unused Unused I2C† CHAR LISTEN SYNC MM SWRST rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−1 Unused Bits 7−6 Unused I2C† Bit 5 I2C mode enable. This bit selects I2C or SPI operation when SYNC = 1. 0 SPI mode 1 I2C mode CHAR Bit 4 Character length 0 7-bit data 1 8-bit data LISTEN Bit 3 Listen enable. The LISTEN bit selects the loopback mode 0 Disabled 1 Enabled.
USART Registers: SPI Mode UxTCTL, USART Transmit Control Register 7 6 CKPH CKPL rw−0 rw−0 5 4 SSELx rw−0 rw−0 3 2 1 0 Unused Unused STC TXEPT rw−0 rw−0 rw−0 rw−1 CKPH Bit 7 Clock phase select. Controls the phase of UCLK. 0 Normal UCLK clocking scheme 1 UCLK is delayed by one half cycle CKPL Bit 6 Clock polarity select 0 The inactive level is low; data is output with the rising edge of UCLK; input data is latched with the falling edge of UCLK.
USART Registers: SPI Mode UxRCTL, USART Receive Control Register 7 6 5 4 3 2 1 0 FE Unused OE Unused Unused Unused Unused Unused rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 FE Bit 7 Framing error flag. This bit indicates a bus conflict when MM = 1 and STC = 0. FE is unused in slave mode. 0 No conflict detected 1 A negative edge occurred on STE, indicating bus conflict Undefined Bit 6 Unused OE Bit 5 Overrun error flag.
USART Registers: SPI Mode UxBR0, USART Baud Rate Control Register 0 7 6 5 4 3 2 1 0 27 26 25 24 23 22 21 20 rw rw rw rw rw rw rw rw UxBR1, USART Baud Rate Control Register 1 7 6 5 4 3 2 1 0 215 214 213 212 211 210 29 28 rw rw rw rw rw rw rw rw UxBRx The baud-rate generator uses the content of {UxBR1+UxBR0} to set the baud rate. Unpredictable SPI operation occurs if UxBR < 2.
USART Registers: SPI Mode UxRXBUF, USART Receive Buffer Register 7 6 5 4 3 2 1 0 27 26 25 24 23 22 21 20 r r r r r r r r UxRXBUFx Bits 7−0 The receive-data buffer is user accessible and contains the last received character from the receive shift register. Reading UxRXBUF resets the OE bit and URXIFGx flag. In 7-bit data mode, UxRXBUF is LSB justified and the MSB is always reset.
USART Registers: SPI Mode ME1, Module Enable Register 1 7 6 5 4 3 2 1 0 USPIE0† rw−0 USPIE0† Bit 7 This bit may be used by other modules. See device-specific datasheet. Bit 6 USART0 SPI enable. This bit enables the SPI mode for USART0. 0 Module not enabled 1 Module enabled Bits 5-0 These bits may be used by other modules. See device-specific datasheet. † Does not apply to MSP430x12xx devices.
USART Registers: SPI Mode IE1, Interrupt Enable Register 1 7 6 UTXIE0† URXIE0† rw−0 rw−0 5 4 3 2 1 0 UTXIE0† Bit 7 USART0 transmit interrupt enable. This bit enables the UTXIFG0 interrupt. 0 Interrupt not enabled 1 Interrupt enabled URXIE0† Bit 6 USART0 receive interrupt enable. This bit enables the URXIFG0 interrupt. 0 Interrupt not enabled 1 Interrupt enabled Bits 5-0 These bits may be used by other modules. See device-specific datasheet. † Does not apply to MSP430x12xx devices.
USART Registers: SPI Mode UTXIE0‡ Bit 1 USART0 transmit interrupt enable. This bit enables the UTXIFG0 interrupt. 0 Interrupt not enabled 1 Interrupt enabled URXIE0‡ Bit 0 USART0 receive interrupt enable. This bit enables the URXIFG0 interrupt for USART0.
USART Registers: SPI Mode IFG1, Interrupt Flag Register 1 7 6 5 UTXIFG0† URXIFG0† rw−1 rw−0 4 3 2 1 0 UTXIFG0† Bit 7 USART0 transmit interrupt flag. UTXIFG0 is set when U0TXBUF is empty. 0 No interrupt pending 1 Interrupt pending URXIFG0† Bit 6 USART0 receive interrupt flag. URXIFG0 is set when U0RXBUF has received a complete character. 0 No interrupt pending 1 Interrupt pending Bits 5-0 These bits may be used by other modules. See device-specific datasheet.
USART Peripheral Interface, SPI Mode 14-23
Chapter 15 ! ) " - . The universal synchronous/asynchronous receive/transmit (USART) peripheral interface supports I2C communication in USART0. This chapter describes the I2C mode. The I2C mode is implemented on the MSP430x15x and MSP430x16x devices. Topic Page 15.1 I2C Module Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2 15.2 I2C Module Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
I 2C Module Introduction 15.1 I2C Module Introduction The inter-IC control (I2C) module provides an interface between the MSP430 and I2C-compatible devices connected by way of the two-wire I2C serial bus. External components attached to the I2C bus serially transmit and/or receive serial data to/from the USART through the 2-wire I2C interface. The I2C module has the following features: - Compliance to the Philips Semiconductor I2C specification v2.
I 2C Module Introduction Figure 15−1.
I 2C Module Operation 15.2 I2C Module Operation The I2C module supports any slave or master I2C-compatible device. Figure 15−2 shows an example of an I2C bus. Each I2C device is recognized by a unique address and can operate as either a transmitter or a receiver. A device connected to the I2C bus can be considered as the master or the slave when performing data transfers. A master initiates a data transfer and generates the clock signal SCL. Any device addressed by a master is considered a slave.
I 2C Module Operation 15.2.1 I2C Module Initialization The I2C module is part of the USART peripheral. Individual bit definitions when using USART0 in I2C mode are different from that in SPI or UART mode. The default value for the U0CTL register is the UART mode. To select I2C operation the SYNC and I2C bits must be set. After module initialization, the I2C module is ready for transmit or receive operation. Setting I2CEN releases the I2C module for operation.
I 2C Module Operation 15.2.2 I2C Serial Data One clock pulse is generated by the master device for each data bit transferred. The I2C module operates with byte data. Data is transferred most significant bit first as shown in Figure 15−3. The first byte after a START condition consists of a 7-bit slave address and the R/W bit. When R/W = 0, the master transmits data to a slave. When R/W = 1, the master receives data from a slave. The ACK bit is sent from the receiver after each byte on the 9th SCL clock.
I 2C Module Operation 15.2.3 I2C Addressing Modes The I2C module supports 7-bit and 10-bit addressing modes. 7-Bit Addressing In the 7-bit addressing format, shown in Figure 15−5, the first byte is the 7-bit slave address and the R/W bit. The ACK bit is sent from the receiver after each byte. Figure 15−5.
I 2C Module Operation 15.2.4 I2C Module Operating Modes The I2C module operates in master transmitter, master receiver, slave transmitter, or slave receiver mode. Master Mode In master mode, transmit and receive operation is controlled with the I2CRM, I2CSTT, and I2CSTP bits as described in Table 15−1. The master transmitter and master receiver modes are shown in Figure 15−8 and Figure 15−9. SCL is held low when the intervention of the CPU is required after a byte has been received or transmitted.
I 2C Module Operation Figure 15−8. Master Transmitter Mode IDLE I2CSTT=1 *When I2RM=1, I2CSTP must be set before the last I2CDR value is written. Othwerwise, correct STOP generation will not occur.
I 2C Module Operation Figure 15−9.
I 2C Module Operation Arbitration If two or more master transmitters simultaneously start a transmission on the bus, an arbitration procedure is invoked. Figure 15−10 illustrates the arbitration procedure between two devices. The arbitration procedure uses the data presented on SDA by the competing transmitters. The first master transmitter that generates a logic high is overruled by the opposing master generating a logic low.
I 2C Module Operation Automatic Data Byte Counting Automatic data byte counting is supported in master mode with the I2CNDAT register. When I2CRM = 0, the number of bytes to be received or transmitted is written to I2CNDAT. A STOP condition is automatically generated after I2CNDAT number of bytes have been transferred. Note: I2CNDAT Register Do not change the I2CNDAT register while I2CBB = 1 and I2CRM = 0. Otherwise, unpredictable operation may occur.
I 2C Module Operation Figure 15−11.
I 2C Module Operation Figure 15−12.
I 2C Module Operation 15.2.5 The I2C Data Register I2CDR The I2CDR register can be accessed as an 8-bit or 16-bit register selected by the I2CWORD bit. The I2CDR register functions as described in Table 15−2. When I2CWORD = 1, any attempt to modify the register with a byte instruction will fail and the register will not be modified. Table 15−2.I2CDR Register Function I2CWORD I2CTRX I2CDR Function 0 1 Byte mode transmit: Only the low byte is used. The byte is double buffered.
I 2C Module Operation 15.2.6 I2C Clock Generation and Synchronization The I2C module is operated with the clock source selected by the I2CSSELx bits. The prescaler, I2CPSC, and the I2CSCLH and I2CSCLL registers determine the frequency and duty cycle of the SCL clock signal for master mode as shown in Figure 15−13. Note: I2CCLK Maximum Frequency The I2C module clock source I2CIN must be at least 10x the SCL frequency in both master and slave modes.
I 2C Module Operation 15.2.7 Using the I2C Module with Low Power Modes The I2C module can be used with MSP430 low-power modes. When the internal clock source for the I2C module is present, the module operates normally regardless of the MSP430 operating mode. When the internal clock source for the I2C module is not present, automatic clock activation is provided.
I 2C Module Operation 15.2.8 I2C Interrupts The I2C module has one interrupt vector for eight interrupt flags listed in Table 15−3. Each interrupt flag has its own interrupt enable bit. When an interrupt is enabled, and the GIE bit is set, the interrupt flag will generate an interrupt request. Table 15−3.I 2C Interrupts Interrupt Flag 15-18 Interrupt Condition ALIFG Arbitration-lost.
I 2C Module Operation I2CIV, Interrupt Vector Generator The I2C interrupt flags are prioritized and combined to source a single interrupt vector. The interrupt vector register I2CIV is used to determine which flag requested an interrupt. The highest priority enabled interrupt generates a number in the I2CIV register that can be evaluated or added to the program counter to automatically enter the appropriate software routine. Disabled I2C interrupts do not affect the I2CIV value.
I 2C Module Registers 15.3 I2C Module Registers The I2C module registers are listed in Table 15−4. Table 15−4.
I 2C Module Registers U0CTL, USART0 Control Register-I2C Mode 7 6 5 4 3 2 1 0 RXDMAEN TXDMAEN I2C XA LISTEN SYNC MST I2CEN rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−1 RXDMAEN Bit 7 Receive DMA enable. This bit enables the DMA controller to be used to transfer data from the I2C module after the I2C modules receives data. When RXDMAEN = 1, RXRDYIE is ignored. 0 Disabled 1 Enabled TXDMAEN Bit 6 Transmit DMA enable.
I 2C Module Registers I2CTCTL, I2C Transmit Control Register 7 6 I2CWORD I2CRM rw−0 rw−0 5 4 I2CSSELx rw−0 rw−0 3 2 1 0 I2CTRX I2CSTB I2CSTP I2CSTT rw−0 rw−0 rw−0 rw−0 Modifiable only when I2CEN = 0 I2CWORD Bit 7 I2C word mode. Selects byte or word mode for the I2C data register. 0 Byte mode 1 Word mode I2CRM Bit 6 I2C repeat mode 0 I2CNDAT defines the number of bytes transmitted. 1 Number of bytes transmitted is controlled by software. I2CNDAT is unused.
I 2C Module Registers I2CDCTL, I2C Data Control Register 7 6 5 4 3 2 1 0 Unused Unused I2CBUSY I2C SCLLOW I2CSBD I2CTXUDF I2CRXOVR I2CBB r0 r0 r−0 r−0 r−0 r−0 r−0 r−0 Unused Bits 7−6 Unused. Always read as 0. I2CBUSY Bit 5 I2C busy 0 I2C module is idle 1 I2C module is not idle I2C SCLLOW Bit 4 I2C SCL low. This bit indicates if a slave is holding the SCL line low while the MSP430 is the master and is unused in slave mode.
I 2C Module Registers I2CDRW, I2CDRB, I2C Data Register 15 14 13 12 11 10 9 8 I2CDRW High Byte rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 7 6 5 4 3 2 1 0 rw−0 rw−0 rw−0 I2CDRW Low Byte I2CDRB rw−0 I2CDRW/ I2CDRB rw−0 Bits 15−8 rw−0 rw−0 rw−0 I2C Data. When I2CWORD = 1, the register name is I2CDRW. When I2CWORD = 0, the name is I2CDRB. When I2CWORD = 1, any attempt to modify the register with a byte instruction will fail and the register will not be updated.
I 2C Module Registers I2CPSC, I2C Clock Prescaler Register 7 6 5 4 3 2 1 0 rw−0 rw−0 rw−0 rw−0 I2CPSCx rw−0 rw−0 rw−0 rw−0 Modifiable only when I2CEN = 0 I2CPSCx Bits 7−0 I2C clock prescaler. The I2C clock input I2CIN is divided by the I2CPSCx value to produce the internal I2C clock frequency. The division rate is I2CPSCx+1. I2CPSCx values > 4 are not recommended. The I2CSCLL and I2CSCLH registers should be used to set the SCL frequency.
I 2C Module Registers I2CSCLH, I2C Shift Clock High Register 7 6 5 4 3 2 1 0 rw−0 rw−0 rw−0 rw−0 I2CSCLHx rw−0 rw−0 rw−0 rw−0 Modifiable only when I2CEN = 0 I2CSCLHx I2C shift clock high. These bits define the high period of SCL when the I2C controller is in master mode. The SCL high period is (I2CSCLH+2) x (I2CPSC + 1).
I 2C Module Registers I2COA, I2C Own Address Register, 7-Bit Addressing Mode 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 7 6 5 4 3 2 1 0 rw−0 rw−0 rw−0 0 r0 I2COAx rw−0 rw−0 rw−0 rw−0 Modifiable only when I2CEN = 0 I2COAx I2C own address. The I2COA register contains the local address of the MSP430 I2C controller. The I2COA register is right-justified. Bit 6 is the MSB. Bits 15-7 are always 0.
I 2C Module Registers I2CSA, I2C Slave Address Register, 7-Bit Addressing Mode 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 7 6 5 4 3 2 1 0 rw−0 rw−0 rw−0 0 r0 I2CSAx I2CSAx rw−0 rw−0 rw−0 rw−0 I2C slave address. The I2CSA register contains the slave address of the external device to be addressed by the MSP430. It is only used in master mode. The I2CSA register is right-justified. Bit 6 is the MSB. Bits 15-7 are always 0.
I 2C Module Registers I2CIE, I2C Interrupt Enable Register 7 6 5 4 3 2 1 0 STTIE GCIE TXRDYIE RXRDYIE ARDYIE OAIE NACKIE ALIE rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 STTIE Bit 7 START detect interrupt enable 0 Interrupt disabled 1 Interrupt enabled GCIE Bit 6 General call interrupt enable 0 Interrupt disabled 1 Interrupt enabled TXRDYIE Bit 5 Transmit ready interrupt enable. When TXDMAEN = 1, TXRDYIE is ignored and TXRDYIFG will not generate an interrupt.
I 2C Module Registers I2CIFG, I2C Interrupt Flag Register 7 6 5 4 3 2 1 0 STTIFG GCIFG TXRDYIFG RXRDYIFG ARDYIFG OAIFG NACKIFG ALIFG rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 rw−0 STTIFG Bit 7 START detect interrupt flag 0 No interrupt pending 1 Interrupt pending GCIFG Bit 6 General call interrupt flag 0 No interrupt pending 1 Interrupt pending TXRDYIFG Bit 5 Transmit ready interrupt flag 0 No interrupt pending 1 Interrupt pending RXRDYIFG Bit 4 Receive ready interrupt flag 0 No
I 2C Module Registers I2CIV, I2C Interrupt Vector Register 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 7 6 5 4 3 2 1 0 0 0 0 r0 r0 r0 I2CIVx Bits 15-0 I2CIVx r−0 r−0 0 r−0 r−0 r0 I2C interrupt vector value I2CIV Contents Interrupt Source Interrupt Flag 000h No interrupt pending 002h Arbitration lost ALIFG 004h No acknowledgement NACKIFG 006h Own address OAIFG 008h Register access ready ARDYIFG 00Ah Receive data ready RXRDYIF
15-32 USART Peripheral Interface, I 2C Mode
Chapter 16 ,) Comparator_A is an analog voltage comparator. This chapter describes Comparator_A. Comparator_A is implemented in MSP430x11x1, MSP430x12x, MSP430x13x, MSP430x14x, MSP430x15x and MSP430x16x devices. Topic Page 16.1 Comparator_A Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-2 16.2 Comparator_A Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-4 16.3 Comparator_A Registers . . . . . . . . . . . . . . . . . .
Comparator_A Introduction 16.1 Comparator_A Introduction The comparator_A module supports precision slope analog-to-digital conversions, supply voltage supervision, and monitoring of external analog signals.
Comparator_A Introduction Figure 16−1. Comparator_A Block Diagram VCC 0V P2CA0 CAEX 1 0 CAON 0 CA0 1 1 0 CA1 CAF 0 CCI1B ++ 0 0 −− 1 1 CAOUT 0 1 1 Set_CAIFG Tau ~ 2.0ms P2CA1 0V 1 0 CAREFx CARSEL 0.5x VCC 00 0 1 VCAREF 01 10 0.
Comparator_A Operation 16.2 Comparator_A Operation The comparator_A module is configured with user software. The setup and operation of comparator_A is discussed in the following sections. 16.2.1 Comparator The comparator compares the analog voltages at the + and – input terminals. If the + terminal is more positive than the – terminal, the comparator output CAOUT is high. The comparator can be switched on or off using control bit CAON.
Comparator_A Operation 16.2.3 Output Filter The output of the comparator can be used with or without internal filtering. When control bit CAF is set, the output is filtered with an on-chip RC-filter. Any comparator output oscillates if the voltage difference across the input terminals is small. Internal and external parasitic effects and cross coupling on and between signal lines, power supply lines, and other parts of the system are responsible for this behavior as shown in Figure 16−2.
Comparator_A Operation 16.2.5 Comparator_A, Port Disable Register CAPD The comparator input and output functions are multiplexed with the associated I/O port pins, which are digital CMOS gates. When analog signals are applied to digital CMOS gates, parasitic current can flow from VCC to GND. This parasitic current occurs if the input voltage is near the transition level of the gate. Disabling the port pin buffer eliminates the parasitic current flow and therefore reduces overall current consumption.
Comparator_A Operation 16.2.7 Comparator_A Used to Measure Resistive Elements The Comparator_A can be optimized to precisely measure resistive elements using single slope analog-to-digital conversion. For example, temperature can be converted into digital data using a thermistor, by comparing the thermistor’s capacitor discharge time to that of a reference resistor as shown in Figure 16−5. A reference resister Rref is compared to Rmeas. Figure 16−5. Temperature Measurement System Rref Px.x Rmeas Px.
Comparator_A Operation The thermistor measurement is based on a ratiometric conversion principle. The ratio of two capacitor discharge times is calculated as shown in Figure 16−6. Figure 16−6. Timing for Temperature Measurement Systems VC VCC Rmeas Rref 0.
Comparator_A Registers 16.3 Comparator_A Registers The Comparator_A registers are listed in Table 16−1: Table 16−1.
Comparator_A Registers CACTL1, Comparator_A Control Register 1 7 6 CAEX CARSEL rw−(0) rw−(0) 5 4 CAREFx rw−(0) rw−(0) 3 2 1 0 CAON CAIES CAIE CAIFG rw−(0) rw−(0) rw−(0) rw−(0) CAEX Bit 7 Comparator_A exchange. This bit exchanges the comparator inputs and inverts the comparator output. CARSEL Bit 6 Comparator_A reference select. This bit selects which terminal the VCAREF is applied to.
Comparator_A Registers CACTL2, Comparator_A, Control Register 7 6 5 4 Unused rw−(0) rw−(0) rw−(0) rw−(0) 3 2 1 0 P2CA1 P2CA0 CAF CAOUT rw−(0) rw−(0) rw−(0) r−(0) Unused Bits 7-4 Unused. P2CA1 Bit 3 Pin to CA1. This bit selects the CA1 pin function. 0 The pin is not connected to CA1 1 The pin is connected to CA1 P2CA0 Bit 2 Pin to CA0. This bit selects the CA0 pin function.
16-12 Comparator_A
Chapter 17 )( . The ADC12 module is a high-performance 12-bit analog-to-digital converter. This chapter describes the ADC12. The ADC12 is implemented in the MSP430x13x, MSP430x14x, MSP430x15x, and MSP430x16x devices. Topic Page 17.1 ADC12 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-2 17.2 ADC12 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-4 17.3 ADC12 Registers . . . . . . . . . . . . . . . .
ADC12 Introduction 17.1 ADC12 Introduction The ADC12 module supports fast, 12-bit analog-to-digital conversions. The module implements a 12-bit SAR core, sample select control, reference generator and a 16 word conversion-and-control buffer. The conversion-and-control buffer allows up to 16 independent ADC samples to be converted and stored without any CPU intervention.
ADC12 Introduction Figure 17−1. ADC12 Block Diagram REFON INCHx=0Ah REF2_5V Ve REF+ on 1.5 V or 2.5 V Reference VREF+ VREF− / Ve REF− AVCC INCHx AVSS 4 A0 A1 A2 A3 A4 A5 A6 A7 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 SREF2 1 Ref_x SREF1 SREF0 11 10 01 00 ADC12OSC ADC12SSELx ADC12ON 0 AVCC ADC12DIVx VR− Sample and Hold VR+ 00 Divider /1 ..
ADC12 Operation 17.2 ADC12 Operation The ADC12 module is configured with user software. The setup and operation of the ADC12 is discussed in the following sections. 17.2.1 12-Bit ADC Core The ADC core converts an analog input to its 12-bit digital representation and stores the result in conversion memory. The core uses two programmable/selectable voltage levels (VR+ and VR−) to define the upper and lower limits of the conversion.
ADC12 Operation 17.2.2 ADC12 Inputs and Multiplexer The eight external and four internal analog signals are selected as the channel for conversion by the analog input multiplexer. The input multiplexer is a break-before-make type to reduce input-to-input noise injection resulting from channel switching as shown in Figure 17−2. The input multiplexer is also a T-switch to minimize the coupling between channels.
ADC12 Operation 17.2.3 Voltage Reference Generator The ADC12 module contains a built-in voltage reference with two selectable voltage levels, 1.5 V and 2.5 V. Either of these reference voltages may be used internally and externally on pin VREF+. Setting REFON=1 enables the internal reference. When REF2_5V = 1, the internal reference is 2.5 V, the reference is 1.5 V when REF2_5V = 0. The reference can be turned off to save power when not in use.
ADC12 Operation 17.2.5 Sample and Conversion Timing An analog-to-digital conversion is initiated with a rising edge of the sample input signal SHI. The source for SHI is selected with the SHSx bits and includes the following: - The ADC12SC bit The Timer_A Output Unit 1 The Timer_B Output Unit 0 The Timer_B Output Unit 1 The polarity of the SHI signal source can be inverted with the ISSH bit. The SAMPCON signal controls the sample period and start of conversion. When SAMPCON is high, sampling is active.
ADC12 Operation Pulse Sample Mode The pulse sample mode is selected when SHP = 1. The SHI signal is used to trigger the sampling timer. The SHT0x and SHT1x bits in ADC12CTL0 control the interval of the sampling timer that defines the SAMPCON sample period tsample. The sampling timer keeps SAMPCON high after synchronization with AD12CLK for a programmed interval tsample. The total sampling time is tsample plus tsync. See Figure 17−4. The SHTx bits select the sampling time in 4x multiples of ADC12CLK.
ADC12 Operation Sample Timing Considerations When SAMPCON = 0 all Ax inputs are high impedance. When SAMPCON = 1, the selected Ax input can be modeled as an RC low-pass filter during the sampling time tsample, as shown below in Figure 17−5. An internal MUX-on input resistance RI (max. 2 kΩ) in series with capacitor CI (max. 40 pF) is seen by the source. The capacitor CI voltage VC must be charged to within 1/2 LSB of the source voltage VS for an accurate 12-bit conversion. Figure 17−5.
ADC12 Operation 17.2.6 Conversion Memory There are 16 ADC12MEMx conversion memory registers to store conversion results. Each ADC12MEMx is configured with an associated ADC12MCTLx control register. The SREFx bits define the voltage reference and the INCHx bits select the input channel. The EOS bit defines the end of sequence when a sequential conversion mode is used. A sequence rolls over from ADC12MEM15 to ADC12MEM0 when the EOS bit in ADC12MCTL15 is not set.
ADC12 Operation Single-Channel Single-Conversion Mode A single channel is sampled and converted once. The ADC result is written to the ADC12MEMx defined by the CSTARTADDx bits. Figure 17−6 shows the flow of the Single-Channel, Single-Conversion mode. When ADC12SC triggers a conversion, successive conversions can be triggered by the ADC12SC bit. When any other trigger source is used, ENC must be toggled between each conversion. Figure 17−6.
ADC12 Operation 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 EOS bit. Figure 17−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, ENC must be toggled between each sequence.
ADC12 Operation 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 17−8 shows repeat-single-channel mode Figure 17−8.
ADC12 Operation 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 EOS bit and the next trigger signal re-starts the sequence. Figure 17−9 shows the repeat-sequence-of-channels mode. Figure 17−9.
ADC12 Operation Using the Multiple Sample and Convert (MSC) Bit To configure the converter to perform successive conversions automatically and as quickly as possible, a multiple sample and convert function is available. When MSC = 1, CONSEQx > 0, and the sample timer is used, the first rising edge of the SHI signal triggers the first conversion. Successive conversions are triggered automatically as soon as the prior conversion is completed.
ADC12 Operation 17.2.8 Using the Integrated Temperature Sensor To use the on-chip temperature sensor, the user selects the analog input channel INCHx = 1010. Any other configuration is done as if an external channel was selected, including reference selection, conversion-memory selection, etc. The typical temperature sensor transfer function is shown in Figure 17−10. When using the temperature sensor, the sample period must be greater than 30 µs.
ADC12 Operation 17.2.9 ADC12 Grounding and Noise Considerations As with any high-resolution ADC, appropriate printed-circuit-board layout and grounding techniques should be followed to eliminate ground loops, unwanted parasitic effects, and noise. Ground loops are formed when return current from the A/D flows through paths that are common with other analog or digital circuitry.
ADC12 Operation 17.2.10 ADC12 Interrupts The ADC12 has 18 interrupt sources: - ADC12IFG0-ADC12IFG15 - ADC12OV, ADC12MEMx overflow - ADC12TOV, ADC12 conversion time overflow The ADC12IFGx bits are set when their corresponding ADC12MEMx memory register is loaded with a conversion result. An interrupt request is generated if the corresponding ADC12IEx bit and the GIE bit are set. The ADC12OV condition occurs when a conversion result is written to any ADC12MEMx before its previous conversion result was read.
ADC12 Operation ADC12 Interrupt Handling Software Example The following software example shows the recommended use of ADC12IV and the handling overhead. The ADC12IV value is added to the PC to automatically jump to the appropriate routine. The numbers at the right margin show the necessary CPU cycles for each instruction. The software overhead for different interrupt sources includes interrupt latency and return-from-interrupt cycles, but not the task handling itself.
ADC12 Registers 17.3 ADC12 Registers The ADC12 registers are listed in Table 17−2: Table 17−2.
ADC12 Registers ADC12CTL0, ADC12 Control Register 0 15 14 13 12 11 10 SHT1x 9 8 SHT0x rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 7 6 5 4 3 2 1 0 MSC REF2_5V REFON ADC12ON ADC12OVIE ADC12 TOVIE ENC ADC12SC rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) Modifiable only when ENC = 0 SHT1x Bits 15-12 Sample-and-hold time. These bits define the number of ADC12CLK cycles in the sampling period for registers ADC12MEM8 to ADC12MEM15.
ADC12 Registers MSC Bit 7 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-conversion. 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. REF2_5V Bit 6 Reference generator voltage. REFON must also be set. 0 1.5 V 1 2.
ADC12 Registers ADC12CTL1, ADC12 Control Register 1 15 14 13 12 11 CSTARTADDx 10 SHSx 9 8 SHP ISSH rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 7 6 5 4 3 2 1 0 ADC12DIVx rw−(0) rw−(0) ADC12SSELx rw−(0) rw−(0) rw−(0) ADC12 BUSY CONSEQx rw−(0) rw−(0) r−(0) Modifiable only when ENC = 0 CSTART ADDx Bits 15-12 Conversion start address.
ADC12 Registers ADC12 SSELx Bits 4-3 ADC12 clock source select 00 ADC12OSC 01 ACLK 10 MCLK 11 SMCLK CONSEQx Bits 2-1 Conversion sequence mode select 00 Single-channel, single-conversion 01 Sequence-of-channels 10 Repeat-single-channel 11 Repeat-sequence-of-channels ADC12 BUSY Bit 0 ADC12 busy. This bit indicates an active sample or conversion operation. 0 No operation is active. 1 A sequence, sample, or conversion is active.
ADC12 Registers ADC12MCTLx, ADC12 Conversion Memory Control Registers 7 6 EOS rw−(0) 5 4 3 2 SREFx rw−(0) rw−(0) 1 0 rw−(0) rw−(0) INCHx rw−(0) rw−(0) rw−(0) Modifiable only when ENC = 0 EOS Bit 7 End of sequence. Indicates the last conversion in a sequence.
ADC12 Registers ADC12IE, ADC12 Interrupt Enable Register 15 14 13 12 11 10 9 8 ADC12IE15 ADC12IE14 ADC12IE13 ADC12IE12 ADC12IE11 ADC12IE10 ADC12IE9 ADC12IE8 rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 7 6 5 4 3 2 1 0 ADC12IE7 ADC12IE6 ADC12IE5 ADC12IE4 ADC12IE3 ADC12IE2 ADC12IE1 ADC12IE0 rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) ADC12IEx Bits 15-0 Interrupt enable.
ADC12 Registers ADC12IV, ADC12 Interrupt Vector Register 15 14 13 12 11 10 9 8 0 0 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r0 r0 7 6 5 4 3 2 1 0 0 0 r0 r0 ADC12IVx Bits 15-0 ADC12IVx r−(0) r−(0) r−(0) 0 r−(0) r−(0) r0 ADC12 interrupt vector value ADC12IV Contents Interrupt Source Interrupt Flag 000h No interrupt pending − 002h ADC12MEMx overflow − 004h Conversion time overflow − 006h ADC12MEM0 interrupt flag ADC12IFG0 008h ADC12MEM1 interrupt flag ADC12IF
17-28 ADC12
Chapter 18 )( / The ADC10 module is a high-performance 10-bit analog-to-digital converter. This chapter describes the ADC10. The ADC10 is implemented in the MSP430x11x2, MSP430x12x2 devices. Topic Page 18.1 ADC10 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-2 18.2 ADC10 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-4 18.3 ADC10 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ADC10 Introduction 18.1 ADC10 Introduction The ADC10 module supports fast, 10-bit analog-to-digital conversions. The module implements a 10-bit SAR core, sample select control, reference generator, and data transfer controller (DTC). The DTC allows ADC10 samples to be converted and stored anywhere in memory without CPU intervention. The module can be configured with user software to support a variety of applications.
ADC10 Introduction Figure 18−1. ADC10 Block Diagram REFBURST REFOUT Ve REF+ 0 on 1.5 V or 2.5 V Reference VREF+ 1 REFON INCHx=0Ah REF2_5V ADC10SR VREF−/ Ve REF− INCHx VCC Ref_x VCC 4 Auto A0 A1 A2 A3 A4 A5 A6 A7 CONSEQx 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 SREF2 VSS 1 11 10 01 00 SREF1 SREF0 ADC10SSELx ADC10ON 0 ADC10OSC ADC10DIVx Sample and Hold VR− S/H Convert VR+ 00 Divider /1 ..
ADC10 Operation 18.2 ADC10 Operation The ADC10 module is configured with user software. The setup and operation of the ADC10 is discussed in the following sections. 18.2.1 10-Bit ADC Core The ADC core converts an analog input to its 10-bit digital representation and stores the result in the ADC10MEM register. The core uses two programmable/selectable voltage levels (VR+ and VR−) to define the upper and lower limits of the conversion.
ADC10 Operation 18.2.2 ADC10 Inputs and Multiplexer The eight external and four internal analog signals are selected as the channel for conversion by the analog input multiplexer. The input multiplexer is a break-before-make type to reduce input-to-input noise injection resulting from channel switching as shown in Figure 18−2. The input multiplexer is also a T-switch to minimize the coupling between channels.
ADC10 Operation 18.2.3 Voltage Reference Generator The ADC10 module contains a built-in voltage reference with two selectable voltage levels. Setting REFON = 1 enables the internal reference. When REF2_5V = 1, the internal reference is 2.5 V. When REF2_5V = 0, the reference is 1.5 V. The internal reference voltage may be used internally and, when REFOUT = 0, externally on pin VREF+. External references may be supplied for VR+ and VR− through pins A4 and A3 respectively.
ADC10 Operation 18.2.5 Sample and Conversion Timing An analog-to-digital conversion is initiated with a rising edge of sample input signal SHI. The source for SHI is selected with the SHSx bits and includes the following: - The ADC10SC bit The Timer_A Output Unit 1 The Timer_A Output Unit 0 The Timer_A Output Unit 2 The polarity of the SHI signal source can be inverted with the ISSH bit. The SHTx bits select the sample period tsample to be 4, 8, 16, or 64 ADC10CLK cycles.
ADC10 Operation Sample Timing Considerations When SAMPCON = 0 all Ax inputs are high impedance. When SAMPCON = 1, the selected Ax input can be modeled as an RC low-pass filter during the sampling time tsample, as shown below in Figure 18−4. An internal MUX-on input resistance RI (max. 2 kΩ) in series with capacitor CI (max. 20 pF) is seen by the source. The capacitor CI voltage VC must be charged to within ½ LSB of the source voltage VS for an accurate 10-bit conversion. Figure 18−4.
ADC10 Operation 18.2.6 Conversion Modes The ADC10 has four operating modes selected by the CONSEQx bits as discussed in Table 18−1. Table 18−1.Conversion Mode Summary CONSEQx Mode Operation 00 Single channel single-conversion A single channel is converted once. 01 Sequence-ofchannels A sequence of channels is converted once. 10 Repeat single channel A single channel is converted repeatedly. 11 Repeat sequenceof-channels A sequence of channels is converted repeatedly.
ADC10 Operation Single-Channel Single-Conversion Mode A single channel selected by INCHx is sampled and converted once. The ADC result is written to ADC10MEM. Figure 18−5 shows the flow of the single-channel, single-conversion mode. When ADC10SC triggers a conversion, successive conversions can be triggered by the ADC10SC bit. When any other trigger source is used, ENC must be toggled between each conversion. Figure 18−5.
ADC10 Operation Sequence-of-Channels Mode A sequence of channels is sampled and converted once. The sequence begins with the channel selected by INCHx and decrements to channel A0. Each ADC result is written to ADC10MEM. The sequence stops after conversion of channel A0. Figure 18−6 shows the sequence-of-channels mode. When ADC10SC triggers a sequence, successive sequences can be triggered by the ADC10SC bit . When any other trigger source is used, ENC must be toggled between each sequence. Figure 18−6.
ADC10 Operation Repeat-Single-Channel Mode A single channel selected by INCHx is sampled and converted continuously. Each ADC result is written to ADC10MEM. Figure 18−7 shows the repeat-single-channel mode. Figure 18−7.
ADC10 Operation Repeat-Sequence-of-Channels Mode A sequence of channels is sampled and converted repeatedly. The sequence begins with the channel selected by INCHx and decrements to channel A0. Each ADC result is written to ADC10MEM. The sequence ends after conversion of channel A0, and the next trigger signal re-starts the sequence. Figure 18−8 shows the repeat-sequence-of-channels mode. Figure 18−8.
ADC10 Operation Using the MSC Bit To configure the converter to perform successive conversions automatically and as quickly as possible, a multiple sample and convert function is available. When MSC = 1 and CONSEQx > 0 the first rising edge of the SHI signal triggers the first conversion. Successive conversions are triggered automatically as soon as the prior conversion is completed.
ADC10 Operation 18.2.7 ADC10 Data Transfer Controller The ADC10 includes a data transfer controller (DTC) to automatically transfer conversion results from ADC10MEM to other on-chip memory locations. The DTC is enabled by setting the ADC10DTC1 register to a nonzero value. When the DTC is enabled, each time the ADC10 completes a conversion and loads the result to ADC10MEM, a data transfer is triggered.
ADC10 Operation One-Block Transfer Mode The one-block mode is selected if the ADC10TB is reset. The value n in ADC10DTC1 defines the total number of transfers for a block. The block start address is defined anywhere in the MSP430 address range using the 16-bit register ADC10SA. The block ends at ADC10SA+2n–2. The one-block transfer mode is shown in Figure 18−9. Figure 18−9.
ADC10 Operation Figure 18−10.
ADC10 Operation Two-Block Transfer Mode The two-block mode is selected if the ADC10TB bit is set. The value n in ADC10DTC1 defines the number of transfers for one block. The address range of the first block is defined anywhere in the MSP430 address range with the 16-bit register ADC10SA. The first block ends at ADC10SA+2n–2. The address range for the second block is defined as SA+2n to SA+4n–2. The two-block transfer mode is shown in Figure 18−11. Figure 18−11.
ADC10 Operation Figure 18−12.
ADC10 Operation Continuous Transfer A continuous transfer is selected if ADC10CT bit is set. The DTC will not stop after block one in (one-block mode) or block two (two-block mode) has been transferred. The internal address pointer and transfer counter are set equal to ADC10SA and n respectively. Transfers continue starting in block one.
ADC10 Operation 18.2.8 Using the Integrated Temperature Sensor To use the on-chip temperature sensor, the user selects the analog input channel INCHx = 1010. Any other configuration is done as if an external channel was selected, including reference selection, conversion-memory selection, etc. The typical temperature sensor transfer function is shown in Figure 18−13. When using the temperature sensor, the sample period must be greater than 30 µs.
ADC10 Operation 18.2.9 ADC10 Grounding and Noise Considerations As with any high-resolution ADC, appropriate printed-circuit-board layout and grounding techniques should be followed to eliminate ground loops, unwanted parasitic effects, and noise. Ground loops are formed when return current from the A/D flows through paths that are common with other analog or digital circuitry.
ADC10 Operation 18.2.10 ADC10 Interrupts One interrupt and one interrupt vector are associated with the ADC10 as shown in Figure 18−17. When the DTC is not used (ADC10DTC1 = 0) ADC10IFG is set when conversion results are loaded into ADC10MEM. When DTC is used (ADC10DTC1 > 0) ADC10IFG is set when a block transfer completes and the internal transfer counter ’n’ = 0. If both the ADC10IE and the GIE bits are set, then the ADC10IFG flag generates an interrupt request.
ADC10 Registers 18.3 ADC10 Registers The ADC10 registers are listed in Table 18−3. Table 18−3.
ADC10 Registers ADC10CTL0, ADC10 Control Register 0 15 14 13 12 SREFx 11 ADC10SHTx 10 9 8 ADC10SR REFOUT REFBURST rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 7 6 5 4 3 2 1 0 MSC REF2_5V REFON ADC10ON ADC10IE ADC10IFG ENC ADC10SC rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) Modifiable only when ENC = 0 SREFx Bits 15-13 Select reference 000 VR+ = VCC and VR− = VSS 001 VR+ = VREF+ and VR− = VSS 010 VR+ = VeREF+ and VR− = VSS 011 VR+ = VeRE
ADC10 Registers MSC Bit 7 Multiple sample and conversion. Valid only for sequence or repeated modes. 0 The sampling requires a rising edge of the SHI signal to trigger each sample-and-conversion. 1 The first rising edge of the SHI signal triggers the sampling timer, but further sample-and-conversions are performed automatically as soon as the prior conversion is completed REF2_5V Bit 6 Reference-generator voltage. REFON must also be set. 0 1.5 V 1 2.
ADC10 Registers ADC10CTL1, ADC10 Control Register 1 15 14 13 12 11 INCHx 10 SHSx 9 8 ADC10DF ISSH rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 7 6 5 4 3 2 1 0 ADC10DIVx rw−(0) rw−(0) ADC10SSELx rw−(0) rw−(0) rw−(0) ADC10 BUSY CONSEQx rw−(0) rw−(0) r−0 Modifiable only when ENC = 0 INCHx Bits 15-12 Input channel select. These bits select the channel for a single-conversion or the highest channel for a sequence of conversions.
ADC10 Registers ADC10DIVx Bits 7-5 ADC10 clock divider 000 /1 001 /2 010 /3 011 /4 100 /5 101 /6 110 /7 111 /8 ADC10 SSELx Bits 4-3 ADC10 clock source select 00 ADC10OSC 01 ACLK 10 MCLK 11 SMCLK CONSEQx Bits 2-1 Conversion sequence mode select 00 Single-channel-single-conversion 01 Sequence-of-channels 10 Repeat-single-channel 11 Repeat-sequence-of-channels ADC10 BUSY Bit 0 ADC10 busy. This bit indicates an active sample or conversion operation 0 No operation is active.
ADC10 Registers ADC10MEM, Conversion-Memory Register, Binary Format 15 14 13 12 11 10 9 8 0 0 0 0 0 0 r0 r0 r0 r0 r0 r0 r r 7 6 5 4 3 2 1 0 r r r Conversion Results Conversion Results r Conversion Results r Bits 15-0 r r r The 10-bit conversion results are right justified, straight-binary format. Bit 9 is the MSB. Bits 15-10 are always 0.
ADC10 Registers ADC10DTC0, Data Transfer Control Register 0 7 6 5 4 Reserved r0 r0 r0 3 2 1 0 ADC10TB ADC10CT ADC10B1 ADC10 FETCH rw−(0) rw−(0) rw−(0) rw−(0) r0 Reserved Bits 7-4 Reserved. Always read as 0. ADC10TB Bit 3 ADC10 two-block mode. 0 One-block transfer mode 1 Two-block transfer mode ADC10CT Bit 2 ADC10 continuous transfer. 0 Data transfer stops when one block (one-block mode) or two blocks (two-block mode) have completed. 1 Data is transferred continuously.
ADC10 Registers ADC10DTC1, Data Transfer Control Register 1 7 6 5 4 3 2 1 0 rw−(0) rw−(0) rw−(0) DTC Transfers rw−(0) DTC Transfers rw−(0) Bits 7-0 rw−(0) rw−(0) rw−(0) DTC transfers. These bits define the number of transfers in each block.
18-32 ADC10
Chapter 19 () . The DAC12 module is a 12-bit, voltage output digital-to-analog converter. This chapter describes the DAC12. Two DAC12 modules are implemented in the MSP430x15x and MSP430x16x devices. Topic Page 19.1 DAC12 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-2 19.2 DAC12 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-4 19.3 DAC12 Registers . . . . . . . . . . . . . . . . . . . . . . . .
DAC12 Introduction 19.1 DAC12 Introduction The DAC12 module is a 12-bit, voltage output DAC. The DAC12 can be configured in 8- or 12-bit mode and may be used in conjunction with the DMA controller. When multiple DAC12 modules are present, they may be grouped together for synchronous update operation.
DAC12 Introduction Figure 19−1. DAC12 Block Diagram Ve REF+ VREF+ To ADC12 module 2.5V or 1.
DAC12 Operation 19.2 DAC12 Operation The DAC12 module is configured with user software. The setup and operation of the DAC12 is discussed in the following sections. 19.2.1 DAC12 Core The DAC12 can be configured to operate in 8- or 12-bit mode using the DAC12RES bit. The full-scale output is programmable to be 1x or 3x the selected reference voltage via the DAC12IR bit. This feature allows the user to control the dynamic range of the DAC12.
DAC12 Operation 19.2.2 DAC12 Reference The reference for the DAC12 is configured to use either an external reference voltage or the internal 1.5-V/2.5-V reference from the ADC12 module with the DAC12SREFx bits. When DAC12SREFx = {0,1} the VREF+ signal is used as the reference and when DAC12SREFx = {2,3} the VeREF+ signal is used as the reference. To use the ADC12 internal reference, it must be enabled and configured via the applicable ADC12 control bits (see the ADC12 chapter).
DAC12 Operation 19.2.4 DAC12_xDAT Data Format The DAC12 supports both straight binary and 2’s compliment data formats. When using straight binary data format, the full-scale output value is 0FFFh in 12-bit mode (0FFh in 8-bit mode) as shown in Figure 19−2. Figure 19−2.
DAC12 Operation 19.2.5 DAC12 Output Amplifier Offset Calibration The offset voltage of the DAC12 output amplifier can be positive or negative. When the offset is negative, the output amplifier attempts to drive the voltage negative, but cannot do so. The output voltage remains at zero until the DAC12 digital input produces a sufficient positive output voltage to overcome the negative offset voltage, resulting in the transfer function shown in Figure 19−4. Figure 19−4.
DAC12 Operation 19.2.6 Grouping Multiple DAC12 Modules Multiple DAC12s can be grouped together with the DAC12GRP bit to synchronize the update of each DAC12 output. Hardware ensures that all DAC12 modules in a group update simultaneously independent of any interrupt or NMI event. On the MSP430x15x and MSP430x16x devices, DAC12_0 and DAC12_1 are grouped by setting the DAC12GRP bit of DAC12_0. The DAC12GRP bit of DAC12_1 is don’t care.
DAC12 Operation 19.2.7 DAC12 Interrupts The DAC12 interrupt vector is shared with the DMA controller. Software must check the DAC12IFG and DMAIFG flags to determine the source of the interrupt. The DAC12IFG bit is set when DAC12LSELx > 0 and DAC12 data is latched from the DAC12_xDAT register into the data latch. When DAC12LSELx = 0, the DAC12IFG flag is not set. A set DAC12IFG bit indicates that the DAC12 is ready for new data.
DAC12 Registers 19.3 DAC12 Registers The DAC12 registers are listed in Table 19−2: Table 19−2.
DAC12 Registers DAC12_xCTL, DAC12 Control Register 15 14 Reserved 13 DAC12SREFx 12 11 DAC12RES 10 DAC12LSELx 9 8 DAC12 CALON DAC12IR rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) 7 6 5 4 3 2 1 0 DAC12DF DAC12IE DAC12IFG DAC12ENC DAC12 GRP rw−(0) rw−(0) rw−(0) rw−(0) rw−(0) DAC12AMPx rw−(0) rw−(0) rw−(0) Modifiable only when DAC12ENC = 0 Reserved Bit 15 Reserved DAC12 SREFx Bits 14-13 DAC12 select reference voltage 00 VREF+ 01 VREF+ 10 VeREF+ 11 VeR
DAC12 Registers DAC12 AMPx Bits 7-5 DAC12 amplifier setting. These bits select settling time vs. current consumption for the DAC12 input and output amplifiers.
DAC12 Registers DAC12_xDAT, DAC12 Data Register 15 14 13 12 11 0 0 0 0 r(0) r(0) r(0) r(0) rw−(0) 7 6 5 4 10 9 8 rw−(0) rw−(0) rw−(0) 3 2 1 0 rw−(0) rw−(0) rw−(0) rw−(0) DAC12 Data DAC12 Data rw−(0) Unused rw−(0) Bits 15-12 DAC12 Data Bits rw−(0) rw−(0) Unused. These bits are always 0 and do not affect the DAC12 core. DAC12 data 11-0 DAC12 Data Format DAC12 Data 12-bit binary The DAC12 data are right-justified. Bit 11 is the MSB.
19-14 DAC12