|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2016-1-17 21:21:08
|
显示全部楼层
我终于做到最后一个问题了_(:з」∠)_………………
最后求助一下……关于第六题那个比较两种程序辣个,我翻上课的课件的时候好像翻到了这俩,但是关于比较不知道从何下手比较好。。。。求路过的大神帮一下忙TuT
;*******************************************************************************
; MSP430F20xx Demo - P1 Interrupt from LPM4 with Internal Pull-up
;
; Description: A hi/low transition on P1.4 will trigger P1_ISR which,
; toggles P1.0. Normal mode is LPM4 ~ 0.1uA.
; Internal pullup enabled on P1.4.
; ACLK = n/a, MCLK = SMCLK = default DCO
;*******************************************************************************
#include "msp430x20x3.h"
;-------------------------------------------------------------------------------
ORG 0F800h ; Program Reset
;-------------------------------------------------------------------------------
RESET mov.w #0280h,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
SetupP1 bis.b #01h,&P1DIR ; P1.0 output, else input
bic.b #04h,&P1DIR ; P1.4 set, else reset
bis.b #04h,&P1REN ; P1.4 pullup
bis.b #04h,&P1IE ; P1.4 Interrupt enabled
bis.b #04h,&P1IES ; P1.4 hi/low edge
bic.b #04h,&P1IFG ; P1.4 IFG Cleared
;
Mainloop bis.w #LPM4+GIE,SR ; LPM4, enable interrupts
nop ; Required only for debugger
;
;-------------------------------------------------------------------------------
P1_ISR; Toggle P1.0 Output
;-------------------------------------------------------------------------------
xor.b #01h,&P1OUT ; P1.0 = toggle
bic.b #04h,&P1IFG ; P1.4 IFG Cleared
reti ; Return from ISR
;
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
ORG 0FFFEh ; MSP430 RESET Vector
DW RESET ;
ORG 0FFE4h ; P1.x Vector (PORT1_VECTOR)
DW P1_ISR ;
END
;*******************************************************************************
; MSP430F2013 Poll P1 with Internal Pull-up
;
; Description: Poll P1.4 in a loop, if hi P1.0 is set, if low, P1.0 reset.
; Internal pullup enabled on P1.4.
; ACLK = n/a, MCLK = SMCLK = default DCO
;*******************************************************************************
#include "msp430x20x3.h"
;-------------------------------------------------------------------------------
ORG 0F800h ; Program Reset
;-------------------------------------------------------------------------------
RESET mov.w #0280h,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
SetupP1 bis.b #01h,&P1DIR ; P1.0 output, else input
bic.b #04h,&P1DIR ; P1.4 set, else reset
bis.b #04h,&P1REN ; P1.4 pullup
Mainloop bit.b #04h,&P1IN ; P1.4 hi/low?
jc ON ; jmp--> P1.4 is set
;
OFF bic.b #01h,&P1OUT ; P1.0 = 0 / LED OFF
jmp Mainloop ;
ON bis.b #01h,&P1OUT ; P1.0 = 1 / LED ON
jmp Mainloop ;
;
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
ORG 0xFFFE ; MSP430 RESET Vector
DW RESET ;
END
|
|