list p=16f628
#include<p16f628.inc>
__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT
ERRORLEVEL -302
cblock 0x20
temp
temp_s
endc
;******************************************************************
org 0x00
goto main
;***********************************INTERRUPT LOOP*****************
org 0X04
inter:
movwf temp
swapf STATUS,w
clrf STATUS
movwf temp_s
movlw b'10000000'
movwf PORTA
btfsc PORTB,0x04
goto inter
bcf INTCON,0x01
swapf temp_s,w
movwf STATUS
swapf temp,w
retfie
main:
bsf INTCON,0x07 ;Globel interrupt enable(we are using interr.)
bsf INTCON,0x04 ;RB0 enabled as external interrupt
bsf INTCON,0x03 ;RB4-RB7 interrupt on change is enabled/ in other words these pins will also work as
;interrupts and interrupt will occur every time any of these pin changes state
; i.e.:HIGH to LOW or LOW to HIGH, we can not set it to be on eather one state change
bcf INTCON,0x01 ;Clear RB0 interuupt flag, in case it is set so
; that another interrupt can occur
bcf INTCON, 0x00 ;Clear RB4-RB7 interrupt flag so, that another interr. can occur.
;**********************************SET UP THE PORTS *****************
bsf STATUS,RP0 ;switch to BANK 1
movlw b'00010001'
movwf TRISB ;set RB0 & RB4 as input
movlw b'00000000'
movwf TRISA ;setPORT A all output
bcf OPTION_REG,0x07 ; enable weak pull ups on port b/ pull ups mean internal resistors
bsf OPTION_REG,0x06 ;interuupt on rising age/this is by defoult set
bcf STATUS,RP0 ;back to BANK 0
movlw 0x07 ;turn comparators off, so HIGH will be simple
; HIGH rather than +5V (compared to supply) so with the LOW
movwf CMCON
Loop:
movlw b'00000001'
movwf PORTA ;set pin 0 of port a HIGH
goto Loop
END