Texas Instruments MSP430x1xx User Manual
Page 116

Features for Low-Power Applications
7-16
b) In x13x and x14x devices, the XT2 oscillator can also be used: XT2Off
is reset
BIC.B
#XT2Off,&BCSCTL1
; Reset XT2Off to turn on LFXT1
; oscillator
2) Wait until the oscillator, which will be used for MCLK, is settled.
Three possibilities are:
a) Always wait enough time so the oscillator is settled under all condi-
tions. The time differs with the crystal type (watch crystal, standard
crystal, resonator) and needs to be evaluated with the application.
PUSH
#Wait
; Load wait time constant onto stack
Loop
DEC
0 (SP)
; Count wait time down to zero
JNZ
Loop
; Wait time not completed > go to loop
; Wait time = t(MCLK) x (4+2)
BIC.B
#OFIFG,&IFG1 ; Clear osc. fault int. flag
BIS.B
#(SELM1+SELM0),&BCSCTL2 ; Select now LFXT1 clock
b) Wait until the oscillator-fault test (reset OFIFG and then test if OFIFG
is reset) indicates that the oscillator has started. Then wait enough
time so that the oscillator amplitude is settled.
TST_OF
BIC.B
#OFIFG,&IFG1 ; Clear osc. fault int. flag
Loop
DEC
0 (SP)
; Count wait time down to zero
JNZ
Loop
; Wait time not completed > go to loop
BIT.B
#OFIFG,&IFG1 ; Test oscillator fault flag
JNZ
TST_OF
; Repeat test until flag remains reset
PUSH
#Wait
; Load wait time constant onto stack
BIC.B
#OFIFG,&IFG1 ; Clear osc. fault int. flag
BIS.B
#(SELM1+SELM0),&BCSCTL2 ; Select now LFXT1 clock
c)
Wait until the oscillator-fault test (reset OFIFG and then test if OFIFG
is reset) indicates that the oscillator has started. Then count pulses
from the oscillator. A typical number is 1024 pulses and needs to be
verified under the final application conditions.
TST_OF
BIC.B
#OFIFG,&IFG1 ; Clear oscillator fault interrupt
; flag
BIT_B
#OFIFG,&IFG1 ; Test oscillator fault flag
JNZ
TST_OF
; Repeat test until flag remains reset
;* Use Watchdog/Timer with ACLK/2, SSEL=1, IS1=1, IS0=0, RST/NMI is
;* reset pin and Watchdog/Timer in Timer function, counter is
;* cleared.
BIS.B
#DIVA0,&BCSCTL1 ; Assumes that DIVA.1 bit is reset
BIC.B
#WDTIE,&IE1 ; No interrupt from Watchdog/Timer
BIC.B
#WDTIFG,&IFG1 ; Clear WDTIFG: it indicates 1024
; pulses from XT1
MOV
#(WDTPW+WDTTMSEL+WDTCNTCL+WDTSSEL+WDTIS1),&WDTCTL
Retest
BIT.B
#WDTIFG,&IFG1 ; Test if 1024 pulses completed