📄 fet110_ta_cap01.s43
字号:
#include "msp430x11x1.h"
;******************************************************************************
; MSP-FET430x110 Demo - Timer_A Ultra-low Power 1200hz detect, ACLK +/- 5%
;
; Description; Using Timer_A capture capability. At 250ms intervals,
; CCR0 is enabled on P2.2 to detect presence or absence of 1200Hz. If
; 1200Hz is present, P1.0 is set, if not, reset. WDT is used for 250ms
; wake-up to hunt for tone. System runs normally in LPM3.
; //*External watch crystal installed on XIN XOUT is required for ACLK*//
;
; 32768Hz = ACLK
; 1200Hz = 27.3 ACLK clocks
; 1260Hz = 26 ACLK clocks
; 1730Hz = 28 ACLK clock
;
; MSP430F1121
; -----------------
; /|\| XIN|-
; | | | 32k
; --|RST XOUT|-
; | |
; Signal->|P2.2/CCR0 P1.0|-->LED
; | |
;
;
; CPU registers used
#define Period R15
#define OldCap R14
;
; M.Buccini
; Texas Instruments, Inc
; January 2002
;******************************************************************************
;------------------------------------------------------------------------------
ORG 0F000h ; Program Start
;------------------------------------------------------------------------------
RESET mov.w #300h,SP ; Initialize stackpointer
SetupWDT mov.w #WDT_ADLY_250,&WDTCTL ; WDT 250ms Interval Timer
bis.b #WDTIE,&IE1 ; Enable WDT Interrupt
SetupP1 mov.b #0FFh,&P1DIR ; All P1.x Outputs
clr.b &P1OUT ; All P1.x Reset
SetupP2 mov.b #0FBh,&P2DIR ; P2.2 Input / All P2.x Output
bis.b #004h,&P2SEL ; P2.2 CCR0 input
clr.b &P2OUT ; All P2.x Reset
eint ; Enable Interrupts
;
Mainloop bis.w #LPM3,SR ; Enter LPM3
call #Get_CCR0 ; Capture CCR0 on P2.2
cmp.w #029,Period ;
jhs OFF ;
cmp.w #026,Period ;
jlo OFF ;
;
ON bis.b #001h,&P1OUT ; P1.0 = 1
jmp Mainloop ;
OFF bic.b #001h,&P1OUT ; P1.0 = 0
jmp Mainloop ;
;
;------------------------------------------------------------------------------
Get_CCR0; Subroutine to get CCR0 Capture
;------------------------------------------------------------------------------
clr Period ;
clr OldCap ;
mov #TASSEL0+TACLR,&TACTL ; ACLK, TAR cleared
SetupC0 mov #CCIS0+CM0+CAP+CCIE+SCS,&CCTL0 ; CCI0B, CAP, interrupt
bis #MC1,&TACTL ; Start timer in Ccntinous mode
Test_1 cmp #0112,&TAR ; Timeout
jlo Test_1 ; jump if 112 > &TAR
clr &TACTL ; Stop Timer_A
clr &CCTL0 ; Stop CCTL0
ret ;
;
;------------------------------------------------------------------------------
TA0_ISR; Timer_A C0 ISR
;------------------------------------------------------------------------------
push.w &CCR0 ; Captured TAR, rising edge
mov.w @SP,Period ;
sub.w OldCap,Period ; New - old = period
pop.w OldCap ; For next calculation
reti ;
;
;------------------------------------------------------------------------------
WDT_ISR; Exit LPM3 on reti
;------------------------------------------------------------------------------
bic.w #LPM3,0(SP) ; Clear LPM3 from TOS
reti ;
;
;------------------------------------------------------------------------------
; Interrupt Vectors Used MSP430x11x1
;------------------------------------------------------------------------------
ORG 0FFFEh ; MSP430 RESET Vector
DW RESET ;
ORG 0FFF4h ; WDT Vector
DW WDT_ISR ;
ORG 0FFF2h ; Timer_A0 Vector
DW TA0_ISR ;
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -