H
huunho
Guest
Đây là code asm trên iar cho 2152: chạy ok lắm nên tặng các bạn
Code:
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
LED_ EQU 001h ; led p1.0
#include <msp430g2152.h>
;-------------------------------------------------------------------------------
ORG 0FC00h ; Program Reset
;-------------------------------------------------------------------------------
RESET mov.w #027Eh,SP ; Initialize stackpointer
mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
MOV.B &CALBC1_1MHZ,&BCSCTL1 ; Set RSELx --BCSCTL1 = 86h
MOV.B &CALDCO_1MHZ,&DCOCTL ; Set DCOx and MODx --DCOCTL = 91h
bis.b #LED_+BIT6,&P1DIR
bic.b #LED_+BIT6,&P1OUT
main:
bis.b #BIT5,&P1SEL2; P1.5 PIN OSD ON
mov.w #TACLR,&TA0CTL; clear TA
mov.w #TASSEL_3+MC_2,&TA0CTL // INCLK, start continue up mode
call #delay_key;
mov.w #CM_3+CCIS_3+CAP+SCS,&TA0CCTL1 // Pos&Neg,GND,Ca
XOR #CCIS0,&TA0CCTL1;
mov.w &CCR1,R4;
bic.b #BIT5,&P1SEL2; P1.5 PIN OSD OFF
cmp.w #01700h,R4;
jn next1;
jmp next2;
next1:
xor.b #BIT6,P1OUT;
call #LED;
next2:
jmp main;
;-------------------------------------------------------------------------------
LED
xor.b #LED_,&P1OUT ; led = toggle
call #delay
xor.b #LED_,&P1OUT ; led = toggle
RET
;-------------------------------------------------------------------------------
delay
MOV #0FFFFh,R6;
L1d:
DEC.W R6
JNZ L1d
ret;
;-------------------------------------------------------------------------------
delay_key
MOV #01000,R6; 3000 us
L2d:
DEC.W R6
JNZ L2d
ret;
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
ORG 0FFFEh ; MSP430 RESET Vector
DW RESET ;
END