⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fet410_ta_dtmf.s43

📁 MSP430常用的程序源代码,很全的,一定适合你(初学者)!
💻 S43
字号:
#include  "msp430x41x.h"
;******************************************************************************
;   MSP-FET430P410 Demo - Timer_A used to generate DTMF using UpMode, DCO SMCLK 
;
;   Description; This program will generate a two tones on P1.2 and P2.0 using 
;   Timer_A in continous mode.  The outputs toggle at 2x the required 
;   frequency, producing a square wave the the target frequencies. The value
;   (0,2,4,6) in R4 points to low frequency stored in DTMF_lo, R5 points to 
;   the high frequency stored in DTMF_hi.  
;   ACLK = LFXT1 = 32768, MCLK =  SMCLK = TACLK = DCO =32XACLK =  1.048576MHz
;   //*An external watch crystal is required on XIN/XOUT for ACLK*//	  
;
;
;                 MSP430F413
;             -----------------
;         /|\|              XIN|-  
;          | |                 | 32k
;          --|RST          XOUT|-
;            |                 |
;            |        CCR1/P1.2|--> DTMF_lo 
;            |        CCR2/P2.0|--> DTMF_hi
;
;
DTMF_lo     equ     0200h
DTMF_hi     equ     0202h
MCLK        equ     1048576
;
;
;   M.Buccini
;   Texas Instruments, Inc
;   January 2002
;******************************************************************************
;------------------------------------------------------------------------------ 
            ORG     0E000h                  ; 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 continous
SetupP1     bis.b   #004h,&P1DIR            ; P1.2 output
            bis.b   #004h,&P1SEL            ; P1.2 TA1 output
SetupP2     bis.b   #001h,&P2DIR            ; P2.0 output
            bis.b   #001h,&P2SEL            ; P2.0 TA1 output
            eint                            ;
            ret                             ; Return from subroutine
                                            ;
;----------------------------------------------------------------------------- 
TAX_ISR;    Common ISR - CCR1-4 and overflow
;----------------------------------------------------------------------------- 
            add.w   &TAIV,PC                ; Add Timer_A offset vector
            reti                            ; CCR0 - no source
            jmp     TA1_ISR                 ; CCR1
            jmp     TA2_ISR                 ; CCR2
;            reti                            ; CCR3 - not used
;            reti                            ; CCR4 - not used
;TA_over     reti                            ; TA overflow - not used		 
                                            ;
TA1_ISR     add.w   DTMF_lo,&CCR1           ;
            reti                            ;
                                            ;
TA2_ISR     add.w   DTMF_hi,&CCR2           ;
            reti                            ;
                                            ;
            even                            ;
DTMF_TABlo  DW      ((MCLK/697)+1)/2        ;
            DW      ((MCLK/770)+1)/2        ;
            DW      ((MCLK/852)+1)/2        ;
            DW      ((MCLK/941)+1)/2        ;
DTMF_TABhi  DW      ((MCLK/1209)+1)/2       ;
            DW      ((MCLK/1336)+1)/2       ;
            DW      ((MCLK/1477)+1)/2       ;
            DW      ((MCLK/1633)+1)/2       ;
                                            ;            
;----------------------------------------------------------------------------- 
;           Interrupt Vectors Used MSP430F41x          
;----------------------------------------------------------------------------- 
            ORG     0FFFEh                  ; MSP430 RESET Vector
            DW      RESET                   ; 
            ORG     0FFEAh                  ; Timer_AX Vector
            DW      TAX_ISR                 ; 
            END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -