Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
5/22/2008 1
DIVAx
Divider /1/2/4/8
Peripherals
LFXT1
Crystal Oscillator 32768Hz 400kHz 16MHz
XIN
XOUT
LFXT1 Oscillator
XCAPx Min. Puls Filter XT2Off XT2S
Divider /1/2/4/8
0 1
MCLK
CPU
XT2
Crystal Oscillator 400kHz 16MHz On high end MSP430
XT2IN XT XT2OUT
XT2 Oscillator
MODx
VCC
DCO
Digitally Controlled Oscillator ~100kHz >16MHz
P2.5/Rosc
Modulator
DCOx
DIVSx
SCG1 0 1
DC Generator
n
DCO
n+1
DCOCLK
Divider /1/2/4/8
Peripherals
SMCLK
3
Peripherals LFXT1
Crystal Oscillator 32768Hz 400kHz 8MHz
DCO
Digitally Controlled Oscillator ~100kHz >8MHz
CPU
XT2
Crystal Oscillator 400kHz 8MHz On high end MSP430
Peripherals
4
VLO
Internal very low power, low frequency oscillator ~12kHz
XT2
REFO
Internal 32768Hz Oscillator
XT2
Crystal Oscillator 400kHz >25MHz
Divider /1/2/4/8/16
FLLREFCLK
MCLK
FLL
Frequency Locked Loop
FLL
DCO
Digitally Controlled Oscillator ~100kHz >25MHz
DCOCLK DCO DCOCLKDIV SMCLK
MODOSC
Module Oscillator e.g. for ADC, Flash Controller etc.
MODOSC MODCLK Provided to Flash controller, ADC12
PRECISION
high medium low
COST
External Components $0 $0
DCO Bits
SDCO = fDCO+1 / fDCO
1.5 2.1
VCC
Modulator
DCOR SCG0 RSELx DCOx
0 1 P2.5/ROSC
off
DCO
n n+1
0 1
DCOCLK
DCO Modulation
eD ag er Av
CO
10
The modulator mixes two DCO frequencies, fDCOx and fDCOx+1 to produce an intermediate frequency between fDCOx and fDCOx+1 and spread the clock energy, reducing electromagnetic interference (EMI)
11
tcycle n
tcycle n+1
DCO accuracy
DV Drift with VCC variation DV 1.8V 3.6V
maximum over entire range
Dt 0C 85C VCC = 3V
maximum over entire range
MSP430F149
0 10 %/V
0 18%
-28 -37%
MSP430F249
0 -2.5%/V
(from graph in DS)
-3% +3%
(Cal 1MHz 12MHz)
-2.5% +2.5%
(Cal 1MHz 12MHz)
MSP430F449
0 15 %/V
0 27 %
0.2 0.4%/C
-17 -34%
Modulator
ROSC
0 1 P2.5/ROSC
off
DCO
n n+1
0 1
DCOCLK
14
MSP430F2xx:
Calibrated DCO with values stored in Information Memory segment A for 1MHz, 8MHz , 12MHz and 16MHz: Code example:
if ((CALDCO_16MHZ != 0xFF) && (CALBC1_16MHZ != 0xFF)) if ((CALDCO_16MHZ != 0xFF) && (CALBC1_16MHZ != 0xFF)) {DCOCTL == CALDCO_16MHZ; // DCO == 16MHz calibrated {DCOCTL CALDCO_16MHZ; // DCO 16MHz calibrated BCSCTL1 == CALBC1_16MHZ; // DCO == 16MHz calibrated BCSCTL1 CALBC1_16MHZ; // DCO 16MHz calibrated }}
DCO (~ 3.5%)
16
Lower LPM3 supply current consumption compared to 32kHz crystal Considerable higher frequency tolerance than LFXT1 with 32kHz crystal
18
NOTES: 6. Calculated using the box method: I version: (MAX(-40 to 85C) - MIN(-40 to 85C))/MIN(-40 to 85C)/(85C -- (-40C)) T version: (MAX(-40 to 105C) - MIN(-40 to 105C))/MIN(-40 to 105C)/(105C -- (-40C)) 7. Calculated using the box method: (MAX(1.8 to 3.6 V) - MIN(1.8 to 3.6 V))/MIN(1.8 to 3.6 V)/(3.6 V - 1.8 V)
VLO is ultra low power oscillator for LPM3, for cost sensitive applications where frequency accuracy is not important. Example: Supply current MSP430F249: ICC (VLO, LPM3, VCC=3V, 25C): ICC (LFXT1, LPM3, VCC=3V, 25C): typ. 0.4uA, max. 1uA typ. 1uA, max. 1.4uA
19
10
Power draw is higher than crystal or VLO Is the default FLL reference clock
21
% % ms
REFO is a low power oscillator for LPM3, without external components, if moderate frequency accuracy is sufficient. Example: Supply current MSP430F5xx: ICC (REFO, LPM3, 25C): ICC (LFXT1): typ. ~5uA typ. ~2.6uA
22
11
12
~180
RD
CL1
32768Hz XTAL
CL2
The characteristics of the Inverter defines the oscillators performance and crystal constraints. The serial resistor RD helps to suppress the crystals overtone mode and can help to reduce the drive level. The chosen crystal and its specification should match the oscillator design and constraints. The load-capacitors CL1 and CL2 (regarded as in series) form the oscillators effective loadcapacitance.
Loop gain: At steady state, the closed-loop gain = 1 Phase shift: At the frequency of oscillation, the closed loop phase shift = 2n
25
OA Oscillation allowance
(negative-resistance model, Crystal constraints)
Assembly Ceramic Package CC
Board Layout
(minimize crosstalk and negative EMI effects)
32768Hz Tuning Fork Crystal
26
13
Actual Effective Load Capacitance 7pF Frequency Shift [ppm] Frequency Target Correct frequency 32768 Hz F F
27
source: MicroCrystal
Actual Effective Load Capacitance 12pF Frequency Shift [ppm] Frequency Target Wrong frequency ~32770 Hz F F
28
source: MicroCrystal
14
29
Determine correct CL
Measure crystal oscillator frequency with frequency counter Dont measure with probes directly at the crystal pins
Typical 32kHz load capacitance is 6pF 15pF Ultra-low-power oscillator input impedance > 5M Probe capacitance and impedance heavily influences oscillator
P2.0/ACLK/CA2
Result on the frequency counter must be 32768 Hz This measurement includes parasitic capacitance of board and pins
32768 Hz
30
15
LM
Equivalent electrical model of a crystal C0: Parasitic capacitance of package and pins CM: Motional capacitance LM: Motional inductance RM: Mechanical losses during oscillation
The ESR (Equivalent Series Resistance) is given in a crystals data sheet and can be calculated with the following formula from the equivalent circuit:
C ESR = RM 1 + 0 ; C L
31
Oscillator Allowance
The Oscillation Allowance test is a method to measure the Oscillator-performance
Resistor Rx is placed in series to the crystal. Increase Rx until oscillation stops / starts.
Oscillation Stops
Inverter
Rx STOP
Oscillation Starts
RD Rx 32768Hz XTAL
Rx START
CL1
CL2
OA = RXSTART + ESRXTAL
Example:
OA = 200k + 50k
32
16
Layout without and with external load capacitors (XIN and XOUT neighboring pins are standard function pins)
Layout with external capacitors and ground guard ring (XIN and XOUT neighboring pins are NC pins) Examples for MSP430F41x and MSP430F1232IRHB
33
Temperature characteristics
curve for 0ppm crystal
20.0 0.0 -20.0 -40.0 -60.0 -80.0
AT-Cut
F F
-100.0 -120.0 -140.0 -160.0 -180.0 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 Tem perature [C]
Tuning Fork
32768Hz crystals
source: MicroCrystal
34
17
35
Method 2:
Divide Timer_A by 32768 or 32769, depending on temperature Divide by 32768 0 ppm correction Divide by 32769 +30 ppm correction 1ppm correction with modulation of Timer_A in software: Within 30 cycles: n cycles divide by 32769 30-n cycles divide by 32768
This procedure needs frequent CPU interaction Higher power consumption! DMA can do modulation with much less power consumption.
36
18
HF oscillator CL configurations
Internal CL MSP430F1xx MSP430F2xx MSP430F4xx MSP430F5xx no no no no External CL free choice free choice free choice free choice
38
19
Temperature characteristics
curve for 0ppm crystal
20.0 0.0 -20.0 -40.0 -60.0 -80.0
AT-Cut
Tuning Fork
F F
source: MicroCrystal
39
20
~ 32768Hz
DCO / (FLLDx * (N+1))
Divider
FLL compares frequencies at + and - input If (f(+) > f(-)) then increment DCO+MOD bits else decrement DCO+MOD bits
41
DCOx
DCOx
DCOx+1
DCOx
DCOx
DCOx
DCOx+1
DCOx
DCOx
DCOx
DCOx+1
DCOx
DCOx
DCOx
DCOx+1
21
FLL at power-on
FLL loop control is turned on by default
Status Register Bit SCG0 = 0 (default value)
Directly after power-on the 32768Hz crystal oscillator starts oscillating and frequency < 32768Hz
FLL reduces the DCO frequency
1MHz
DCOCLK
22
CCI2B_ISR
DCOCLK
>CLK
Timer_A CCR2
capture
;244 DCO clock cycles captured? ;244 DCO clock cycles captured? CCI2B_ISR push.w ;; TOS == temp save &CCR2 CCI2B_ISR push.w &CCR2 &CCR2 TOS temp save &CCR2 sub.w R15,&CCR2 ;; &CCR2 == capture sub.w R15,&CCR2 &CCR2 capture difference difference cmp.w #244,&CCR2 ;; Delta == SMCLK/(32768/8) cmp.w #244,&CCR2 Delta SMCLK/(32768/8) pop.w R15 ;; R15 == captured SMCLK pop.w R15 R15 captured SMCLK jlo IncDCO jlo IncDCO ;; DecDCO &DCOCTL ;; DecDCO dec.b dec.b &DCOCTL reti ;; reti IncDCO &DCOCTL ;; IncDCO inc.b inc.b &DCOCTL reti ;; reti
45
This library encapsulates routines used for setting the DCO to a specific speed based on a multiplication of a known clock, such as a 32-kHz crystal. These functions are written in assembly to be optimized for the MSP430 but can be called from any C program that includes their header files.
Download from http://www.ti.com/msp430 Code Examples (slaa336)
46
23
VLO Calibration
The VLO frequency is fixed and can not be changed Temperature and VCC influence the VLO frequency Based on a calibrated DCO the actual frequency of the VLO can be measured with a Timer Once the VLO frequency is known, software can adjust timing
47
48
24
Precise Timing
Precise timing Triggering in hardware
MSP430 peripherals offer trigger signals between peripherals e.g. Comparator_A Timer_A Timer_A ADC10 or ADC12 Timer_A DAC12 MSP430 peripherals have additional hardware for precise timing e.g. Timer_A SCCI latch Group load logic in Timer_B and DAC12
Triggering in software
Interrupts add delay to program execution Turn off Interrupts if timing is based on program execution Depending on the addressing mode used, MSP430 instruction execution needs between 1 and 6 MCLK clock cycles Interrupt latency uncertainty of 5 MCLK clock cycles
50
25
Comparator_A+
Timer_A
TACLK ACLK SMCLK INCLK 16-bit Timer TAR Count Mode Set TAIFG CCR0 CCR1 CCI1A CCI1B GND VCC CCI SCCI
A Y EN
Capture Mode
TACCR 1 Comparator 1
CCR2
26
Timer
CA1
CAREF
CAOUT
53
t_NTC = t_10k
- R NTC * C * ln - 10k * C * ln
R_NTC = 10k x
t_NTC t_10k
54
27
28
Timer_A3
TA Clock 15 0 16-bit Timer TAR RC 16 Count Mode Set TAIFG CCR0 logic CCI1A CCI1B GND VCC Capture Mode TA Clock CCI A EN Output Unit1 Sync COV 15
Async 16-Bit timer/counter with four modes Int/ext clock source Three capture/ compare registers Outputs with PWM capability SCCI asynchronous input signal latching Interrupt vector register for fast decoding DMA enabled
/1/2/4/8
SCCI
CCR2
57
100% hardware bit latching and output Full speed from LPM3 and LPM4 Low CPU Overhead App Note SLAA078
58
29
Timer_A UART TX SW
add.w add.w dec.w dec.w jne jne bic.w bic.w reti reti bic.w bic.w rra.w rra.w jc jc bis.w bis.w reti reti
;; Time to Next Bit Time to Next Bit ;; Dec bit counter Dec bit counter ;; Next bit? Next bit? ;; Done, disable int Done, disable int ;; #OUTMOD2,&CCTL0 ;; TX Mark #OUTMOD2,&CCTL0 TX Mark RXTXData ;; LSB->Carry RXTXData LSB->Carry TX_Test ;; Jump if bit == 11 TX_Test Jump if bit #OUTMOD2,&CCTL0 ;; TX Space #OUTMOD2,&CCTL0 TX Space ;;
59
Timer_A UART RX SW
tS t1 t2 t3 t4 t5 t6 t7
ST
Interrupts
1. Capture mode:
Wait for falling edge of start bit and store a time stamp tS of its occurrence in TACCR
2. Compare mode:
1. Program TACCR to t1 = tS + 150% of a bit time This loads 1st bit of RX signal into SCCI latch 2. Program TACCR to t2 = t1 + 100% of a bit time This loads 2nd bit of RX signal into SCCI latch 3. Program TACCR to t3 = t2 + 100% of a bit time This loads 3rd bit of RX signal into SCCI latch .. (continue until all bits are captured)
Capture Mode
TACCR 1 Comparator 1
Output Unit2
CCR2
60
30
Timer_A UART RX SW
TA0_ISR TA0_ISR RX_Edge RX_Edge RX_Bit RX_Bit RX_Test RX_Test RX_Comp RX_Comp RX_Next RX_Next
add.w add.w bit.w bit.w jz jz bic.w bic.w add.w add.w reti reti bit.w bit.w rrc.b rrc.b dec.w dec.w jnz jnz bic.w bic.w reti reti
#Bitime,&CCR0 #Bitime,&CCR0 ; Time to Next Bit ; Time to Next Bit #CAP,&CCTL0 ; Capture mode? #CAP,&CCTL0 ; Capture mode? RX_Bit ; Is start bit edge RX_Bit ; Is start bit edge #CAP,&CCTL0 ; Enable comp. mode #CAP,&CCTL0 ; Enable comp. mode #Bitime_5,&CCR0 ; Add 0.5 T_bit #Bitime_5,&CCR0 ; Add 0.5 T_bit ; ; #SCCI,&CCTL0 ; Read RX latch #SCCI,&CCTL0 ; Read RX latch RXTXData ; Store received bit RXTXData ; Store received bit BitCnt ; All bits RXed? BitCnt ; All bits RXed? RX_Next ; No, next bit RX_Next ; No, next bit #CCIE,&CCTL0 ; All bits RXed! #CCIE,&CCTL0 ; All bits RXed! ; ;
61
31
USART The USART supports 2 or 3 operating modes: Asynchronous RS232 Mode Synchronous SPI Mode (3-Wire & 4 Wire) I2C interface MSP430F15x/16x/16xx (Master & Slave)
64
32
Receiver Buffer URXBUF Receiver Shift Register Baud-Rate Generator Baud-Rate Register UBR Baud-Rate Generator
SNYC RXE Listen MM SOMI SYNC URXD STE SYNC UCLKS UTXD SIMO
Transmit Shift Register Transmit Buffer UTXBUF CKPH SYNC CKPL UCLKI UCLKS
65
N
15 Modulator 8 UMCTL BITCLK
Example1: SMCLK = 1MHz Baud rate = 19200 1,000,000/19,200 = 52.08 0x34 UBR1 | UBR0 = 0x00 0x34; +0.16% error
Example2: ACLK = 32,768Hz Baud rate = 9600 32,768/9,600 = 3.413 UBR1 | UBR0 = 0x00 0x03; UBR1 | UBR0 = 0x00 0x04; +13.8% error -14.7% error
66
33
N
15 Modulator 8 UMCTL BITCLK
A 3 4 3 4 3 3
Table with Baud R Commonly Guide, ate Data, an Used Baud R d chapte a r USA Errors in Us tes, RT in UART ers Mode A
4
bit 2
3
bit 1
3
bit 0
4
stop bit
Modulator mixes adjacent clock dividers to enable high baud rates even with low frequency XTAL.
67
34
69
BITCLK Modulation Pattern 0 -.2 0.7 Bit 0 0 1.0Bit 1 UCBRSx -1.1 (Start Bit) 0 0 1 2 3 4 5 6 7 -2.8 0 0 0 0 0 0 0 0 1.2 0 1 1 1 1 1 1 1
35
BITCLK16
Two modulators RX sampled using BITCLK16 Majority vote always at the same location within one RX bit BITCLK16 supports IrDA TX pulse generation Quasi-standard for UART, IrDA & LIN
/16
BITCLK
71
36
Software ADC trigger Time uncertainty Voltage error Hardware ADC trigger with Timer eliminates phase error Precise timing Precise voltage
73
ADC12
12 Bit SAR 200ksps+ Autoscan Single, sequence, repeat-single, repeat-sequence Int/ext VRef Temp sensor Batt measure TA/TB trigger 16-word conversion buffer DMA enabled
1.5V or 2.5V
AVCC AVSS
ADC12OSC
VR-
V R+
/1 .. /8
12-bit SAR
/4 .. /1024
Sync
Batt Temp
16 x 12 Memory Buffer
16 x 8 Memory Control
74
37
Flash
DMA
DAC
Amp
Timer_A generates sampling rate and triggers DMA DMA loads new digital value from Flash to DAC Wrong trigger sequence because of timing uncertainty for DMA data and address bus access!
76
38
MSP430 DAC12
12-bit monotonic output 8- or 12-bit voltage output resolution Programmable settling time vs power consumption Internal or external reference selection Straight binary or 2s compliment data format Self-calibration option for offset correction Synchronized update capability for multiple DAC12s
77
Flash
DMA
DAC
Amp
Timer_A generates sampling rate and triggers DAC DAC loads output register ADC12_xLatch with value of shadow register ADC12_xDat DAC with empty shadow register ADC12_xDat triggers DMA to get next audio sample from Flash DMA copies digital audio data from Flash to DAC
78
39
Summary
The complete clock chain is important for precise timing:
Oscillators are the source of precise timing
Internal Oscillators DCO, VLO, REFO Crystal oscillators LFXT1 and XT2 FLL (Frequency locked loop) and calibration
79
Thank you
80
40