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

📄 dco_2mhz_1xx.asm

📁 ti发布的MSP430 dco库 使用非常方便
💻 ASM
字号:
;*******************************************************************************
;  MSP430x11x1 Demo - Basic Clock, Output Buffered SMCLK, ACLK and MCLK/10
;
;  Description: Buffer ACLK on P2.0, default SMCLK(DCO) on P1.4 and MCLK/10 on
;  P1.1. To measure SMCLK on P1.4 with the FET, use "Release JTAG on Go"
;  in the debugger to have access to the port. Then run the code.
;  ACLK = LFXT1 = 32768, MCLK = SMCLK = 2MHz
;  //* External watch crystal installed on XIN XOUT is required for ACLK *//	
;
;               MSP430F1121
;             -----------------
;         /|\|              XIN|-
;          | |                 | 32kHz
;          --|RST          XOUT|-
;            |                 |
;            |       P1.4/SMCLK|-->SMCLK = ~2Mhz
;            |             P1.1|-->MCLK/10 = DCO/10
;            |        P2.0/ACLK|-->ACLK = 32kHz
;
;  L. Westlund
;  Texas Instruments Inc.
;  March 2006
;  Built with IAR Embedded Workbench Version: 3.40A
;*******************************************************************************
 .cdecls C,LIST,    "msp430x11x1.h"
 .ref    TI_SetDCO
;------------------------------------------------------------------------------
            .text
;------------------------------------------------------------------------------
RESET       mov.w   #0x300,        SP       ; Initialize stackpointer
StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT
SetupPx     bis.b   #013h,&P1DIR            ; P1.1,4 output direction
            bis.b   #010h,&P1SEL            ; P1.4 = SMCLK
            bis.b   #001h,&P2DIR            ; P2.0 output direction
            bis.b   #001h,&P2SEL            ; P2.0 = ACLK
                                            ;
            mov.w   #0xFFFF, r15            ; Delay for ACLK startup
Loop        dec.w   r15
            jnz     Loop

            mov.w   #488, r12               ; value for 2MHz
            call    #TI_SetDCO
            cmp.w   #0x00, r12
            jz      Mainloop
            cmp.w   #0xFF, r12
            jz      TimeoutError
            cmp.w   #0x02, r12              ; compare returned value
            jl      SlowestError            ; 1 = DCO set to slowest
            jz      FastestError            ; 2 = DCO set to fastest setting
            jn      TimeoutError            ; 0xFF = loop timeout error
                                            ;
Mainloop    bis.b   #001h,&P1OUT            ; P1.1 = 1
            bic.b   #001h,&P1OUT            ; P1.1 = 0
            jmp     Mainloop                ; Repeat
SlowestError
            nop                             ; set breakpoint here
            jmp     SlowestError
FastestError
            nop                             ; set breakpoint here
            jmp     FastestError
TimeoutError
            nop                             ; set breakpoint here
            jmp     TimeoutError
;------------------------------------------------------------------------------
;           Interrupt Vectors
;------------------------------------------------------------------------------
            .sect   ".reset"                ; MSP430 RESET Vector
            .short  RESET                   ;
            .end

⌨️ 快捷键说明

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