📄 glass_breakage_detector.s43
字号:
; non inv input OA0I0 P2.0
; off mode, OA0O at A13 & P2.1
OP1 mov.b #OAFC_2,&OA1CTL1_ ; Unity gain buffer
mov.b #OAP_3+OAPM_0+OAADC0,&OA1CTL0_
; non inv input OA1I1 P4.6
; off mode, OA1O at A13 & P4.4
bis.b #0f0h,&ADC10AE1 ; P4.4 OA1O, P4.6 OA1I3
ret
;-------------------------------------------------------------------------------
SetupTA; Setup TA wake up
;-------------------------------------------------------------------------------
mov.w #TASSEL0, TACTL ; TACLK=ACLK=VLO
mov.w #OUTMOD_4+CCIE, TACCTL0 ; toggle mode @ P1.1, CCRO IE
mov.w #TACCR0_2ms, TACCR0 ;
ret
;-------------------------------------------------------------------------------
SetDCO_12Mhz; Set DCO to 12Mhz and ACLK = VLO
;-------------------------------------------------------------------------------
mov.b &CALBC1_12MHZ,&BCSCTL1 ; set range
mov.b &CALDCO_12MHZ,&DCOCTL ; set DCO step + modulation
mov.b #LFXT1S_2, &BCSCTL3 ; ACLK = VLO
ret
;-------------------------------------------------------------------------------
SetDCO_8Mhz; Set DCO to 8Mhz and ACLK = VLO
;-------------------------------------------------------------------------------
mov.b &CALBC1_8MHZ,&BCSCTL1 ; set range
mov.b &CALDCO_8MHZ,&DCOCTL ; set DCO step + modulation
mov.b #LFXT1S_2, &BCSCTL3 ; ACLK = VLO
ret
;------------------------------------------------------------------------------
delay_12Mhz;
;------------------------------------------------------------------------------
clr R14
clr R13
incr_R13 inc.w R13
incr_R14 inc.w R14
cmp #12000, R14
jnz incr_R14
clr R14
cmp #1000, R13
jnz incr_R13
ret
;------------------------------------------------------------------------------
delay_8MHz_AAF;
;------------------------------------------------------------------------------
clr R14
clr R13
inc_R13 inc.w R13
inc_R14 inc.w R14
cmp #25, R14
jnz inc_R14
clr R14
cmp #1, R13
jnz inc_R13
ret
;------------------------------------------------------------------------------
delay_8MHz_no_AAF;
;------------------------------------------------------------------------------
clr R14
clr R13
inc_R13_ inc.w R13
inc_R14_ inc.w R14
cmp #1, R14
jnz inc_R14_
clr R14
cmp #1, R13
jnz inc_R13_
ret
;------------------------------------------------------------------------------
WDF; Bi-reciprocal WDF fs=38900
;------------------------------------------------------------------------------
// upper branch \\
; ** alpha 3 stage ** gamma=-0.375 -> Type 3, alpha=0.375
mov.w INPUT, inp13 ; WDF input
mov.w delay1, inp23
mov.w outp23, delay1
mov.w inp13, temp1
sub.w inp23, temp1
mov.w temp1, p13 ; p13=inp13-inp23
; begin shift & add multipication using horner method
clr.w temp2
sub.w temp1, temp2
mov.w temp2, temp1 ; negate temp1
rra.w temp1
rra.w temp1
add.w p13, temp1 ; 2
rra.w temp1 ; 1
; end shift & add multipication using horner method
mov.w temp1, temp2
sub.w inp13, temp2
mov.w temp2, outp23 ; outp23=temp1-inp13
sub.w inp23, temp1
mov.w temp1, outp13 ; outp13=temp1-inp23
; ** alpha 1 stage ** gamma=-0.109375 -> Type 3 alpha=0.109375
mov.w INPUT, inp11 ; WDF input
mov.w delay2, inp21
mov.w outp21, delay2
mov.w inp11, temp1
sub.w inp21, temp1
mov.w temp1, p11 ; p11=inp11-inp21
; begin shift & add multipication using horner method
clr.w temp2
sub.w temp1, temp2
mov.w temp2, temp1 ; negate temp1
rra.w temp1
rra.w temp1
rra.w temp1
add.w p11, temp1 ; 3
rra.w temp1
rra.w temp1
rra.w temp1
; end shift & add multipication using horner method
mov.w temp1, temp2
sub.w inp11, temp2
mov.w temp2, outp21 ; outp21=temp1-inp11
sub.w inp21, temp1
mov.w temp1, outp11 ; outp11=temp1-inp21
; ** alpha 5 stage ** gamma=-0.75 -> Type 4 alpha=0.75
mov.w outp11, inp15
mov.w delay3, inp25
mov.w outp25, delay3
mov.w inp25, temp1
sub.w inp15, temp1
mov.w temp1, p15 ; p15=inp25-inp15
; begin shift & add multipication using horner method
rra.w temp1
rra.w temp1
; end shift & add multipication using horner method
sub.w inp25, temp1
mov.w temp1, outp25 ; outp25=temp1-inp25
mov.w outp25, temp2
sub.w p15, temp2
mov.w temp2, outp15 ; outp15=outp25-p15
; begin final output
mov.w delay4, OUTP
sub.w outp15, OUTP ; high pass output
rra OUTP ; divide output by two
mov.w outp13, delay4
; end final output
ret
;-------------------------------------------------------------------------------
INITMEM; INIT Memory
;-------------------------------------------------------------------------------
clr.w INPUT
clr.w OUTP
clr.w inp11
clr.w inp21
clr.w outp11
clr.w outp21
clr.w inp13
clr.w inp23
clr.w outp13
clr.w outp23
clr.w inp15
clr.w inp25
clr.w outp15
clr.w outp25
clr.w delay1
clr.w delay2
clr.w delay3
clr.w delay4
clr.w temp1
clr.w temp2
clr.w avg_1
clr.w avg_2
clr.w avg_3
clr.w res_avg
clr.w avg_temp_1
clr.w avg_temp_2
clr.w peaks
clr.w zeros
clr.w integ_total
clr.w integ_HPB
clr.w sample_count
clr.w sample_count_2
clr.w div_count_1
clr.w div_count_2
clr.w ratio_false
clr.w peak_false
clr.w zero_false
ret
;------------------------------------------------------------------------------
COMMON INTVEC ; Interrupt Vectors
;------------------------------------------------------------------------------
ORG RESET_VECTOR ; MSP430 RESET Vector
DW RESET ;
ORG TIMERA0_VECTOR ; Timer_A0 Vector (CCRO IFG only)
DW TA0_ISR ;
ORG ADC10_VECTOR ; ADC10 Vector
DW ADC10_ISR ;
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -