📄 msp430x42x0_ta_25.s43
字号:
;******************************************************************************
; MSP430x42x0 Demo - Timer_A, Output DTMF, Cont. Mode, DCO SMCLK
;
; Description: This program outputs two tones on P1.2 and P1.3 using
; Timer_A configured for continuous mode. The outputs toggle at 2x the
; required frequency, thus producing a square wave the the target
; frequencies. The index value (0, 2, 4, or 6) in R4 points to low a
; frequency value stored in DTMF_TABlo, the index in R5 points to a high
; frequency value stored in DTMF_TABhi.
; ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz
; //* An external watch crystal between XIN & XOUT is required for ACLK *//
;
; MSP430F4270
; -----------------
; /|\| XIN|-
; | | | 32kHz
; --|RST XOUT|-
; | |
; | P1.2/TA1|--> DTMF_lo
; | P1.3/TA2|--> DTMF_hi
;
; L. Westlund / S. Karthikeyan
; Texas Instruments Inc.
; June 2005
; Built with IAR Embedded Workbench Version: 3.30A
;******************************************************************************
#include <msp430x42x0.h>
DTMF_lo EQU 0200h
DTMF_hi EQU 0202h
MCLK EQU 1048576
;------------------------------------------------------------------------------
ORG 08000h ; Program Start
;------------------------------------------------------------------------------
RESET mov.w #300h,SP ; Initialize stackpointer
call #Init_Sys ; Initialize System Peripherals
clr.w R4 ;
clr.w R5 ;
;
Mainloop call #Send_DTMF ;
jmp $ ;
;
;-----------------------------------------------------------------------------
Send_DTMF
;-----------------------------------------------------------------------------
mov.w DTMF_TABlo(R4),DTMF_lo ;
mov.w DTMF_TABhi(R5),DTMF_hi ;
SetupC1 mov.w #OUTMOD2+CCIE,&CCTL1 ; CCR1 toggle, interrupt
SetupC2 mov.w #OUTMOD2+CCIE,&CCTL2 ; CCR2 toggle, interrupt
push.w &TAR ; Delay until DTMF start
add.w #000FFh,0(SP) ;
mov.w 0(SP),&CCR1 ;
pop.w &CCR2 ;
ret ;
;
;-----------------------------------------------------------------------------
Init_Sys; Initialize System Peripherals
;-----------------------------------------------------------------------------
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
SetupFLL bis.b #XCAP14PF,&FLL_CTL0 ; Configure load caps
SetupTA mov.w #TASSEL1+MC1,&TACTL ; SMCLK, continuous mode
SetupP1 bis.b #00Ch,&P1DIR ; P1.2 output
bis.b #00Ch,&P1SEL ; P1.2 TA1,2 output
eint ;
ret ; Return from subroutine
;
;-----------------------------------------------------------------------------
TAX_ISR; Common ISR - CCR1-4 and overflow
;-----------------------------------------------------------------------------
add.w &TAIV,PC ; Add offset to jump table
reti ; Vector 0 - no interrupt
jmp TA1_ISR ; CCR1
jmp TA2_ISR ; CCR2
reti ; Vector 6 - reserved
reti ; Vector 8 - reserved
reti ; TAIFG - no source
;
TA1_ISR add.w DTMF_lo,&CCR1 ;
reti ;
;
TA2_ISR add.w DTMF_hi,&CCR2 ;
reti ;
;
EVEN ;
DTMF_TABlo DW ((MCLK/697)+1)/2 ; Generates 697 Hz
DW ((MCLK/770)+1)/2 ; Generates 770 Hz
DW ((MCLK/852)+1)/2 ; Generates 852 Hz
DW ((MCLK/941)+1)/2 ; Generates 941 Hz
DTMF_TABhi DW ((MCLK/1209)+1)/2 ; Generates 1209 Hz
DW ((MCLK/1336)+1)/2 ; Generates 1336 Hz
DW ((MCLK/1477)+1)/2 ; Generates 1477 Hz
DW ((MCLK/1633)+1)/2 ; Generates 1633 Hz
;
;-----------------------------------------------------------------------------
; Interrupt Vectors
;-----------------------------------------------------------------------------
ORG 0FFFEh ; RESET Vector
DW RESET ;
ORG 0FFEAh ; Timer_AX Vector
DW TAX_ISR ;
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -