Page 247 - Making PIC Microcontroller Instruments and Controllers
P. 247
COUIITING TO A REGISTEN USNG AII ITITERNUPT 2/15
plPi!i'alni:!l1i!:i: This program is not executable (Program nol for use in real
counting as ii is now;for discusson and examinalion ady) lcontinued)
i A n d . - e o p ( i o p a o p t - o . ' 1 - o r ' ' u D d r d - o r - " 1 "
ADCON1-%OOOOO111 , ""a ..nr.a".. to di€rital
IIiITCON=%10100000 - :n .!-.p o 'o eo bi -
oPTIoN R!c=%00000101 ; set oplion req bits
; ite need for Lhe progrm Lo pause for half a second
: r o . l l o l - _ D o o - p o n p - F d a d c 4 o a . 4 4 1
PAUSE 500 ; pause for LCD startup
LCDOn:r SFE, 901 ; clear the LCD
. _ h 6
o l d . 6 _ v o - L A .
POTO VAR BYTE ; create adval to store res!1t
POT1 VAR BATE ; create adval to slore resutt
POT2 VAR BYTE ; create adval to sLore result
ALPIIA VAR BYTE
; Tell the prosran where ro go on an intedupt
oN INTERRUP! Goto rN! RoulrrNE ; set inte.rupt target
; set Lhe initial conditions for the Lwo gates as top oped,
; botton closed
PoT0=125 ; open rop qa€e
; create a loop that the pro€rrd can wait in ti11 we press sditch I
wAITLooP ! ; this is the loop for
PORTD.3=PORTB.4 , the starL swiLch to be pressed
IF PORTB.4=1 THEN ; switch is connected to
GOIO WAIfLOOP ; line 84
ENDIF
^ b - r - " d i r q l - p h o o - d n : ' l o o - o o r B 0 w -
j T R I C B o ! P O R T B o h - B 0 . . d . : l p l t . W e -
I
; lhe interrupt feature of
; BO in later prograns so we want to keep che sensor on 80. Ide
; B0 an inpur so
; Lhat iL can receive the signaf fron the IR Phototransistor
; pair and enabLe
; lhe interrupt capabilily for B {later).