msp430x24x_tb_03.s43

来自「步进电机驱动程序msp430f247单片机」· S43 代码 · 共 61 行

S43
61
字号
;*******************************************************************************
;  MSP430x24x Demo - Timer_B, Toggle P1.0, Overflow ISR, DCO SMCLK
;
;  Description: Toggle P1.0 using software and Timer_B overflow ISR.
;  In this example an ISR triggers when TB overflows.  TB overflow has the 
;  lowest priority. Inside the TB overflow ISR P1.0 is toggled. Toggle rate is 
;  approximatlely ~ [1.04MHz/FFFFh]/2. Proper use of TBIV interrupt vector 
;  generator is shown.
;  ACLK = n/a, MCLK = SMCLK = TBCLK = default DCO ~1.045MHz.
;
;           MSP430F249
;         ---------------
;     /|\|            XIN|-
;      | |               |
;      --|RST        XOUT|-
;        |               |
;        |           P1.0|-->LED
;
;   B. Nisarga
;   Texas Instruments Inc.
;   September 2007
;   Built with IAR Embedded Workbench Version: 3.42A
;*******************************************************************************
#include "msp430x24x.h"

;-------------------------------------------------------------------------------
            RSEG    CSTACK                  ; Define stack segment
;-------------------------------------------------------------------------------
            RSEG    CODE                    ; Assemble to Flash memory
;-------------------------------------------------------------------------------
RESET       mov.w   #SFE(CSTACK),SP         ; Initialize stackpointer
StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop watchdog timer
SetupP1     bis.b   #01h, &P1DIR            ; Set P1.0 to output direction
            mov.w   #TBSSEL_2 + MC_2 + TBIE, &TBCTL ;SMCLK, contmode, interrupt
                                            ;
Mainloop    bis.w   #CPUOFF+GIE,SR          ; CPU off, interrupts enabled
            nop                             ; Required for debugger
                                            ;
;-------------------------------------------------------------------------------
TBX_ISR;    Common ISR for overflow
;-------------------------------------------------------------------------------
            add.w   &TBIV,PC                ; Add Timer_B offset vector
            reti                            ;
            reti                            ; TBCCR1 not used
            reti                            ; TBCCR2 not used
            reti                            ;
            reti                            ;
            reti                            ;
            reti                            ;
TB_over     xor.b   #001h,&P1OUT            ; Toggle P1.0
            reti                            ; Return from overflow ISR
                                            ;
;-------------------------------------------------------------------------------
            COMMON  INTVEC                  ; Interrupt Vectors
;-------------------------------------------------------------------------------
            ORG     RESET_VECTOR            ; MSP430 RESET Vector
            DW      RESET                   ;
            ORG     TIMERB1_VECTOR          ; Timer_BX Vector
            DW      TBX_ISR                 ;
            END

⌨️ 快捷键说明

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