|
Tài trợ cho PIC Vietnam |
MPASM Lập trình bằng hợp ngữ là một việc làm vô cùng vất vả, tuy nhiên, để hiểu và làm việc với vi điều khiển, hợp ngữ trở thành một công cụ khá đắc lực ... |
|
Ðiều Chỉnh | Xếp Bài |
05-06-2013, 01:54 PM | #1 |
Nhập môn đệ tử
Tham gia ngày: Feb 2013
Bài gửi: 1
: |
đo tốc độ động cơ với 16f84a dùng ngôn ngữ ASM
sao e mô phỏng được nhưng khi làm mạch thực thì không được
processor `16f84a #include <p16f84a.inc> ;---------------------------------------------- ; khai bao bien w_temp equ 0x0C pclath_temp equ 0x0D status_temp equ 0x0E n1 equ 0x0F n2 equ 0x10 n3 equ 0x11 dem_tg equ 0x12 ;---------------------------------------------- org 0x00 goto main org 0x004 movwf w_temp swapf STATUS,w movwf status_temp ;-----------------chuong trinh ngat BCF INTCON,7 btfsc INTCON,1 GOTO INTEXT goto ngat_timer0 INTEXT incf n1,1 ; bcf INTCON,1 movlw d'10' xorwf n1,0 btfsc STATUS,Z goto inc2 goto thoat_ngat inc2 incf n2,1 clrf n1 goto thoat_ngat ngat_timer0 bcf INTCON,2 incf dem_tg,1 movlw d'12' xorwf dem_tg,0 btfsc STATUS,Z call hien_thi ;-----------------tra lai gia tri cho thanh ghi thoat_ngat BSF INTCON,7 swapf status_temp,w movwf STATUS swapf w_temp,w swapf w_temp,f retfie ;---------------------------------------------- main ;---------------------------------------------- bsf STATUS,5 movlw b'00000001' movwf TRISB movlw 0X00 movwf TRISA bcf STATUS,5 clrf PORTB movlw b'00000011' movwf PORTA ;---------------------bat tat ngat timer0_config banksel OPTION_REG bcf OPTION_REG,5 bcf OPTION_REG,3 bsf OPTION_REG,2 bsf OPTION_REG,1 bsf OPTION_REG,0 BCF STATUS,5 bsf INTCON,4 bsf INTCON,5 bsf INTCON,7 ;--------------------- ;===================================== while1 goto while1 ;============================================== hien_thi BCF STATUS,5 clrf dem_tg movf n1,w call table bsf PORTA,1 bcf PORTA,0 movwf PORTB call delay call delay call delay call delay movf n2,W call table bcf PORTA,1 bsf PORTA,0 movwf PORTB call delay call delay call delay call delay clrf n1 clrf n2 return ;------------------------------- delay movlw 0xff movwf n3 loop12 decfsz n3 goto loop12 return ;------------------------------- table addwf PCL,1 retlw 0x81 retlw 0xf3 retlw 0x49 retlw 0x61 retlw 0x33 retlw 0x25 retlw 0x05 retlw 0xf1 retlw 0x01 retlw 0x21 end các a chỉ giúp e với |