;USE PIC16C508 OSC=PC,INT=10M,WDT=OFF
;GPIO
INDF EQU 0H ;F0
TMR0 EQU 1H ;F1
RTCC EQU 1H ;TO TMR0
PCL EQU 2H ;F2
STATUS EQU 3H ;F3
FSR EQU 4H
OSCCAL EQU 5H
GPIO EQU 6H
GPWUF EQU 7H
;---------------------------------------------------------
C EQU 0 ;DEF BIT OF F3
DC EQU 1
Z EQU 2
PD EQU 3
TO EQU 4
RP0 EQU 5
RP1 EQU 6
RP2 EQU 7
;----------------------------------------------------------
FSR EQU 4H
W EQU 0H
;------------------------------------------------
GP0 EQU 0
GP1 EQU 1
;------------------------------------------------
TR4 EQU 9H
R0 EQU 0AH
R1 EQU 0BH ;
R2 EQU 0CH ;
TR0 EQU 0DH
TR1 EQU 0EH
TR2 EQU 0FH
ORG 1FFH
GOTO START
ORG 00H
GOTO START
;--------------------------
ORG 05H
DELAY CLRF TMR0
CLRWDT
MOVLW B'00001011'
OPTION
MOVF TR2,W
MOVWF R2
DY2 MOVF TR1,W
MOVWF R1
DY1 MOVF TR0,W
MOVWF R0
DY0 DECFSZ R0,1
GOTO DY0
DECFSZ R1,1
GOTO DY1
DECFSZ R2,1
GOTO DY2
RETLW 0
;--------------------------
DELAY1
MOVLW 5H
MOVWF R0
DY12 CLRF TR4
DY11 DECFSZ TR4,1
GOTO DY11
DECFSZ R0,1
GOTO DY12
RETLW 0
;--------------------------
OUTRB_0
BSF GPIO,GP0
CALL DELAY1
BCF GPIO,GP0
CALL DELAY
RETLW 0
;--------------------------
START CLRW ;SET I/O DIRECTION
CLRWDT
MOVLW B'00000011'
OPTION
CLRF TMR0
CLRWDT
MOVLW B'00001011'
OPTION
MOVLW B'11000000' ;d5_t0cs=1=rtcc,d4_t0se=0,d3_psa=WDT
OPTION
MOVLW B'00111000' ;GP2=T0CK1 GP3=MCLR
TRIS GPIO
MOVLW B'01000000'
MOVWF OSCCAL
MOVLW 40H
MOVWF TR0
MOVWF TR1
MAIN BTFSS GPIO,GP1
GOTO MM0
GOTO MM1
MM0 MOVLW 9
MOVWF TR2
CALL OUTRB_0
CALL OUTRB_0
CALL OUTRB_0
CALL OUTRB_0
CALL OUTRB_0
CALL OUTRB_0
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO MAIN
MM1 MOVLW 9
MOVWF TR2
CALL OUTRB_0
CALL OUTRB_0
CALL OUTRB_0
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO MAIN
;--------------------------
END