![](http://datasheet.mmic.net.cn/370000/TAS3001EVM_datasheet_16735494/TAS3001EVM_24.png)
5-4
jnz
incd
RET
DELAY3
;
;
SP
;****************************************************************************
;
Set_DCO Subroutine: Set DCO to selected frequency.
;
Count1 = R8 and Count2 = R9 are used and not saved.
;****************************************************************************
Set_DCO
;
JMPskipdco
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
BIS
#MC1,&TACTL
;start timer
—
continous Mode
CLR
Count1
;clear counter
MOV
#CCIS0+CM0+CAP,&CCTL2 ;Define CCR2: capture input signal
;=ACLK, capture on rising edge,
;set to capture mode
Test_DCO BIT
#CCIFG,&CCTL2
;intrpt flag set yes=value captured
JZ
Test_DCO
;flag not set = loop again
BIC
#CCIFG,&CCTL2
;clear interrupt flag
AdjDCO
MOV
&CCR2,Count2
;contents of cap/com reg2 ->Count2
SUB
Count1,Count2
;Count2-Count1 --> Count2
MOV
&CCR2,Count1
;contents of cap/com reg2 ->Count1
CMP
#Delta,Count2
;Delta=Count2 Delta = SMCLK/(32768/4)
JL
IncDCO
;jump if Count2 < Delta
JEQ
DoneDCO
;jump if Count2 = Delta
DecDCO
DEC.b &DCOCTL
;decrease DCO frequency
JMP
Test_DCO
;jump to test new setting
IncDCO
INC.b &DCOCTL
;increase DCO frequency
JMP
Test_DCO
;jump to test new setting
DoneDCO
CLR &CCTL2
;DCO calibrated. stop CCR2
;skipdco
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
RET
;return from setup / cal routine
;****************************************************************************
; I2C send & test for end of data
;****************************************************************************
Loop
XOR.b #LED,&LED_OUT
;LED momentarily swithed to indicate I2C
;data being sent
Loop2 CMP.b #0,Data(Tbl_Pntr) ;first byte in string is no. of data bytes
;to follow before next stop is issued
JZ LP_END
;if first byte in string = 0 then end
MOV.b Data(Tbl_Pntr),Strng_Pntr ;set string pointer = (table pointer)
CALL
#I2C
;call routine to send Dig Spkr data byte via I2C
JMP
Loop2
;loop to send next data byte string
LP_END
CALL
#DELAY
XOR.b #LED,&LED_OUT
;LED switched back to original state = off at
;start up, on in shift (EQ) mode
RET
;return from call
;****************************************************************************
;
I2C subroutines
;****************************************************************************
;******************** send start, set up mask
I2C
BIS.B #SDA,&SDAEN
;start Condition: set SDA low
INC
Tbl_Pntr
;increment to first data byte in string