#include <P16F84A.inc>
errorlevel -302
cblock 70h
int_work
int_status
[B]counterL
d1
d2
d3[/B]
endc
org 0x0000
goto Start
org 0x0004
interrupt movwf int_work ;2latent +1 =3
swapf STATUS,W ;+1 =4
movwf int_status ;+1 =5
bcf STATUS,RP0 ;+1 =6
bcf STATUS,RP1 ;+1 =7
movlw 100h-d'78' ;+1 =8
goto $+1 ;+2 =10
goto $+1 ;+2 =14
nop ;+1 =15
movwf TMR0 ;+1 =16 + 78*128 = 10,000
[B]btfss INTCON,T0IF ;Is it a TMR0 interupt?
goto intend ;return from interupt
decfsz counterL,1
goto intend ;return from interupt
bsf PORTB,0 ;turn on the LED RB0
movlw 64h ;load 100 to counterL
movwf counterL[/B]
intend bcf INTCON,T0IF ;reset int flag
swapf int_status,W
movwf STATUS
swapf int_work,F ;swap to file
swapf int_work,W ;swap to work
retfie
Start bcf STATUS,RP1
bsf STATUS,RP0
bcf STATUS,IRP
clrf TRISB
movlw b'00000110' ;set prescaler to 128
movwf OPTION_REG
bcf STATUS,RP0
movlw 0a0h ;enable timer interupt
movwf INTCON
[B]movlw 64h ;load 100 to counterL
movwf counterL
call del ;call a 0.5 seconds delay to see the LED flash
bcf PORTB,0 ;other 0.5 seconds LED will off[/B]
Loop goto Loop ;Loop
[B]del movlw 0x03 ;0.5 seconds delay routine
movwf d1
movlw 0x18
movwf d2
movlw 0x02
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
goto $+1
goto $+1
goto $+1
return
[/B]
end