list p=16F628A ; list directive to define processor
#include <p16F628A.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _HS_OSC
;**********************************************************************
reg1 equ 0x20
reg2 equ 0x21
reg3 equ 0x22
w_temp equ 0x23
;***********************************************************************
start: org 0x0000
goto mainProg ; go to beginning of program
itsr: org 0x0004
goto intsup
;**************** Interrupt rotine gos here ****************
;*************************************************************
mainProg: movlw 0x07 ;turn off comparator(PORTA = i/o)
movwf CMCON
movlw 0x90 ;GIE – Global interrupt enable (1=enable)
movwf INTCON ;INTE - RB0 interrupt enable (1=enable)& clear flag INTF
bsf STATUS,RP0 ;bank1
movlw 0x3f
movwf OPTION_REG
movlw 0x00
movwf TRISA
movlw 0x01
movwf TRISB
bcf STATUS,RP0 ;bank0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
main: movlw 0xff
movwf PORTA
call delay500
movlw 0x00
movwf PORTA
call delay500
goto main
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; delay500;;;;;;;
delay500:
movwf w_temp
movlw 0x04 ;0x04
movwf reg3
L3: movlw 0xff ;0xff
movwf reg2
L2: movlw 0xff ;0xff
movwf reg1
L1: decfsz reg1
goto L1
decfsz reg2
goto L2
decfsz reg3
goto L3
movf w_temp,0
return
;;;;;;;;;;;;;;;;;;;;;;;
intsup:
movlw 0x01
movwf PORTA
call delay500
movlw 0x02
movwf PORTA
call delay500
bcf INTCON,INTF
bsf INTCON,INTE
retfie ;return to mainProg
END ; directive 'end of program'