ZEROBIT equ 2 ;ZEROBIT is bit 2.
COUNT equ 0ch ;user ram location.
;************************************************* *********
list p=16f84a ;we are using the 16f84
#include <p16f84a.inc>
org 0000H ;0x00 is the start address.
goto start ;goto start!
;************************************************* *********
;configuration bits
__config h'3ff0' ;selects lp oscillator, wdt off, put on,
;code protection disabled.
;************************************************* ****
;subroutine section.
;5 second delay.
delay5:
clrf TMR0 ;start tmr0.
loopA:
movf TMR0,w ;read tmr0
sublw 160 ;time - 160
btfss STATUS,ZEROBIT ;chec k time-w¼0
goto loopA ;time is not¼160.
retlw 0 ;time is 160, return.
;************************************************* *********
;configuration section.
start:
bsf STATUS,5 ;turn to bank1
movlw b'00011111' ;5 bits of PORTA are i/ps.
movwf TRISA
;movlw b'00000000'
;movwf TRISB ;PORTB is output
CLRF TRISB ;is enough
movlw b'00000111'
movwf OPTION_REG ;prescaler is /256
bcf STATUS,5 ;return to bank0
clrf PORTA ;clears PORTA
clrf PORTB ;clears PORTB
clrf COUNT
;************************************************* ********
;program starts now.
on:
btfsc PORTA,0 ;check button pressed.
goto on
bsf PORTB,0 ;turn on led.
call delay5 ;call 5 second delay
bcf PORTB,0 ;turn off led.
call delay5
goto on ;repeat
end