Chớp tắt led dùng thạch anh trong PIC 16f887 (ASM)

processor   16f887
   
#include <p16f887.inc>
   
__config  _CONFIG1,_HS_OSC&_WDTE_OFF&_PWRTE_ON&_MCLRE_ON&_CP_OFF
    cblock 0x20
count
count_1
count_2
    endc
    org 0x0000
    goto start
    org 0x0004
start
    banksel ANSEL
    clrf ANSEL
    clrf ANSELH
    banksel TRISD
    clrf TRISD
    banksel PORTD
   
   ; clrf PORTD
loop
    MOVLW 0x01
    movwf dat
    clrf dat
loop1
    movf dat,w
    call table
    movwf PORTD
    call delay
    incf dat,f
    movf dat,w
    xorlw .10
    btfss STATUS,Z
    goto loop1
    goto loop
table
    addwf PCL,f
    retlw 0x01
    retlw 0x02
    retlw 0x04
    retlw 0x08
    retlw 0x10
    retlw 0x20
    retlw 0x40
    retlw 0x80
delay
movlw 0x03
movwf count
movlw 0x18
movwf count_1
movlw 0x02
movwf count_2
delay_0
decfsz count,f
goto $+2
decfsz count_1,f
goto $+2
decfsz count_2,f
goto delay_0
goto $+1
return
end



Previous
Next Post »