LIST P=16F877A
INCLUDE "P16F877A.INC"
DELAY1 EQU 0X20
DELAY2 EQU 0X21
DELAY3 EQU 0X22
REG1 EQU 0X34
ORG 0x00
GOTO MAIN
MAIN BSF STATUS,RP0
MOVLW B'00000010' ;TWO INDEPENDENT COMPORATORS
MOVWF CMCON
MOVLW B'00111111' ;IN
MOVWF TRISB ;IN
MOVLW B'11111111' ;OUT
MOVWF TRISC ;OUT
BCF STATUS,RP0
START
MOVLW 00H
MOVWF REG1
LOOP
CALL DELAY
BTFSC PORTB,1
CALL TEMP
GOTO LOOP
TEMP
MOVLW 02H
MOVWF PORTC
RETURN
DELAY
MOVLW D'20'
MOVWF DELAY1
THIRD
MOVLW D'255'
MOVWF DELAY2
SECOND
MOVLW D'255'
MOVWF DELAY3
FIRST
DECFSZ DELAY3,1
GOTO FIRST
DECFSZ DELAY2,1
GOTO SECOND
DECFSZ DELAY1,1
GOTO THIRD
RETURN
END