📄 msp430x21x1_pull-up.asm
字号:
;*****************************************************************************
; MSP430x21x1 Demo - 21x1 Pull-up resistors demo
;
; Description: This program demonstrates how to use the internal pull-ups
; on the 21x1 device. P1.2 is configured for using the pull-up. P1.0
; is configured as output to use the LED as an indicator. The P1.2 interrupt
; is enabled and the device is put into LPM4. When P1.2 goes low, and
; interrupt is generated and the P1_ISR executes. The ISR implements a
; software debounce delay, toggles P1.0 and returns.
; ACLK = n/a, MCLK = SMCLK = default DCO ~1.16MHz
;
;
; MSP430F21x1
; -----------------
; /|\ | XIN|-
; | | |
; ---|RST XOUT|-
; | |
; | P1.2|---- \----
; | | |
; | | GND
;
; H. Grewal / A. Dannenberg
; Texas Instruments, Inc
; July 2005
; Built with Code Composer Essentials Version: 1.0
;******************************************************************************
.cdecls C,LIST, "msp430x21x1.h"
;------------------------------------------------------------------------------
.text ;
;------------------------------------------------------------------------------
RESET mov.w #300h,SP ; Initialize 'x1121 stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
SetupP1 bis.b #001h,&P1DIR ; P1.0 output
mov.b #04h,&P1REN ; Enable resistor on P1.2
mov.b #04h,&P1OUT ; Select pull-up
mov.b #04h,&P1IE ; Enable interrupt
clr.b &P1IFG ; Clear IFG
mov.w #LPM4+GIE,SR ; Enable interrupts, LPM4
;-----------------------------------------------------------------------------
P1_ISR; Toggle P1.0 Output
;-----------------------------------------------------------------------------
Wait mov.w #01FFFh,R15 ; Delay to R15
L1 dec.w R15 ; Decrement R15
jnz L1 ; Delay over?
xor.b #001h,&P1OUT ; P1.0 = toggle
clr.b &P1IFG ; IFG Cleared
reti ; Return from ISR
;-----------------------------------------------------------------------------
; Interrupt Vectors Used MSP430
;-----------------------------------------------------------------------------
.sect ".reset" ; MSP430 RESET Vector
.short RESET ;
.sect ".int02" ; P1.x Vector
.short P1_ISR ;
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -