?? msp430x24x_compa_05.s43
字號:
;******************************************************************************
; MSP430x24x Demo - Comparator A, Poll input CA0, interrupt triggered
;
; Description: Normal operation is in LPM3. When Vcompare crosses the ref
; voltage, an interrupt is generated, and the ISR toggles the LED.
;
;
; MSP430x249
; -----------------
; /|\| |
; | | |
; --|RST P2.3/CA0|<--Vcompare
; | |
; | |
; | P1.0/CAOUT|-->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 WDT
mov.b #CAON+CAREF_2+CARSEL, &CACTL1 ; Enable comp, ref = 0.5*Vcc
mov.b #P2CA0, &CACTL2 ; Pin to CA0
SetupP1 bis.b #BIT0,&P1DIR ; P1.0 = output direction
bis.b #BIT0,&P1SEL ; P1.0 = CAOUT
SetupCAIRQ bis.b #CAIE,&CACTL1 ; Setup interrupt for Comparator
bis.w #GIE,SR ; Enter LPM3, interrupts enabled
mainloop bis.w #LPM3+GIE,SR ; Enter LPM3, enable interrupts
;------------------------------------------------------------------------------
COMPA_ISR ; COMPARATOR A ISR - toggles LED
;------------------------------------------------------------------------------
xor.b #CAIES,&CACTL1 ; Toggles interrupt edge
xor.b #BIT0,&P1OUT ; Toggle P1.0
reti ;
;------------------------------------------------------------------------------
COMMON INTVEC ; Interrupt Vectors
;------------------------------------------------------------------------------
ORG RESET_VECTOR ; MSP430 RESET Vector
DW RESET ;
ORG COMPARATORA_VECTOR ; Comparator A
DW COMPA_ISR
END
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -