clrf PORTA ; I/O Bits Off movlw 7 movwf CMCON0 movf STATUS, w ; Set RP0 Bit to w iorlw 1 << 5 movwf STATUS clrf ANSEL ^ 0x80 ; All Bits Digital movlw b'001111' ; RA4/RA5 Digital Outputs movwf TRISA ^ 0x80 movf STATUS, w ; Clear RP0 andlw 0xFF ^ (1 << 5) movwf STATUS
Loop: ; Return here after toggle clrf Dlay + 1 ; High 8 bits for delay clrf Dlay ; Low 8 bits for delay DlayLoop: movlw 1 ; Decrement Inside Loop subwf Dlay, f movf STATUS, w ; Z Bit Flag Check andlw 1 << 2 ; Check Bit 2 addwf PCL, f ; Add to program counter goto DlayLoop ; Zero, loop around nop nop nop movlw 1 ; Decrement Outside loop subwf Dlay + 1, f movf STATUS, w ; Check Z Bit andlw 1 << 2 addwf PCL, f goto DlayLoop nop nop nop
;
;
Bu program flaş yapar
;
; Hardware Notes:
; PIC16F684 @ 4MHz
; RA4 - LED Positive
; RA5 - LED Negative
;
;
; 23/10/14
;
LIST R=DEC
INCLUDE "p16f684.inc"
__CONFIG _FCMEN_OFF & _IESO_OFF & _BOD_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF & _INTOSCIO
; Variables
CBLOCK 0x20 ;Define Variables, start at memory location Hex 20
Dlay:2
ENDC
PAGE
; Mainline
org 0
nop
clrf PORTA ; I/O Bits Off
movlw 7
movwf CMCON0
movf STATUS, w ; Set RP0 Bit to w
iorlw 1 << 5
movwf STATUS
clrf ANSEL ^ 0x80 ; All Bits Digital
movlw b'001111' ; RA4/RA5 Digital Outputs
movwf TRISA ^ 0x80
movf STATUS, w ; Clear RP0
andlw 0xFF ^ (1 << 5)
movwf STATUS
Loop: ; Return here after toggle
clrf Dlay + 1 ; High 8 bits for delay
clrf Dlay ; Low 8 bits for delay
DlayLoop:
movlw 1 ; Decrement Inside Loop
subwf Dlay, f
movf STATUS, w ; Z Bit Flag Check
andlw 1 << 2 ; Check Bit 2
addwf PCL, f ; Add to program counter
goto DlayLoop ; Zero, loop around
nop
nop
nop
movlw 1 ; Decrement Outside loop
subwf Dlay + 1, f
movf STATUS, w ; Check Z Bit
andlw 1 << 2
addwf PCL, f
goto DlayLoop
nop
nop
nop
movlw 1 << 4 ; Toggle RA4 (D0)
xorwf PORTA, f
goto Loop ; Repeat
end
Bu mesaja 1 cevap geldi. Cevapları Gizle
Bu mesajda bahsedilenler: @egealtay