Users G u ide
2 00 5
M i e d S i n al Po d u c ts x g r
SLAU049E
I n dex
Section Title Page
1 MSP430 Architecture 1 1.1 Address Space.. 3 1.2 Operating Modes. 5 1.3 Status Register (SR).... 8 1.4 Addressing Modes... 9 1.5 Instruction Set...... 17 2 Basic clock Module. 18 2.1 Adjusting the DCO.. 21 2.2 Registers... ...... 23 3 Flash Memory... 25 4 Hardware Multiplier.. 30 5 DMA Controller 32 6 Digital I/O Register... 39 7 Watchdog Timer... 40 8 Timer A... 42 9 Timer B.. 49 10 USART (UART Mode)... ............... 56 11 USART (SPI Mode).. 64 12 Comparator A. 70 13 ADC12... 76 14 DAC12... 87 15 Special Function Registers 15.1 Interrupt Vector Address... 93 15.2 IE1, IE2, IFG1, IFG2 Registers.... 94 15.3 ME1, ME2 Registers.. 95 16 Reference Data sheets 16.1 Timer A Input Pin Details. 96 16.2 DS 1307 Datasheet 97 16.3 MSP430F14x Pin Diagram... 101
12-bit or 10-bit ADC 200 ksps, temperature sensor, VRef J Comparator-gated timers for measuring resistive elements J
12-bit dual-DAC
J
16-bit RISC CPU enables new applications at a fraction of the code size.
J Large register file eliminates working file bottleneck J Compact core design reduces power consumption and cost J
Introduction
Embedded Emulation
Clock System
MCLK
ACLK SMCLK
Flash/ ROM
RAM
Peripheral
Peripheral
Peripheral
MAB 16-Bit
Bus Conv.
MDB 8-Bit
JTAG
ACLK SMCLK
Watchdog
Peripheral
Peripheral
Peripheral
Peripheral
application.
Introduction
Address Space
Flash/ROM
Word/Byte
0200h 01FFh
RAM
Word/Byte
16-Bit Peripheral Modules 0100h 0FFh 010h 0Fh 0h 8-Bit Peripheral Modules Special Function Registers
1.4.1
Flash/ROM
The start addr ess of Flash /ROM depends on t he a mount of Flash /ROM present and varies by device. The end address for Flash/ROM is 0FFFFh. Flash can be used for both code and data. W ord or byte tables can be stored and used in Flash/ROM without the need to copy the tables to RAM before using them. The interrupt vector table is mapped into the upper 16 words of Flash/ROM address space, with the highest priority interrupt vector at the highest Flash/ROM word address (0FFFEh).
1.4.2
RAM
RAM starts at 0200h. The end address of RAM depends on the amount of RAM present and varies by device. RAM can be used for both code and data.
Introduction
O p eratin g M ode s
2.3 Operating Modes
The MSP430 family is designed for ultralow-power applications and uses different operating modes shown in Figure 210. The operating modes take into account three different needs: Ultralow-power
- S peed and data through put - Minimization of individual peripheral current consumption
Figure 29. Typical Current Consumption of 13x and 14x Devices vs Operating Modes
340 225 VCC = 3 V VCC = 2.2 V 70 65 17 11 AM LPM0 2 1 0.10. 1 LPM4
The low-power modes 04 are configured with the CPUOFF, OSCOFF, SCG0, and SCG1 bits in the status register The advantage of including the CPUOFF, OSCOFF, SCG0, and SCG1 mode-control bits in the status register is that the present operating mode is saved onto the stack during an interrupt service routine. Program flow returns to the previous operating mode if the saved SR value is not altered during the interrupt service routine. Program flow can be returned to a different operating mode by manipulating the saved SR value on the stack inside of the interrupt service routine. The mode-control bits and the stack can be accessed with any instruction. When setting any of the mode-control bits, the selected operating mode takes effect immediately. Peripherals operating with any disabled clock are disabled until the clock becomes active. The peripherals may also be disabled with their individual control register settings. All I/O port pins and RAM/registers are unchanged. W ake up is possible through all enabled interrupts.
Operating Modes
VCC On
POR WDTIFG = 1 WDTIFG = 1 WDTIFG = 0 PUC RST/NMI is Reset Pin WDT is Active RST/NMI NMI Active
CPUOFF = 1 SCG0 = 0 SCG1 = 0 LPM0 CPU Off, MCLK Off, SMCLK On, ACLK On CPUOFF = 1 SCG0 = 1 SCG1 = 0 LPM1 CPU Off, MCLK Off, SMCLK On, ACLK On DC Generator Off if DCO not used in active mode
CPUOFF = 1 OSCOFF = 1 SCG0 = 1 SCG1 = 1 LPM4 CPU Off, MCLK Off, DCO Off, ACLK Off DC Generator Off
LPM2 CPU Off, MCLK Off, SMCLK Off, DCO Off, ACLK On
LPM3 CPU Off, MCLK Off, SMCLK Off, DCO Off, ACLK On DC Generator Off
SCG1 0 0 0
CPU and Clocks Status CPU is active, all enabled clocks are active CPU, MCLK are disabled SMCLK , ACLK are active CPU, MCLK, DCO osc. are disabled DC generator is disabled if the DCO is not used for MCLK or SMCLK in active mode SMCLK , ACLK are active CPU, MCLK, SMCLK, DCO osc. are disabled DC generator remains enabled ACLK is active CPU, MCLK, SMCLK, DCO osc. are disabled DC generator disabled ACLK is active CPU and all clocks disabled
LPM2
LPM3
LPM4
CPU Introduction
addressing mode.
- Full register access including program counter, status registers, and stack
pointer.
- Si ngle- cycle reg ister o peratio ns. - Large 16-bit register file reduces fetches to memor y. - 16-bit address bus allows direct access and branching throughout entire
memory range.
- 16-bit data bus allows direct manipulation of word-wide arguments. - Constant generator provides six m ost used immediate values and
Word and byte addressing and instruction formats. The block diagram of the CPU is shown in Figure 31.
CPU Introduction
CPU Registers
3.2.3
SUB(.B),SUBC(.B),CMP(.B)
System clock generator 1. This bit, when set, turns off the SMCLK. System clock generator 0. This bit, when set, turns off the DCO dc generator, if DCOCLK is not used for MCLK or SMCLK. Oscillator Off. This bit, when set, turns off the LFXT1 crystal oscillator, when LFXT1CLK is not use for MCLK or SMCLK CPU off. This bit, when set, turns off the CPU. General interrupt enable. This bit, when set, enables maskable interrupts. When reset, all maskable interrupts are disabled. Negative bit. This bit is set when the result of a byte or word operation is negative and cleared when the result is not negative. Word operation: N is set to the value of bit 15 of the result Byte operation: N is set to the value of bit 7 of the result Zero bit. This bit is set when the result of a byte or word operation is 0 and cleared when the result is not 0. Carry bit. This bit is set when the result of a byte or word operation produced a carry and cleared when no carry occurred.
Z C
A d dressin g Mod e s
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 33 describe the contents of the As (source) and Ad (destination) mode bits.
01/1
Absolute mode
&ADDR
10/ 11/
@Rn @Rn+
11/
Immediate mode
#N
The seven addressing modes are explained in detail in the following sections. Most of the examples show the same addressing mode for the source and destination, but any valid combination of source and destination addressing modes is possible in an instruction. Note: Use of Labels EDE, TONI, TOM, and LEO Throughout MSP430 documentation EDE, TONI, TOM, and LEO are used as generic labels. They are only labels. They have no special meaning.
Addressing Modes
3.3.1
Register Mode
The register mode is described in Table 34.
One or two words Move the content of R10 to R11. R10 is not affected. Valid for source and destination MOV R10,R11
After: R10 0A023h
R11
0FA15h
R11
0A023h
PC
PCold
PC
PCold + 2
Note: Data in Registers The data in the register can be accessed using word or byte instructions. If byte instructions are used, the high byte is always 0 in the result. The status bits are handled according to the result of the byte instruction.
10
Addressing Modes
3.3.2
Indexed Mode
The indexed mode is described in Table 35.
Length: Operation:
Two or three words 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. In index ed m ode, the p ro gram co unter is increme nted automatically so that program execution continues with the next instruction. Valid for source and destination MOV 2(R5),6(R6);
Register After: Address Space 0xxxxh 00006h 00002h 04596h Register PC R5 01080h R6 0108Ch
Comment: Example:
Before: Address Space 00006h 00002h
R5 R6
01080h 0108Ch
11
Addressing Modes
3.3.3
Symbolic Mode
The symbolic mode is described in Table 36.
Length: Operation:
Two or three words 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. The assembler computes and inserts offsets X and Y automatically. W ith symbolic mode, the program counter (PC) is incremented automatically so that program execution continues with the next instruction. Valid for source and destination MOV
Address Space 011FEh 0F102h 04090h PC 0FF14h +0F102h 0F016h
Comment: Example:
Before:
12
Addressing Modes
3.3.4
Absolute Mode
The absolute mode is described in Table 37.
Length: Operation:
Two or three words 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. W ith absolute mode, the PC is incremented automatically so that program execution continues with the next instruction. Valid for source and destination MOV
Address Space 01114h 0F016h 04292h PC
Comment: Example:
Before:
This address mode is mainly for hardware peripheral modules that are located at an absolute, fixed address. These are addressed with absolute mode to ensure software transportability (for example, position-independent code).
13
Addressing Modes
3.3.5
Length: Operation:
One or two words Move the contents of the source address (contents of R10) to the destination address (contents of R11). The registers are not modified. Valid only for source operand. The substitute for destination operand is 0(Rd). MOV.B @R10,0(R11)
Register After: Address Space 0xxxxh 0FF16h 0000h 0FF14h 0FF12h 04AEBh 0xxxxh Register PC R10 0FA33h R11 002A7h
Comment: Example:
Before: Address Space 0xxxxh 0000h 04AEBh 0xxxxh
R10 PC R11
0FA33h 002A7h
14
Addressing Modes
3.3.6
Length: Operation:
One or two words Move the contents of the source address (contents of R10) to the destination address (contents of R11). Register R10 is i ncrem ent ed by 1 f or a byte opera tion, or 2 f or a w ord operation after the fetch; it points to the next address without any overhead. This is useful for table processing. Valid only for source operand. The substitute for destination operand is 0(Rd) plus second instruction INCD Rd. MOV @R10+,0(R11)
Register After: Address Space 0xxxxh 00000h 04ABBh 0xxxxh PC R10 0FA34h R11 010A8h Register
Comment: Example:
Before: Address Space
R10 PC R11
0FA32h 010A8h
The autoincrem enting of the register contents occurs after the operand is fetched. This is shown in Figure 38.
15
Addressing Modes
3.3.7
Immediate Mode
The immediate mode is described in Table 310.
Length: Operation:
Two or three words It is one word less if a constant of CG1 or CG2 can be used. Move the immediate constant 45h, which is contained in the word following the instruction, to destination address TONI. When fetching the source, the program counter points to the word following the instruction and moves the contents to the destination. Valid only for a source operand. MOV
Address Space 01192h 00045h 040B0h PC 0FF16h +01192h 010A8h
Comment: Example:
Before:
#45h,TONI
Register After: 0FF18h 0FF16h 0FF14h 0FF12h Address Space 0xxxxh 01192h 00045h 040B0h Register PC
16
Instr uction S et
Table 317.MSP430 Instruction Set
Mnemonic ADC(.B) ADDC(.B) AND(.B) BIC(.B) BIS(.B) BR BIT(.B) ADD(.B) dst src,dst src,dst src,dst src,dst src,dst dst dst dst src,dst Description Add C to destination Add source to destination Add source and C to destination AND source and destination Clear bits in destination Set bits in destination Test bits in destination Branch to destination Call destination Clear destination Clear C Clear N Clear Z dst dst dst src,dst src,dst Compare source and destination Add C decimally to destination Add source and C decimally to dst. Decrement destination Double-decrement destination Disable interrupts Enable interrupts dst dst dst label label label label label label label src,dst dst src label Increment destination Double-increment destination Invert destination Jump if C set/Jump if higher or same Jump if equal/Jump if Z set Jump if greater or equal Jump if less Jump Jump if N set Jump if C not set/Jump if lower Jump if not equal/Jump if Z not set Move source to destination No operation Pop item from stack to destination Push source onto stack Return from subroutine Return from interrupt dst dst dst dst dst Rotate left arithmetically Rotate left through C Rotate right arithmetically Rotate right through C Subtract not(C) from destination Set C Set N Set Z src,dst dst dst dst src,dst src,dst Subtract source from destination Subtract source and not(C) from dst. Swap bytes Extend sign Test destination Exclusive OR source and destination dst + 0FFFFh + 1 src .xor. dst dst dst + 0FFFFh + C dst 1C 1N 1C dst + .not.src + 1 dst dst + .not.src + C dst @SP dst, SP+2 SP SP 2 SP, src @SP @SP PC, SP + 2 SP src dst PC + 2 x offset PC dst + C dst src + dst dst src + dst + C dst src .and. dst dst .not.src .and. dst dst src .or. dst dst src .and. dst dst PC PC+2 stack, dst PC 0 dst 0C 0N 0Z dst src dst + C dst (decimally) src + dst + C dst (decimally) dst 1 dst dst 2 dst 0 GIE 1 GIE dst +1 dst dst+2 dst .not.dst dst V * * * 0 0 * * * * * * * * * * * 0 * * * * 0 0 * N * * * * * 0 * * * * * * * * * * * * * * 1 * * * * * Z * * * * * 0 * * * * * * * * * * * * * * 1 * * * * * C * * * * * 0 * * * * * * * * * * * * * * 1 * * * 1 *
CALL
DECD(.B)
INC(.B)
JGE JMP JN JL
NOP
RETI
RET
PUSH(.B)
SBC(.B) SET
SWPB SXT
SUBC(.B)
SUB(.B)
TST(.B) XOR(.B)
Emulated Instruction
17
either with low-frequency 32768-Hz watch crystals, or standard crystals or resonators in the 450-kHz to 8-MHz range.
standard crystals, resonators, or external clock sources in the 450-kHz to 8-MHz range. characteristics.
Three clock signals are available from the basic clock module:
- ACLK: Auxiliary clock. The ACLK is the buffered LFXT1CLK clock source
d ivi ded by 1 , 2 , 4, or 8. ACL K is so ftw are selectable for i ndiv idual peripheral modules.
XT2CLK (if available), or DCOCLK. MCLK is divided by 1, 2, 4, or 8. MCLK is used by the CPU and system.
XT2CLK (if available on-chip), or DCOCLK. SMCLK is divided by 1, 2, 4, or 8. SMCLK is software selectable for individual peripheral modules.
The block diagram of the basic clock module is shown in Figure 41.
18
Divider /1/2/4/8
XIN
0V
12pF LF 12pF LFOff XT XT1Off SELMx DIVMx 00 XT2CLK 01 10 11 Divider /1/2/4/8 0 1 MCLK CPUOFF
XOUT
0V LFXT1 Oscillator
XT2OFF XT2IN XT
XT2OUT
0 1 P2.5/Rosc
off
DC
Generator
n DCO n+1
0 1
Divider /1/2/4/8
0 1 SMCLK
Note:
XT2 Oscillator
The XT2 Oscillator is not present on MSP430x11xx or MSP430x12xx devices. The LFXT1CLK is used in place of XT2CLK.
19
Set
max
DCO
frequency
4.2.1
capability
The basic clock module addresses the above conflicting requirements by allowing the user to select from the three available clock signals: ACLK, MCLK, and SMCLK. For optimal low-power performance, the ACLK can be configured to oscillate with a low-power 32,786-Hz watch crystal, providing a stable time base for the system and low power stand-by operation. The MCLK can be configured to operate from the on-chip DCO that can be only activated when requested by interrupt-driven events. The SMCLK can be configured to operate from a crystal or the DCO, depending on peripheral requirements. A flex ible c lock di stribution and div ider system is provided to fine tune the individual clock requirements.
20
resistor defines the fundamental frequenc y. The DCOR bit selects the internal or external resistor.
- The three RSELx bits select one of eight nominal frequency ranges for the
DCO. These ranges are de fined for an ind ividual device in t he device-specific data sheet.
- The three DCOx bits divide the DCO range selected by the RSELx bits into
- The five MODx bits, switch between the frequency selected by the DCOx
bits and the next higher frequency set by DCOx+1. W hen DCOx = 07h, the MODx bits have no effect because the DCO is already at the highest setting for the selected RSELx range.
DCO=0
DCO=1
DCO=2
DCO=3
DCO=4
DCO=5
DCO=6
DCO=7
21
4.2.6
V CC software enables OSC XT1OFF/ XT2OFF LFXT1CLK/ XT2CLK 50 us XT_OscFault 50 us 50 us software disables OSC
OSC faults
22
DCOx MODx
DCO frequency select. These bits select which of the eight discrete DCO frequencies of the RSELx setting is selected. 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 (32MOD) the fDCO frequency is used. Not useable when DCOx=7.
XT2OFF
Bit 7
XT2 off. This bit turns off the XT2 oscillator 0 XT2 is on 1 XT2 is off if it is not used for MCLK or SMCLK. LFXT1 mode select. 0 Low frequency mode 1 High frequency mode Divider for ACLK 00 /1 01 /2 10 /4 11 /8 Unused. XT5V should always be reset. Resistor Select. The internal resistor is selected in eight different steps. The value of the resistor defines the nominal frequency. The lowest nominal frequency is selected by setting RSELx=0.
XTS
Bit 6
DIVAx
Bits 5-4
XT5V RSELx
23
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 Divider for MCLK 00 /1 01 /2 10 /4 11 /8 Select SMCLK. This bit selects the SMCLK source. 0 DCOCLK 1 XT2CLK when XT2 oscillator present on-chip. LFXT1CLK when XT2 oscillator not present on-chip. Divider for SMCLK 00 /1 01 /2 10 /4 11 /8 DCO resistor select 0 Internal resistor 1 External resistor
DIVMx
BitS 5-4
SELS
Bit 3
DIVSx
BitS 2-1
DCOR
Bit 0
24
The block diagram of the flash memory and controller is shown in Figure 51. Note: Minimum VCC During Flash Write or Erase The minimum VCC voltage during a flash write or erase operation is 2.7 V. If VCC falls below 2.7 V during a write or erase, the result of the write or erase will be unpredictable.
MAB
FCTL1
FCTL2
FCTL3
Timing Generator
25
1000h
26
7 BLKWRT rw0
6 WRT rw0
5 Reserved r0
4 Reserved r0
3 Reserved r0
2 MERAS rw0
1 ERASE rw0
0 Reserved r0
FCTLx password. Always read as 096h. Must be written as 0A5h or a PUC will be generated. Block write mode. W RT must also be set for block write mode. BLKW RT is automatically reset when EMEX is set. 0 Block-write mode is off 1 Block-write mode is on W rite. This bit is used to select any write mode. W RT is automatically reset when EMEX is set. 0 Write mode is off 1 Write mode is on Reserved. Always read as 0. Mass erase and erase. These bits are used together to select the erase mode. MERAS and ERASE are automatically reset when EMEX is set.
MERAS ERASE 0 0 1 1 0 1 0 1 No erase Erase individual segment only Erase all main memory segments Erase all main and information memory segments Erase Cycle
WRT
Bit 6
Reserved
Bit 0
27
7 FSSELx rw0
3 FNx
rw1
rw-0
rw-0
rw-0
rw0
rw-1
rw0
FWKEYx FSSELx
FCTLx password. Always read as 096h. Must be written as 0A5h or a PUC will be generated. Flash controller clock source select 00 ACLK 01 MCLK 10 SMCLK 11 SMCLK Flash controller clock divider. These six bits select the divider for the flash controller clock. The divisor value is FNx + 1. For example, when FNx=00h, the divisor is 1. W hen FNx=03Fh the divisor is 64.
FNx
Bits 5-0
28
7 Reserved r0
6 Reserved r0
5 EMEX rw-0
4 LOCK rw-1
3 WAIT r-1
2 ACCVIFG rw0
1 KEYV rw-(0)
0 BUSY r(w)0
FCTLx password. Always read as 096h. Must be written as 0A5h or a PUC will be generated. Reserved. Always read as 0. Emergency exit 0 No emergency exit 1 Emergency exit Lock. This bit unlocks the flash memory for writing or erasing. The LOCK bit c an be set a nytime during a byte/word write or erase opera tion and the operation will complete normally. In the block write mode if the LOCK bit is set while BLKW RT=W AIT=1, then BLKW RT and W AIT are reset and the mode ends normally. 0 Unlocked 1 Locked Wait. Indicates the flash memory is being written to. 0 The flash memory is not ready for the next byte/word write 1 The flash memory is ready for the next byte/word write Access violation interrupt flag 0 No interrupt pending 1 Interrupt pending Flash security key violation. This bit indicates an incorrect FCTLx password was written to any flash control register and generates a PUC when set. KEYV must be reset with software. 0 FCTLx password was written correctly 1 FCTLx password was written incorrectly Busy. This bit indicates the status of the flash timing generator. 0 Not Busy 1 Busy
LOCK
Bit 4
WAIT
Bit 3
ACCVIFG
Bit 2
KEYV
Bit 1
BUSY
Bit 0
29
ACCVIE Bit 5 Flash memory access violation interrupt enable bit is avilable in IE1
MPY = 0000
32bit Multiplexer
SUMEXT 13Eh 15 r 0
S 31
RESHI 13Ch rw
RESLO 13Ah rw 0
30
Hardware Multiplier
7.2.1
Operand Registers
The operand one register OP1 has four addresses, shown in Table 71, used to select the multiply mode. Writing the first operand to the desired address selects the type of multiply operation but does not start any operation. W riting the second operand to the operand two register OP2 initiates the multiply operation. Writing OP2 starts the selected operation with the values stored in OP1 and OP2. The result is written into the three result registers RESLO, RESHI, and SUMEXT. Repeated multiply operations may be performed without reloading OP1 if the OP1 value is used for successive operations. It is not necessary to re-write the OP1 value to perform the operations.
Hardware Multiplier
31
DMAEN
DMA1TSELx 4 DMAREQ TACCR2_CCIFG TBCCR2_CCIFG USART0 data received USART0 transmit ready DAC12_0IFG ADC12IFGx TACCR0_CCIFG TBCCR0_CCIFG USART1 data received USART1 transmit ready Multiplier ready No trigger No trigger DMA0IFG DMAE0 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1110 1111 DMADSTINCRx DMADTx DMADSTBYTE 3 DMA Channel 1 DMA1SA DMA1DA DMA1SZ 2 DMASRSBYTE DMASRCINCRx DT
Address Space
DMAEN
DMA2TSELx 4 DMAREQ TACCR2_CCIFG TBCCR2_CCIFG USART0 data received USART0 transmit ready DAC12_0IFG ADC12IFGx TACCR0_CCIFG TBCCR0_CCIFG USART1 data received USART1 transmit ready Multiplier ready No trigger No trigger DMA1IFG DMAE0 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1110 1111 2
DMASRSBYTE DMASRCINCRx
DMAEN
32
8.2.1
The addressing modes are configured with the DMASRCINCRx and DMADSTINCRx control bits. The DMASRCINCRx bits select if the source address is incremented, decremented, or unchanged after each transfer. The DMADSTINCRx bits select if the destination address is incremented, decremented, or unchanged after each transfer. Transfers may be byte-to-byte, word-to-word, byte-to-word, or word-to-byte. When t ransf erri ng w ord- to-byte, only t he low er byte of t he s ource-w ord transfers. W hen transferring byte-to-word, the upper byte of the destination-word is cleared when the transfer occurs.
DMA Controller
Address Space
DMA Controller
Address Space
DMA Controller
Address Space
DMA Controller
Address Space
33
8.2.2
001
Block transfer
010, 011
Burst-block transfer Repeated single transfer Repeated block transfer Repeated burst-block transfer
34
6 DMA1TSELx
2 DMA0TSELx
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
Reserved DMA trigger select. These bits select the DMA transfer trigger. 0000 DMAREQ bit (software trigger) 0001 TACCR2 CCIFG bit 0010 TBCCR2 CCIFG bit 0011 URXIFG0 (UART/SPI mode), USART0 data received (I2C mode) 0100 UTXIFG0 (UART/SPI mode), USART0 transmit ready (I2C mode) 0101 DAC12_0CTL DAC12IFG bit 0110 ADC12 ADC12IFGx bit 0111 TACCR0 CCIFG bit 1000 TBCCR0 CCIFG bit 1001 URXIFG1 bit 1010 UTXIFG1 bit 1011 Multiplier ready 1100 No action 1101 No action 1110 DMA0IFG bit triggers DMA channel 1 DMA1IFG bit triggers DMA channel 2 DMA2IFG bit triggers DMA channel 0 1111 External trigger DMAE0 Same as DMA2TSELx Same as DMA2TSELx
35
7 0 r0
6 0 r0
5 0 r0
4 0 r0
3 0 r0
0 ENNMI rw(0)
Reserved. Read only. Always read as 0. DMA on fetch 0 The DMA transfer occurs immediately 1 The DMA transfer occurs on next instruction fetch after the trigger Round robin. This bit enables the round-robin DMA channel priorities. 0 DMA channel priority is DMA0 DMA1 DMA2 1 DMA channel priority changes with each transfer Enable NMI. This bit enables the interruption of a DMA transfer by an NMI interrupt. W hen an NMI interrupts a DMA transfer, the current transfer is completed normally, further transfers are stopped, and DMAABORT is set. 0 NMI interrupt does not interrupt DMA transfer 1 NMI interrupt interrupts a DMA transfer
Bit 1
Bit 0
36
5 DMALEVEL rw(0)
4 DMAEN rw(0)
3 DMAIFG rw(0)
2 DMAIE rw(0)
0 DMAREQ rw(0)
Reserved DMADTx
Reserved DMA Transfer mode. 000 Single transfer 001 Block transfer 010 Burst-block transfer 011 Burst-block transfer 100 Repeated single transfer 101 Repeated block transfer 110 Repeated burst-block transfer 111 Repeated burst-block transfer DMA destination increment. This bit selects automatic incrementing or decrementing of the destination address after each byte or word transfer. W hen DMADSTBYTE=1, the destination address increments/decrements by one. W hen DMADSTBYTE=0, the destination address increments/decrements by two. The DMAxDA is copied into a temporary register and the temporary register is incremented or decremented. DMAxDA is not incremented or decremented. 00 Destination address is unchanged 01 Destination address is unchanged 10 Destination address is decremented 11 Destination address is incremented DMA source increment. This bit selects automatic incrementing or decrementing of the source address for each byte or word transfer. W hen DMASRCBYTE=1, the source address increments/decrements by one. W hen DMASRCBYTE=0, the source address increments/decrements by two. The DMAxSA is copied into a temporary register and the temporary register is increm ented or decrem ented. DMAxSA is not increm ented or decremented. 00 Source address is unchanged 01 Source address is unchanged 10 Source address is decremented 11 Source address is incremented DMA destination byte. This bit selects the destination as a byte or word. 0 Word 1 Byte
DMA DSTINCRx
Bits 1110
DMA SRCINCRx
Bits 98
DMA DSTBYTE
Bit 7
37
Bit 6
DMA source byte. This bit selects the source as a byte or word. 0 Word 1 Byte DMA level. This bit selects between edge-sensitive and level-sensitive triggers. 0 Edge sensitive (rising edge) 1 Level sensitive (high level) DMA enable 0 Disabled 1 Enabled DMA interrupt flag 0 No interrupt pending 1 Interrupt pending DMA interrupt enable 0 Disabled 1 Enabled DMA Abort. This bit indicates if a DMA transfer was interrupt by an NMI. 0 DMA transfer not interrupted 1 DMA transfer was interrupted by NMI DMA request. Software-controlled DMA start. DMAREQ is reset automatically. 0 No DMA start 1 Start DMA
Bit 5
DMAEN
Bit 4
DMAIFG
Bit 3
DMAIE
Bit 2
Bit 1
Bit 0
4 DMAxSAx
rw
rw
rw
rw
rw
rw
rw
rw
DMA source address. The source address register points to the DMA source address for single transfers or the first source address for block transfers. The source address register remains unchanged during block and burst-block transfers.
38
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 91.
Direction Interrupt Flag Interrupt Edge Select Interrupt Enable Port Select
P2
Input Output Direction Interrupt Flag Interrupt Edge Select Interrupt Enable Port Select
P3
P4
P5
P6
Digital I/O
39
Watchdog T im er Introduction
Figure 101. Watchdog Timer Block Diagram
WDTCTL 4 Int. Flag WDTQn Y 3 2 1 Pulse Generator A B Clear (Asyn) CLK Q6 0 Q9 Q13 Q15 16bit Counter 1 0 1 1 0 1 0 EQU Write Enable Low Byte 16bit Password Compare MSB MDB
PUC
EQU
R/W
SMCLK ACLK
1 1 A EN
Watchdog Timer
40
7 WDTHOLD rw0
6 WDTNMIES rw0
5 WDTNMI rw0
4 WDTTMSEL rw0
3 WDTCNTCL r0(w)
2 WDTSSEL rw0
1 WDTISx rw0
rw0
WDTPW WDTHOLD
Watchdog timer password. Always read as 069h. Must be written as 05Ah, or a PUC will be generated. Watchdog timer hold. This bit stops the watchdog timer. Setting W DTHOLD = 1 when the W DT is not in use conserves power. 0 Watchdog timer is not stopped 1 Watchdog timer is stopped W atchdog timer NMI edge select. This bit selects the interrupt edge for the NMI interrupt when W DTNMI = 1. Modifying this bit can trigger an NMI. Modify this bit when W DTNMI = 0 to avoid triggering an accidental NMI. 0 NMI on rising edge 1 NMI on falling edge Watchdog timer NMI select. This bit selects the function for the RST/NMI pin. 0 Reset function 1 NMI function Watchdog timer mode select 0 Watchdog mode 1 Interval timer mode Watchdog timer counter clear. Setting W DTCNTCL = 1 clears the count value to 0000h. W DTCNTCL is automatically reset. 0 No action 1 WDTCNT = 0000h Watchdog timer clock source select 0 SMCLK 1 ACLK Watchdog timer interval select. These bits select the watchdog timer interval to set the W DTIFG flag and/or generate a PUC. 00 Watchdog clock source /32768 01 Watchdog clock source /8192 10 Watchdog clock source /512 11 Watchdog clock source /64
WDTNMIES
Bit 6
WDTNMI
Bit 5
WDTTMSEL
Bit 4
WDTCNTCL
Bit 3
WDTSSEL
Bit 2
WDTISx
Bits 1-0
41
W atch d o g Tim er T a p s:
S S EL 0 0 1 0 1 0 1 1 IS 1 1 1 1 0 1 0 0 0 IS 0 1 0 1 1 0 0 1 0 Int e rval( ms) 0.064 tSMCLK x 64 0 .5 1 .9 8 16 32 25 0 10 00 tS M CLK x 51 2 tACLK x 64 tS M CLK x 8192 tAC L K
x 51 2
Ti m er _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 fr om the counter on overflow c onditi ons and from each of the capture/compare registers. Timer_A features include:
- Asynchronous 16-bit timer/counter with four operating modes -
block diagram of Timer_A is shown in Figure 111. Note: Use of the Word Count Count is used throughout this chapter. It means the counter must be in the process of counting for the action to take place. If a particular value is directly written to the counter, then an associated action will not take place.
42
Timer_A
Timer_A Introduction
TASSELx
IDx
MCx
Timer Block
00 01 10 11
Divider 1/2/4/8
Count Mode
TACLR CCR0 CCR1 CCR2 CCISx CMx logic COV SCS CCI2A CCI2B GND VCC 00 01 10 11 CCI Capture Mode Timer Clock Sync 0 1 15 TACCR2 0
SCCI
A EN
0 1 OUT
EQU0
Output Unit2
Timer Clock
Set Q Reset
OUT2 Signal
OUTMODx
POR
Timer_A
43
Timer_A Operation
Output ExampleTimer 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 1112 using TACCR0 and TACCR1.
Output Mode 7: Reset/Set EQU0 TAIFG EQU1 EQU0 TAIFG EQU1 EQU0 TAIFG Interrupt Events
4 4
Timer_A
Timer_A Registers
7 IDx rw(0)
5 MCx
3 Unused
2 TACLR w(0)
1 TAIE rw(0)
0 TAIFG rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
Unused TASSELx
Unused Timer_A clock source select 00 TACLK 01 ACLK 10 SMCLK 11 INCLK Input divider. These bits select the divider for the input clock. 00 /1 01 /2 10 /4 11 /8 Mode control. Setting MCx = 00h when Timer_A is not in use conserves power. 00 Stop mode: the timer is halted 01 Up mode: the timer counts up to TACCR0 10 Continuous mode: the timer counts up to 0FFFFh 11 Up/down mode: the timer counts up to TACCR0 then down to 0000h Unused Timer_A clear. Setting this bit resets TAR, the TACLK divider, and the count direction. The TACLR bit is automatically reset and is always read as zero. Timer_A interrupt enable. This bit enables the TAIFG interrupt request. 0 Interrupt disabled 1 Interrupt enabled Timer_A interrupt flag 0 No interrupt pending 1 Interrupt pending
IDx
Bits 7-6
MCx
Bits 5-4
TAIFG
Bit 0
45
Timer_A
Timer_A Registers
4 TARx
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
TARx
Bits 15-0
Timer_A
46
Timer_A Registers
6 OUTMODx
4 CCIE
3 CCI r
2 OUT rw(0)
1 COV rw(0)
0 CCIFG rw(0)
rw(0)
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 Capture/compare input select. These bits select the TACCRx input signal. See the device-specific datasheet for specific signal connections. 00 CCIxA 01 CCIxB 10 GND 11 VCC Synchronize capture source. This bit is used to synchronize the capture input signal with the timer clock. 0 Asynchronous capture 1 Synchronous capture Synchronized capture/compare input. The selected CCI input signal is latched with the EQUx signal and can be read via this bit Unused. Read only. Always read as 0. Capture mode 0 Compare mode 1 Capture mode Output mode. Modes 2, 3, 6, and 7 are not useful for TACCR0 because EQUx = EQU0. 000 OUT bit value 001 Set 010 Toggle/reset 011 Set/reset 100 Toggle 101 Reset 110 Toggle/set 111 Reset/set
CCISx
Bit 13-12
SCS
Bit 11
OUTMODx
Bits 7-5
47
Timer_A
Bit 4
Capture/compare interrupt enable. This bit enables the interrupt request of the corresponding CCIFG flag. 0 Interrupt disabled 1 Interrupt enabled Capture/compare input. The selected input signal can be read by this bit. Output. For output mode 0, this bit directly controls the state of the output. 0 Output low 1 Output high Capture overflow. This bit indicates a capture overflow occurred. COV must be reset with software. 0 No capture overflow occurred 1 Capture overflow occurred Capture/compare interrupt flag 0 No interrupt pending 1 Interrupt pending
CCI OUT
Bit 3 Bit 2
COV
Bit 1
CCIFG
Bit 0
7 0 r0
6 0 r0
5 0 r0
4 0 r0
2 TAIVx
0 0
r(0)
r(0)
r(0)
r0
TAIVx
Bits 15-0
TAIV Contents 00h 02h 04h 06h 08h 0Ah 0Ch 0Eh
Interrupt Source No interrupt pending Capture/compare 1 Capture/compare 2 Reserved Reserved Timer overflow Reserved Reserved
Lowest
Timer_A
48
Ti m er _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 features include :
- Async hro nous 16-b it timer /counter with four operating m od es and four
selectable lengths
- Selectable and configurable clock source - Three or seven configurable capture/compare registers -
block diagram of Timer_B is shown in Figure 121. Note: Use of the Word Count Count is used throughout this chapter. It means the counter must be in the process of counting for the action to take place. If a particular value is directly written to the counter, then an associated action does not take place.
49
Timer_B
Timer_B Introduction
00 01 10 11 CCR5 CCR4 CCR1 0 1 OUT Set TBCCR6 CCIFG Compararator 6 EQU6 CAP
EQU0
Output Unit6
Timer Clock
D S et Q Reset
OUT6 Signal
OUTMODx
POR
Timer_B
50
Timer_B Registers
7 IDx rw(0)
5 MCx
3 Unused
2 TBCLR w(0)
1 TBIE rw(0)
0 TBIFG rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
Unused TBCLGRP
Unused 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) TBCL5+TBCL6 (TBCCR5 CLLDx bits control the update) TBCL0 independent 10 TBCL1+TBCL2+TBCL3 (TBCCR1 CLLDx bits control the update) TBCL4+TBCL5+TBCL6 (TBCCR4 CLLDx bits control the update) TBCL0 independent 11 TBCL0+TBCL1+TBCL2+TBCL3+TBCL4+TBCL5+TBCL6 (TBCCR1 CLLDx bits control the update) Counter Length 00 16-bit, TBR(max) = 0FFFFh 01 12-bit, TBR(max) = 0FFFh 10 10-bit, TBR(max) = 03FFh 11 8-bit, TBR(max) = 0FFh Unused Timer_B clock source select. 00 TBCLK 01 ACLK 10 SMCLK 11 Inverted TBCLK Input divider. These bits select the divider for the input clock. 00 /1 01 /2 10 /4 11 /8 Mode control. Setting MCx = 00h when Timer_B is not in use conserves power. 00 Stop mode: the timer is halted 01 Up mode: the timer counts up to TBCL0 10 Continuous mode: the timer counts up to the value set by TBCNTLx 11 Up/down mode: the timer counts up to TBCL0 and down to 0000h
CNTLx
Bits 12-11
Unused TBSSELx
IDx
Bits 7-6
MCx
Bits 5-4
Timer_B
51
Unused 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. Timer_B interrupt enable. This bit enables the TBIFG interrupt request. 0 Interrupt disabled 1 Interrupt enabled Timer_B interrupt flag. 0 No interrupt pending 1 Interrupt pending
TBIFG
Bit 0
4 TBRx
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
TBRx
Bits 15-0
52
Timer_B
Timer_B Registers
6 OUTMODx
4 CCIE
3 CCI r
2 OUT rw(0)
1 COV rw(0)
0 CCIFG rw(0)
rw(0)
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 Capture/compare input select. These bits select the TBCCRx input signal. See the device-specific datasheet for specific signal connections. 00 CCIxA 01 CCIxB 10 GND 11 VCC Synchronize capture source. This bit is used to synchronize the capture input signal with the timer clock. 0 Asynchronous capture 1 Synchronous capture Compare latch load. These bits select the compare latch load event. 00 TBCLx loads on write to TBCCRx 01 TBCLx loads when TBR counts to 0 10 TBCLx loads when TBR counts to 0 (up or continuous mode) TBCLx loads when TBR counts to TBCL0 or to 0 (up/down mode) 11 TBCLx loads when TBR counts to TBCLx Capture mode 0 Compare mode 1 Capture mode Output mode. Modes 2, 3, 6, and 7 are not useful for TBCL0 because EQUx = EQU0. 000 OUT bit value 001 Set 010 Toggle/reset 011 Set/reset 100 Toggle 101 Reset 110 Toggle/set 111 Reset/set
CCISx
Bit 13-12
SCS
Bit 11
CLLDx
Bit 10-9
CAP
Bit 8
OUTMODx
Bits 7-5
Timer_B
53
Bit 4
Capture/compare interrupt enable. This bit enables the interrupt request of the corresponding CCIFG flag. 0 Interrupt disabled 1 Interrupt enabled Capture/compare input. The selected input signal can be read by this bit. Output. For output mode 0, this bit directly controls the state of the output. 0 Output low 1 Output high Capture overflow. This bit indicates a capture overflow occurred. COV must be reset with software. 0 No capture overflow occurred 1 Capture overflow occurred Capture/compare interrupt flag 0 No interrupt pending 1 Interrupt pending
CCI OUT
Bit 3 Bit 2
COV
Bit 1
CCIFG
Bit 0
54
Timer_B
Timer_B Registers
7 0 r0
6 0 r0
5 0 r0
4 0 r0
2 TBIVx
0 0
r(0)
r(0)
r(0)
r0
TBIVx
Bits 15-0
TBIV Contents 00h 02h 04h 06h 08h 0Ah 0Ch 0Eh
Interrupt Source No interrupt pending Capture/compare 1 Capture/compare 2 Capture/compare 3 Capture/compare 4 Capture/compare 5 Capture/compare 6 Timer overflow
Interrupt Flag TBCCR1 CCIFG TBCCR2 CCIFG TBCCR3 CCIFG TBCCR4 CCIFG TBCCR5 CCIFG TBCCR6 CCIFG TBIFG
Lowest
Timer_B
55
Separate transmit and receive buffer registers LSB-first data transmit and receive
- B uilt-in idle-li ne
- Receiver start-edge detection for auto-wake up from LPMx modes - Programmable baud rate with modulation for fractional baud rate support - Status flags for error detection and suppression and address detection - Independent interrupt capability for receive and transmit
Figure 131 shows the USART when configured for UART mode.
56
FE PE OE BRK
Receive Control
Receive Status
LISTEN 0
MM 1 0
RXERR
RXWAKE
CHAR
PEV
PENA UCLKS
STE
UTXD
WUT
SIMO
UCLK
57
ST
D0
D6
D7 AD PA
SP SP
58
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. Parity select. PEV is not used when parity is disabled. 0 Odd parity 1 Even parity Stop bit select. Number of stop bits transmitted. The receiver always checks for one stop bit. 0 One stop bit 1 Two stop bits Character length. Selects 7-bit or 8-bit character length. 0 7-bit data 1 8-bit data Listen enable. The LISTEN bit selects loopback mode. 0 Disabled 1 Enabled. UTXDx is internally fed back to the receiver. Synchronous mode enable 0 UART mode 1 SPI Mode Multiprocessor mode select 0 Idle-line multiprocessor protocol 1 Address-bit multiprocessor protocol Software reset enable 0 Disabled. USART reset released for operation 1 Enabled. USART logic held in reset state
PEV
Bit 6
SPB
Bit 5
CHAR
Bit 4
LISTEN
Bit 3
SYNC
Bit 2
MM
Bit 1
SWRST
Bit 0
59
Unused CKPL
Bit 7 Bit 6
Unused Clock polarity select 0 UCLKI = UCLK 1 UCLKI = inverted UCLK Source select. These bits select the BRCLK source clock. 00 UCLKI 01 ACLK 10 SMCLK 11 SMCLK UART receive start-edge. The bit enables the UART receive start-edge feature. 0 Disabled 1 Enabled Transmitter wake 0 Next character transmitted is data 1 Next character transmitted is an address Unused Transmitter empty flag 0 UART is transmitting data and/or data is waiting in UxTXBUF 1 Transmitter shift register and UxTXBUF are empty or SWRST=1
SSELx
Bits 5-4
URXSE
Bit 3
TXWAKE
Bit 2
Unused TXEPT
Bit 1 Bit 0
60
FE
Bit 7
Framing error flag 0 No error 1 Character received with low stop bit Parity error flag. W hen PENA = 0, PE is read as 0. 0 No error 1 Character received with parity error Overrun error flag. This bit is set when a character is transferred into UxRXBUF before the previous character was read. 0 No error 1 Overrun error occurred Break detect flag 0 No break condition 1 Break condition occurred Receive erroneous-character interrupt-enable 0 Erroneous characters rejected and URXIFGx is not set 1 Erroneous characters received will set URXIFGx Receive wake-up interrupt-enable. This bit enables URXIFGx to be set when an address character is received. W hen URXEIE = 0, an address character will not set URXIFGx if it is received with errors. 0 All received characters set URXIFGx 1 Only received address characters set URXIFGx Receive wake-up flag 0 Received character is data 1 Received character is an address Receive error flag. This bit indicates a character was received with error(s). When RXERR = 1, on or more error flags (FE,PE,OE, BRK) is also set. RXERR is cleared when UxRXBUF is read. 0 No receive errors detected 1 Receive error detected
PE
Bit 6
OE
Bit 5
BRK
Bit 4
URXEIE
Bit 3
URXWIE
Bit 2
RXWAKE
Bit 1
RXERR
Bit 0
61
UxBRx
The valid baud-rate control range is 3 UxBR < 0FFFFh, where UxBR = {UxBR1+UxBR0}. Unpredictable receive and transmit timing occurs if UxBR <3.
UxMCTLx
Bits 70
62
UxRXBUFx
Bits 70
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.
UxTXBUFx
Bits 70
The transmit data buffer is user accessible and holds the data waiting to be moved into the transmit shift register and transmitted on UTXDx. W riting to the transmit data buffer clears UTXIFGx. The MSB of UxTXBUF is not used for 7-bit data and is reset.
63
UBR = 32768/4800 = 6.82667 This means the Baud Rate Register, UBR1, (MSBs) is loaded with 0 and the UBR0 Register contains 6. To get a rough value for the 8-bit modulation register, UMCTL, the fractional part (0.826667) is multiplied by 8 (the number of bits in the register UMCTL). UMCTL = 0.82667 * 8 = 6.613 The rounded result, 7, is the number of 1s to be placed in to the Modulation Register, UMCTL. The resulting, corrected Baud rate with the UMCTL register containing seven 1s is: Baud rate = 32768/ ((7*7+1*6)/8) = 4766.2545 This result in an average Baud rate error of: Baud Rate Error = (4766.2545 - 4800/4800) *100 = -0.703% To get the bit sequence for the modulation register, UMCTL, that fits best, the following algorithm can be used. The fractional part of the theoretical division factor is summed eight times and if a carry to a integer part occurs, the actual mbit is set. Otherwise it is cleared. An example with the above fraction 0.82667 follows. Fraction Addition 0.82667+0.82667 = 1.65333 1.65333+0.82667 = 2.48000 2.48000+0.82667 = 3.30667 3.30667+0.82667 = 4.13333 4.13333+0.82667 = 4.96000 4.96000+0.82667 = 5.78667 5.78667+0.82667 = 6.61333 6.61333+0.82667 = 7.44000 Carry to the Integer Yes Yes Yes Yes No Yes Yes Yes UMC TL Bits m0 m1 m2 m3 m4 m5 m6 m7 1 1 1 1 0 1 1 1
Figure 141 shows the USART when configured for SPI mode.
64
14.2.2 Master Mode Figure 142. USART Master and External Slave
MASTER SLAVE
SIMO
SIMO
MSP430 USART
UCLK
SCLK
Figure 142 shows the USART as a master in both 3-pin and 4-pin configurations. The USART initiates data transfer when data is moved to the transmit data buffer UxTXBUF. The UxTXBUF data is moved to the TX shift register when the TX shift register is empty, initiating data transfer on SIMO starting with the most-significant bit. Data on SOMI is shifted into the receive shift register on the opposite clock edge, starting with the most-significant bit. When the character is received, the receive data is moved from the RX shift register to the received data buffer UxRXBUF and the receive interrupt flag, URXIFGx, is set, indicating the RX/TX operation is complete. A set transmit interrupt flag, UTXIFGx, indicates that data has moved from UxTXBUF to the TX shift register and UxTXBUF is ready for new data. It does not indicate RX/TX completion. To receive data into the USART in m aster m ode, data must be written to UxTXBUF because receive and transmit operations operate concurrently.
A low STE signal does not reset the USART module. The STE input signal is not used in 3-pin master mode.
65
14.2.3 Slave Mode Figure 143. USART Slave and External Master
MASTER SLAVE
SIMO
SIMO
SS Port.x SOMI
SCLK
UCLK
MSP430 USART
Figure 143 shows the USART as a slave in both 3-pin and 4-pin c onfi gurati ons. UCLK is us ed as t he i nput for t he SPI clo ck and mu st be supplied by the external master. The data-transfer rate is determined by this clock and not by the internal baud rate generator. Data written to UxTXBUF and moved to the TX shift register before the start of UCLK is transmitted on SOMI. Data on SIMO is shifted into the receive shift register on the opposite edge of UCLK and m oved to UxRXBUF when the set num ber of bits are received. W hen data is moved from the RX shift register to UxRXBUF, the URXIFGx interrupt flag is set, indicating that data has been received. The overrun error bit, OE, is set when the previously received data is not read from UxRXBUF before new data is moved to UxRXBUF.
SOMI is set to the input direction A high STE signal does not reset the USART module. The STE input signal is not used in 3-pin slave mode.
66
Unused I2C
Bits 76 Bit 5
Unused I2C mode enable. This bit selects I2C or SPI operation when SYNC = 1. 0 SPI mode 1 I2C mode Character length 0 7-bit data 1 8-bit data Listen enable. The LISTEN bit selects the loopback mode 0 Disabled 1 Enabled. The transmit signal is internally fed back to the receiver Synchronous mode enable 0 UART mode 1 SPI mode Master mode 0 USART is slave 1 USART is master Software reset enable 0 Disabled. USART reset released for operation 1 Enabled. USART logic held in reset state
CHAR
Bit 4
LISTEN
Bit 3
SYNC
Bit 2
MM
Bit 1
SWRST
Bit 0
67
CKPH
Bit 7
Clock phase select. Controls the phase of UCLK. 0 Normal UCLK clocking scheme 1 UCLK is delayed by one half cycle 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. 1 The inactive level is high; data is output with the falling edge of UCLK; input data is latched with the rising edge of UCLK. Source select. These bits select the BRCLK source clock. 00 External UCLK (valid for slave mode only) 01 ACLK (valid for master mode only) 10 SMCLK (valid for master mode only) 11 SMCLK (valid for master mode only) Unused Unused Slave transmit control. 0 4-pin SPI mode: STE enabled. 1 3-pin SPI mode: STE disabled. Transmitter empty flag. The TXEPT flag is not used in slave mode. 0 Transmission active and/or data waiting in UxTXBUF 1 UxTXBUF and TX shift register are empty
CKPL
Bit 6
SSELx
Bits 5-4
TXEPT
Bit 0
68
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 Unused Overrun error flag. This bit is set when a character is transferred into UxRXBUF before the previous character was read. OE is automatically reset when UxRXBUF is read, when SW RST = 1, or can be reset by software. 0 No error 1 Overrun error occurred Unused Unused Unused Unused Unused
Undefined OE
Bit 6 Bit 5
69
Software selectable RC-filter for the comparator output Output provided to Tim er_A capture input
- Software control of the port input buffer - Int errupt capab ility - Selectable reference voltage generator -
70
Comparator_A
Comparator_A Introduction
0V 1 CAREFx 0
Comparator_A
71
Comparator_A Operation
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. The comparator should be switched off when not in use to reduce current consumption. W hen the comparator is switched off, the CAOUT is always low.
Internally, the input switch is constructed as a T-switch to suppress distortion in the signal path. Note: Comparator Input Connection W hen the comparator is on, the input terminals should be connected to a signal, power, or ground. Otherwise, floating levels may cause unexpected interrupts and increased current consumption. The CAEX bit controls the input multiplexer, exchanging which input signals are connected to the comparators + and - terminals. Additionally, when the comparator terminals are exchanged, the output signal from the comparator is inverted. This allows the user to determine or compensate for the comparator input offset voltage.
72
Comparator_A
Comparator_A Operation
+ Terminal Terminal Comparator Inputs Comparator Output Unfiltered at CAOUT Comparator Output Filtered at CAOUT
Comparator_A
73
Comparator_A Registers
CAEX CARSEL
Bit 7 Bit 6
Comparator_A exchange. This bit exchanges the comparator inputs and inverts the comparator output. Comparator_A reference select. This bit selects which terminal the VCAREF is applied to. When CAEX = 0: is applied to the + terminal 0 VCAREF is applied to the - terminal 1 V
CARE = When CAEX F 1: 0 V is applied to the - terminal 1 VCAREF is applied to the + terminal CAREF
CAREF
Bits 5-4
Comparator_A reference. These bits select the reference voltage VCAREF. 00 Internal reference off. An external reference can be applied. 01 0.25*VCC 10 0.50*VCC 11 Diode reference is selected Comparator_A on. This bit turns on the comparator. W hen the comparator is off it consumes no current. The reference circuitry is enabled or disabled independently. 0 Off 1 On Comparator_A interrupt edge select 0 Rising edge 1 Falling edge Comparator_A interrupt enable 0 Disabled 1 Enabled The Comparator_A interrupt flag 0 No interrupt pending 1 Interrupt pending
CAON
Bit 3
CAIES
Bit 2
CAIE
Bit 1
CAIFG
Bit 0
74
Comparator_A
Comparator_A Registers
Unused P2CA1
Unused. 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 Pin to CA0. This bit selects the CA0 pin function. 0 The pin is not connected to CA0 1 The pin is connected to CA0 Comparator_A output filter 0 Comparator_A output is not filtered 1 Comparator_A output is filtered Comparator_A output. This bit reflects the value of the comparator output. Writing this bit has no effect.
P2CA0
Bit 2
CAF
Bit 1
CAOUT
Bit 0
CAPDx
Bits 7-0
Comparator_A port disable. These bits individually disable the input buffer for the pins of the port associated with Comparator_A. For example, if CA0 is on pin P2.3, the CAPDx bits can be used to individually enable or disable each P2.x pin buffer. CAPD0 disables P2.0, CAPD1 disables P2.1, etc. 0 The input buffer is enabled. 1 The input buffer is disabled.
Comparator_A
75
- Monotonic 12-bit converter with no m issing codes - Sam ple-and-hol d wi th pr og ramma ble s ampling perio ds controlled by
software or timers.
- Conversion initiation by software, Timer_A, or Timer_B - Software selectable on-chip reference voltage generation (1.5 V or 2.5 V) -
references
negative references
- Sele ct able c onversion clo ck source - Single-channel, repeat-single-channel, sequence, and repeat-sequence
conversion modes
- ADC core and reference voltage can be powered down separately - Interrupt vector register for fast decoding of 18 ADC interrupts -
76
ADC12
ADC12 Introduction
REF2_5V Ve REF+ REF+ V REF / Ve REF AVCC INCHx 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 V AVSS 0 V 11 10 01 00 SREF1 SREF0 Ref_x ADC12OSC ADC12SSELx ADC12DIVx Sample and Hold S/H R R+ 00 Divider /1 .. /8 ADC12CLK BUSY SHP SHT0x 4 Sample Timer /4 .. /1024 4 SHT1x MSC SHI ISSH ENC 0 1 00 01 10 11 01 10 11 ACLK MCLK SMCLK V on 1.5 V or 2.5 V Reference
REFON INCHx=0A
AVCC
ADC12ON
SHSx
Sync
R AVSS
CONSEQx
ADC12
77
ADC12 Operation
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. W hen SAMPCON is high, sampling is active. The high-to-low SAMPCON transition starts the analog-to-digital conversion, which requires 13 ADC12CLK cycles. Two different sample-timing methods are defined by control bit SHP, extended sample mode and pulse mode.
SHI
13 x ADC12CLK tconvert
ADC12
78
ADC12 Operation
SHI
13 x ADC12CLK t convert
79
ADC12
ADC12 Registers
7 MSC rw(0)
6 REF2_5V rw(0)
5 REFON rw(0)
4 ADC12ON rw(0)
3 ADC12OVIE rw(0)
1 ENC rw(0)
0 ADC12SC rw(0)
SHT1x SHT0x
Sample-and-hold time. These bits define the number of ADC12CLK cycles in the sampling period for registers ADC12MEM8 to ADC12MEM15. Sample-and-hold time. These bits define the number of ADC12CLK cycles in the sampling period for registers ADC12MEM0 to ADC12MEM7.
SHTx Bits 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 ADC12CLK cycles 4 8 16 32 64 96 128 192 256 384 512 768 1024 1024 1024 1024
ADC12
80
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. Reference generator voltage. REFON must also be set. 0 1.5 V 1 2.5 V Reference generator on 0 Reference off 1 Reference on ADC12 on 0 ADC12 off 1 ADC12 on ADC12MEMx overflow-interrupt enable. The GIE bit must also be set to enable the interrupt. 0 Overflow interrupt disabled 1 Overflow interrupt enabled ADC12 conversion-time-overflow interrupt enable. The GIE bit must also be set to enable the interrupt. 0 Conversion time overflow interrupt disabled 1 Conversion time overflow interrupt enabled Enable conversion 0 ADC12 disabled 1 ADC12 enabled Start conversion. Software-controlled sample-and-conversion start. ADC12SC and ENC may be set together with one instruction. ADC12SC is reset automatically. 0 No sample-and-conversion-start 1 Start sample-and-conversion
REF2_5V
Bit 6
REFON
Bit 5
ADC12ON
Bit 4
ADC12OVIE Bit 3
ADC12 TOVIE
Bit 2
ENC
Bit 1
ADC12SC
Bit 0
81
ADC12
ADC12 Registers
6 ADC12DIVx
4 ADC12SSELx
2 CONSEQx rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
CSTART ADDx
Bits 15-12
Conversion start address. These bits select which ADC12 conversion-m em ory register is used for a single conversion or for the first conversion in a sequence. The value of CSTARTADDx is 0 to 0Fh, corresponding to ADC12MEM0 to ADC12MEM15. Sample-and-hold source select 00 ADC12SC bit 01 Timer_A.OUT1 10 Timer_B.OUT0 11 Timer_B.OUT1 Sample-and-hold pulse-mode select. This bit selects the source of the sampling signal (SAMPCON) to be either the output of the sampling timer or the sample-input signal directly. 0 SAMPCON signal is sourced from the sample-input signal. 1 SAMPCON signal is sourced from the sampling timer. Invert signal sample-and-hold 0 The sample-input signal is not inverted. 1 The sample-input signal is inverted. ADC12 clock divider 000 /1 001 /2 010 /3 011 /4 100 /5 101 /6 110 /7 111 /8
SHSx
Bits 11-10
SHP
Bit 9
ISSH
Bit 8
ADC12DIVx
Bits 7-5
ADC12
82
Bits 4-3
ADC12 clock source select 00 ADC12OSC 01 ACLK 10 MCLK 11 SMCLK Conversion sequence mode select 00 Single-channel, single-conversion 01 Sequence-of-channels 10 Repeat-single-channel 11 Repeat-sequence-of-channels ADC12 busy. This bit indicates an active sample or conversion operation. 0 No operation is active. 1 A sequence, sample, or conversion is active.
CONSEQx
Bits 2-1
ADC12 BUSY
Bit 0
Conversion Results rw rw rw
Conversion Results rw rw rw rw rw rw rw rw
Conversion Results
Bits 15-0
The 12-bit conversion results are right-justified. Bit 11 is the MSB. Bits 15-12 are always 0. W riting to the conversion memory registers will corrupt the results.
83
ADC12
ADC12 Registers
EOS
Bit 7
End of sequence. Indicates the last conversion in a sequence. 0 Not end of sequence 1 End of sequence Select reference = AV and V = AV 000 VR+ R = AV S S = V CC 001 VR+ REF+ and VR S = Ve = AV S 010 VR+ REF+ and VR = Ve = AVSS 011 VR+ REF+ and VR SS = AV and V = V / Ve 100 VR+ CC R REF R =V =V / Ve EF 101 VR+ REF+ and VR REF = Ve =V / VREF e 110 VR+ REF+ and VR REF = Ve =V / VeREF 111 VR+ REF+ and VR REF REF Input channel select 0000 A0 0001 A1 0010 A2 0011 A3 0100 A4 0101 A5 0110 A6 0111 A7 1000 VeREF+ /Ve 1001 VREF REF 1010 Temperature sensor 1011 (AVCC - AVSS) / 2 1100 (AVCC - AVSS) / 2 1101 (AVCC - AVSS) / 2 1110 (AVCC - AVSS) / 2 1111 (AVCC - AVSS) / 2
SREFx
Bits 6-4
INCHx
Bits 3-0
ADC12
84
ADC12 Registers
7 ADC12IE7 rw(0)
6 ADC12IE6 rw(0)
5 ADC12IE5 rw(0)
4 ADC12IE4 rw(0)
3 ADC12IE3 rw(0)
2 ADC12IE2 rw(0)
1 ADC12IE1 rw(0)
0 ADC12IE0 rw(0)
ADC12IEx
Bits 15-0
Interrupt enable. These bits enable or disable the interrupt request for the ADC12IFGx bits. 0 Interrupt disabled 1 Interrupt enabled
ADC12IFGx Bits
15-0
ADC12MEMx Interrupt flag. These bits are set when corresponding ADC12MEMx is loaded with a conversion result. The ADC12IFGx bits are reset if the corresponding ADC12MEMx is accessed, or may be reset with software. 0 No interrupt pending 1 Interrupt pending
85
ADC12
ADC12 Registers
7 0 r0
6 0 r0
3 ADC12IVx
0 0
r(0)
r(0)
r(0)
r(0)
r(0)
r0
ADC12IVx
Bits 15-0
ADC12IV Contents 000h 002h 004h 006h 008h 00Ah 00Ch 00Eh 010h 012h 014h 016h 018h 01Ah 01Ch 01Eh 020h 022h 024h
Interrupt Source No interrupt pending ADC12MEMx overflow Conversion time overflow ADC12MEM0 interrupt flag ADC12MEM1 interrupt flag ADC12MEM2 interrupt flag ADC12MEM3 interrupt flag ADC12MEM4 interrupt flag ADC12MEM5 interrupt flag ADC12MEM6 interrupt flag ADC12MEM7 interrupt flag ADC12MEM8 interrupt flag ADC12MEM9 interrupt flag ADC12MEM10 interrupt flag ADC12MEM11 interrupt flag ADC12MEM12 interrupt flag ADC12MEM13 interrupt flag ADC12MEM14 interrupt flag ADC12MEM15 interrupt flag
Interrupt Flag ADC12IFG0 ADC12IFG1 ADC12IFG2 ADC12IFG3 ADC12IFG4 ADC12IFG5 ADC12IFG6 ADC12IFG7 ADC12IFG8 ADC12IFG9 ADC12IFG10 ADC12IFG11 ADC12IFG12 ADC12IFG13 ADC12IFG14 ADC12IFG15
Lowest
ADC12
86
Note: Multiple DAC12 Modules Some devices may integrate more than one DAC12 module. In the case where more than one DAC12 is present on a device, the multiple DAC12 modules operate identically. Throughout this chapter, nomenclature appears such as DAC12_xDAT or DAC12_xCTL to describe register names. W hen this occurs, the x is used to i ndi cate whi ch D AC12 m odule is bei ng dis cuss ed. In cases w here operation is identical, the register is simply referred to as DAC12_xCTL. The blo ck dia gram of the two D AC 12 mo dules in t he MSP 430F15x/16x devices is shown in Figure 191.
87
DAC12
DAC12 Introduction
To ADC12 module 2.5V or 1.5V reference from ADC12 DAC12SREFx DAC12IR 00 01 10 11 AV SS /3 DAC12AMPx 3
DAC12LSELx
V R DAC12_0
V R+ x3 DAC12_0OUT
00 01 TA1 TB2 10 11
DAC12_0Latch
DAC12_0DAT
DAC12LSELx
V R DAC12_1
V R+ x3
DAC12_1OUT
00 01 TA1 TB2 10 11
DAC12_1Latch
DAC12_1DAT
DAC12_1DAT Updated
DAC12
88
DAC12 Operation
In 8-bit mode the maximum useable value for DAC12_xDAT is 0FFh and in 12-bit mode the maximum useable value for DAC12_xDAT is 0FFFh. Values greater t han t hese may be wr itt en to t he reg ister, but all l eadi ng bits are ignored.
89
DAC12
DAC12 Registers
6 DAC12AMPx
4 DAC12DF
3 DAC12IE rw(0)
2 DAC12IFG rw(0)
1 DAC12ENC rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
Reserved DAC12 select reference voltage 00 VREF+ 01 VREF+ 10 VeREF+ 11 VeREF+ DAC12 resolution select 0 12-bit resolution 1 8-bit resolution DAC12 load select. Selects the load trigger for the DAC12 latch. DAC12ENC must be set for the DAC to update, except when DAC12LSELx = 0. 00 DAC12 latch loads when DAC12_xDAT written (DAC12ENC is ignored) 01 DAC12 latch loads when DAC12_xDAT written, or, when grouped, when all DAC12_xDAT registers in the group have been written. 10 Rising edge of Timer_A.OUT1 (TA1) 11 Rising edge of Timer_B.OUT2 (TB2) DAC12 calibration on. This bit initiates the DAC12 offset calibration sequence and is automatically reset when the calibration completes. 0 Calibration is not active 1 Initiate calibration/calibration in progress DAC12 input range. This bit sets the reference input and voltage output range. 0 DAC12 full-scale output = 3x reference voltage 1 DAC12 full-scale output = 1x reference voltage
Bit 12
Bits 11-10
DAC12 CALON
Bit 9
DAC12IR
Bit 8
DAC12
90
Bits 7-5
DAC12 amplifier setting. These bits select settling time vs. current consumption for the DAC12 input and output amplifiers. DAC12AMPx 000 001 010 011 100 101 110 111 Off Off Low speed/current Low speed/current Low speed/current Medium speed/current Medium speed/current High speed/current Input Buffer Output Buffer DAC12 off, output high Z DAC12 off, output 0 V Low speed/current Medium speed/current High speed/current Medium speed/current High speed/current High speed/current
DAC12DF
Bit 4
DAC12 data format 0 Straight binary 1 2s compliment DAC12 interrupt enable 0 Disabled 1 Enabled DAC12 Interrupt flag 0 No interrupt pending 1 Interrupt pending DAC12 enable conversion. This bit enables the DAC12 module when DAC12LSELx > 0. when DAC12LSELx = 0, DAC12ENC is ignored. 0 DAC12 disabled 1 DAC12 enabled DAC12 group. Groups DAC12_x with the next higher DAC12_x. Not used for DAC12_1 on MSP430x15x and MSP430x16x devices. 0 Not grouped 1 Grouped
DAC12IE
Bit 3
DAC12IFG
Bit 2
DAC12 ENC
Bit 1
DAC12 GRP
Bit 0
91
DAC12
DAC12 Registers
4 DAC12 Data
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
rw(0)
Unused
Unused. These bits are always 0 and do not affect the DAC12 core. DAC12 data
DAC12 Data The DAC12 data are right-justified. Bit 11 is the MSB. The DAC12 data are right-justified. Bit 11 is the MSB (sign). The DAC12 data are right-justified. Bit 7 is the MSB. Bits 11-8 are dont care and do not effect the DAC12 core. The DAC12 data are right-justified. Bit 7 is the MSB (sign). Bits 11-8 are dont care and do not effect the DAC12 core.
8-bit 2s complement
DAC12
92
Interrupt V e ct or Addre s s e s
The interrupt vectors and the power-up starting address are located in the address range 0FFFFh - 0FFE0h. The vector contains the 16-bit address of the appropriate interrupt-handler instruction sequence.
INTERRUPT SOURCE Power-up External Reset Watchdog Flash memory NMI Oscillator Fault Flash memory access violation Timer_B7 (see Note 5) Timer_B7 (see Note 5) Comparator_A Watchdog timer USART0 receive USART0 transmit ADC Timer_A3 Timer_A3 INTERRUPT FLAG WDTIFG KEYV (see Note 1) NMIIFG (see Notes 1 & 4) OFIFG (see Notes 1 & 4) ACCVIFG (see Notes 1 & 4) BCCIFG0 (see Note 2) BCCIFG1 to BCCIFG6 TBIFG (see Notes 1 & 2) CAIFG WDTIFG URXIFG0 UTXIFG0 ADCIFG (see Notes 1 & 2) CCIFG0 (see Note 2) CCIFG1, CCIFG2, TAIFG (see Notes 1 & 2) P1IFG.0 (see Notes 1 & 2) To P1IFG.7 (see Notes 1 & 2) URXIFG1 UTXIFG1 P2IFG.0 (see Notes 1 & 2) To P2IFG.7 (see Notes 1 & 2) Maskable SYSTEM INTERRUPT Reset WORD ADDRESS 0FFFEh PRIORITY 15, highest
(Non)maskable (Non)maskable (Non)maskable Maskable Maskable Maskable Maskable Maskable Maskable Maskable Maskable Maskable
0FFFCh 0FFFAh 0FFF8h 0FFF6h 0FFF4h 0FFF2h 0FFF0h 0FFEEh 0FFECh 0FFEAh
14 13 12 11 10 9 8 7 6 5
I/O port P1 (eight flags) USART1 receive USART1 transmit I/O port P2 (eight flags)
Maskable Maskable
4 3 2 1 lowest
NOTES: 1. 2. 3. 4.
Multiple source flags Interrupt flags are located in the module. Nonmaskable: neither the individual nor the general interrupt-enable bit will disable an interrupt event. (Non)maskable: the individual interrupt-enable bit can disable an interrupt event, but the general-interrupt enable can not disable it. 5. Timer_B7 in MSP430x14x family has 7 CCRs; Timer_B3 in MSP430x13x family has 3 CCRs; in Timer_B3 there are only interrupt flags CCIFG0, 1, and 2, and the interrupt-enable bits CCIE0, 1, and 2 integrated.
93
IE 1
Address 0h
6 URXIE0 rw-0
5 ACCVIE rw-0
4 NMIIE
2 rw-0
1 OFIE rw-0
0 WDTIE
Watchdog-timer-interrupt enable signal Oscillator-fault-interrupt enable signal Nonmaskable-interrupt enable signal (Non)maskable-interrupt enable signal, access violation if FLASH memory/module is busy USART0, UART, and SPI receive-interrupt enable signal USART0, UART, and SPI transmit-interrupt enable signal
6 rw-0 5 UTXIE1 rw-0 4 URXIE1 3 2 1 0
IE2
URXIE1: UTXIE1:
USART1, UART, and SPI receive-interrupt enable signal USART1, UART, and SPI transmit-interrupt enable signal
I FG 1
7 UTXIFG0 rw-0
6 URXIFG0
5 rw-0
4 NMIIFG
2 rw-1
1 OFIFG rw-0
0 WDTIFG
Set on overflow or security key violation or reset on VCC power-on or reset condition at RST/NMI Flag set on oscillator fault Set via RST/NMI pin USART0, UART, and SPI receive flag USART0, UART, and SPI transmit flag
6 rw-1 5 UTXIFG1 rw-0 4 URXIFG1 3 2 1 0
IFG2
URXIFG1: UTXIFG1:
USART1, UART, and SPI receive flag USART1, UART, and SPI transmit flag
94
ME 1
Address 04h
7 UTXE0 rw-0
USART0, UART receive enable USART0, UART transmit enable USART0, SPI (synchronous peripheral interface) transmit and receive enable
7 6 5 UTXE1 rw-0 4 URXE1 USPIE1 rw-0 3 2 1 0
M E2
Address 05h
USART1, UART receive enable USART1, UART transmit enable USART1, SPI (synchronous peripheral interface) transmit and receive enable
Bit Can Be Read and Written Bit Can Be Read and Written. It Is Reset by PUC. SFR Bit Not Present in Device
memory organization
MSP430F133 Memory Main: interrupt vector Main: code memory Information memory Boot memory RAM Peripherals Size Flash Flash Size Flash Size ROM Size 16-bit 8-bit 8-bit SFR 8kB 0FFFFh - 0FFE0h 0FFFFh - 0E000h 256 Byte 010FFh - 01000h 1kB 0FFFh - 0C00h 256 Byte 02FFh - 0200h 01FFh - 0100h 0FFh - 010h 0Fh - 00h MSP430F135 16kB 0FFFFh - 0FFE0h 0FFFFh - 0C000h 256 Byte 010FFh - 01000h 1kB 0FFFh - 0C00h 512 Byte 03FFh - 0200h 01FFh - 0100h 0FFh - 010h 0Fh - 00h MSP430F147 32kB 0FFFFh - 0FFE0h 0FFFFh - 08000h 256 Byte 010FFh - 01000h 1kB 0FFFh - 0C00h 1kB 05FFh - 0200h 01FFh - 0100h 0FFh - 010h 0Fh - 00h MSP430F148 48kB 0FFFFh - 0FFE0h 0FFFFh - 04000h 256 Byte 010FFh - 01000h 1kB 0FFFh - 0C00h 2kB 09FFh - 0200h 01FFh - 0100h 0FFh - 010h 0Fh - 00h MSP430F149 60kB 0FFFFh - 0FFE0h 0FFFFh - 01100h 256 Byte 010FFh - 01000h 1kB 0FFFh - 0C00h 2kB 09FFh - 0200h 01FFh - 0100h 0FFh - 010h 0Fh - 00h
95
P2.1/TAINCLK
MC1 MC0 0
P2.2/CAOUT/TA0
P1.1/TA0
0 1 2 3
Capture/Compare Reg. CCR1 15 Capture Mode CCI1 CCM11 CCM10 Capture Capture/Compare Register CCR1 0 OM12OM11 OM10 P1.2/TA1 Output Unit1 Comparator 1 EQU1 Out1 P1.6/TA1 P2.3/CA0/TA1 ADC12I1 (i/p at ADC12)
CCIS21CCIS20 P1.3/TA2 ACLK CCI2A CCI2B GND VCC 0 1 2 3 Capture Mode CCI2 CCM21 CCM20 Capture 15 0 a C om pa e C ptture/Comparre Register CCR2 Comparator 2 Output Unit2 EQU2 OM22OM21OM20 Out2
Figure 2. Timer_A, MSP430x13x/14x Configuration Two interrupt vectors are used by the module. One vector is assigned to capture/compare block CCR0, and one common-interrupt vector is implemented for the timer and the other two capture/compare blocks. The three interrupt events using the same vector are identified by an individual interrupt vector word. The interrupt vector word is used to add an offset to the program counter so that the interrupt handler software continues at the corresponding program location. This simplifies the interrupt handler and assigns each interrupt event the same five-cycle overhead.
96
FEATURES
Real-time clock (RTC) counts seconds, minutes, hours, date of the month, month, day of the week, and year with leap-year compensation valid up to 2100 56-byte, battery-backed, nonvolatile (NV) RAM for data storage Two-wire serial interface Programmable squarewave output signal Automatic power-fail detect and switch circuitry Consumes less than 500nA in battery backup mode with oscillator running Optional industrial temperature range: -40C to +85C Available in 8-pin DIP or SOIC Underwriters Laboratory (UL) recognized
PIN ASSIGNMENT
X1 X2 VBAT GND l 2 3 4 8 7 6 5 VCC SQW/OUT SCL SDA
ORDERING INFORMATION
DS1307 DS1307Z DS1307N DS1307ZN
8-Pin DIP (300-mil) 8-Pin SOIC (150-mil) 8-Pin DIP (Industrial) 8-Pin SOIC (Industrial)
PIN DESCRIPTION
- Primary Power Supply - 32.768kHz Crystal Connection - +3V Battery Input - Ground - Serial Data - Serial Clock - Square Wave/Output Driver
DESCRIPTION
The DS1307 Serial Real-Time Clock is a low-power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially via a 2-wire, bi-directional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with AM/PM indicator. The DS1307 has a built-in power sense circuit that detects power failures and automatically switches to the battery supply.
97
DS1307
0 0 0 0 0 0 0 0 0 0 0 0
CONTROL REGISTER
BIT 7 OUT BIT 6 0
The DS1307 control register is used to control the operation of the SQW/OUT pin. BIT 5 0 BIT 4 SQWE BIT 3 0 BIT 2 0 BIT 1 RS1 BIT 0 RS0
OUT (Output control): This bit controls the output level of the SQW/OUT pin when the square wave output is di sabled. If SQWE = 0, the logic level on the SQW/OU T pin is 1 if OU T = 1 and is 0 if OUT = 0. SQWE (Square Wave Enable): This bit, when set to a logic 1, will enable the oscillator output. The frequency of the square wave output depends upon the value of the RS0 and RS1 bits. With the square wave output set to 1Hz, the clock registers update on the falling edge of the square wave. RS (Rate Select): These bits control the frequency of the square wave output when the square wave output has been enabled. Table 1 lists the square wave frequencies that can be selected with the RS bits.
98
Philips Semiconductors
then hold the SCL line LOW after reception and acknowledgment of a byte to force the master into a wait state until the slave is ready for the next byte transfer in a type of handshake procedure (see Fig.6). On the bit level, a device such as a microcontroller with or 2 without limited hardware for the I C-bus, can slow down the bus clock by extending each clock LOW period. The speed of any master is thereby adapted to the internal operating rate of this device. In Hs-mode, this handshake feature can only be used on byte level (see Section 13). 9 FORMATS WITH 7-BIT ADDRESSES
Data transfers follow the format shown in Fig.10. After the START condition (S), a slave address is sent. This Slaves are not involved in the arbitration procedure. address is 7 bits long followed by an eighth bit which is a data direction bit (R/W ) - a zero indicates a transmission 8.3 Use of the clock synchronizing mechanism as (W RITE), a one indicates a request for data (READ). A a handshake data transfer is always terminated by a STOP condition (P) In addition to being used during the arbitration procedure, generated by the master. However, if a master still wishes to communicate on the bus, it can generate a repeated the clock synchronization mechanism can be used to enable receivers to cope with fast data transfers, on either a START condition (Sr) and address another slave without first generating a STOP condition. Various combinations of byte level or a bit level. read/write formats are then possible within such a transfer. On the byte level, a device may be able to receive bytes of data at a fast rate, but needs more time to store a received byte or prepare another byte to be transmitted. Slaves can
SDA
1-7
1-7
1-7
9 P
ADDRESS
R/W
ACK
DATA
ACK
DATA
ACK
STOP condition
MBC604
99
Philips Semiconductors
SLAVE ADDRESS
R/W
DATA
DATA
A/A
A = acknowledge (SDA LOW ) A = not acknowledge (SDA HIGH) S = START condition P = STOP condition
Fig.11 A master-transmitter addressing a slave receiver with a 7-bit address. The transfer direction is not changed.
data transferred
MBC606
(read)
(n bytes + acknowledge)
100
M S P 43 x 13x MS 4 30 x 4 x 0 , P 1 M I X E D S I G N A L M I C R O C O N T R OL E R L
SLAS272C - JULY 2000 - REVISED FEBRUARY 2001
DVCC P6.3/A3 P6.4/A4 P6.5/A5 P6.6/A6 P6.7/A7 VREF+ XIN XOUT/TCLK VeREF+ VREF-/VeREFP1.0/TACLK P1.1/TA0 P1.2/TA1 P1.3/TA2 P1.4/SMCLK
1 2 3 4 5 6 7 8 9
64 63 6261 6059 58 57
56 55 54 5352 51 50 49
48 47 46 45 44 43 42 41 40 39 38 37 36 35 34
10 11 12 13 14 15
P5.4/MCLK P5.3/UCLK1 P5.2/SOMI1 P5.1/SIMO1 P5.0/STE1 P4.7/TBCLK P4.6/TB6 P4.5/TB5 P4.4/TB4 P4.3/TB3 P4.2/TB2 P4.1/TB1 P4.0/TB0 P3.7/URXD1 P3.6/UTXD1 P3.5/URXD0
101