LIST p=16F628
include "P16F628.inc"
__config 0x3D18
cblock 0x20
cnt1 ;for delay routine
cnt2 ;for delay routine
cnt3 ;for delay routine
endc
org 0x0000
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)
bsf STATUS, RP0
movlw B'00100000' ;set PortA 1 inputs, 7 outputs
movwf TRISA
bcf STATUS, RP0
clrf PORTA ;set all outputs low
bsf PORTA, 4
Loop btfss PORTA, 5 ;wait for press "reset"
call short
goto Loop
short call Delay ; delay ~700ms
btfsc PORTA, 5 ; verify if "reset" is pressed
call output1 ; if not execute output1
bsf PORTA, 0
bcf PORTA, 1 ; here I need output GND. I don't know how and if it's possible
bsf PORTA, 2
bsf PORTA, 4 ; here I need output GND. I don't know how and if it's possible
goto finish ; "stop" program, execute countinous loop
output1 bcf PORTA, 0 ; here I need output GND. I don't know how and if it's possible
bsf PORTA, 1
bcf PORTA, 2 ; here I need output GND. I don't know how and if it's possible
bcf PORTA, 4
goto finish
Delay movlw 3 ; delay routine ~700ms
movwf cnt3
movlw b'11111111'
movwf cnt2
movlw b'11111111'
movwf cnt1
decfsz cnt3, F
goto $+2
goto $+0A
decfsz cnt2, F
goto $+2
goto $+6
btfsc PORTA, 5 ; verify if "reset" is pressed
retlw 0x00 ; if not return
decfsz cnt1, F
goto $-1
goto $-7
goto $-0B
movlw b'01111111'
movwf cnt2
movlw b'11111111'
movwf cnt1
decfsz cnt2, F
goto $+2
goto $+6
btfsc PORTA, 5 ; verify if "reset" is pressed
retlw 0x00 ; if not return
decfsz cnt1, F
goto $-1
goto $-7
movlw 89
movwf cnt1
decfsz cnt1, F
goto $-1
retlw 0x00 ;return after delay it's over
finish sleep ; stop all, it's enough ;-)
end