Page 104 - Making PIC Microcontroller Instruments and Controllers
P. 104
94 ftiltERs a D coul{TERs
of
on
Timerl usage (Budimentary operation
ittLi-qatilafris!:ll timer ihat depends vaLue
POT-1)
; 6rst fet us seL up lhe LCD dispLav parmeLers.
CLtlaR ; cleai nenory
DEFITIE OgC 4 ; set osc speed
DEFINE IJCD DREG FORTD ; lcd is on PORT'D
DEFIIIE LCD DBIT 4 ; we will use 4-bit plolocoL
DEFME l,CD RSRBG PORTE ; relrister selecL reerister
DEFTNE IcD,RsBIt 0 ; regisLer seLect bit
DEFINE LCD-EREG PORTE ; enable Re€risLer
DEFINE LCD,EBI! I ; enable bil
poRTE.2 = O ; set for vtile node
PAuSE 5OO ; wait 5 seconds
; NeaL Let us deFne the variables we uiLl be usins
AD1/Ai V,IR BYTE cleate adval to store result
TICKS VAR WORD
TENTES VAR B'TE
sEcs vax woRD
MINS VAR BYEE
; set the variable to specifrc vaLues, not necessarv in thls progrm
; but a formaLity for cLariLY
TICKS = 0
TEMUIS = 0
SECS = 0
MINS = 0
; set the re€rislers Lhat will conlroL the fork ;
; This is the nilLy grittv of it so we will call out each bit
; INTCON is Lhe lnterlup! control register.
INICON =%11000000
; bit ?: GIE: GlobaL Interrupt Enable bi!, rhis has io be seL
; for any interrupt to worK-
; 1 = Enables all un nasked interrupts
; 0 = Disables all inteIrupLs
; bit 5: PEIE: Peripheral htertupt Enable bit
r 1 = Enables alL un-masked peripheraL intefupLs
; 0 = Disables alL peripheraL inLert\rpts
; bit 5: TOIE: TMRo overflow Interupt Enabte brt
r I = Enables the T!IR1 interrupt
; o = Disables the TlG1 inlerrupt
, bib 4: INTE: RBO/INT ExternaL Interrupt Enable llt
; I = Enables lhe RBO/INT exLernal intelrupr
; 0 = Disables the RBO/INT exLernal inteirupt
(Coklikue.t)