Page 251 - Making PIC Microcontroller Instruments and Controllers
P. 251
us|l|G tlMERl |l{ couNrEB ltoDE
tlole 1 The intetnqt fag at PIRI .0 trill be set \')hen the counter owtnows (and
would hare to be cleared in the interrtrpt tetfice ft)utine-our count will ne')er get that
fa\ but v,e still need to be aware ofthi!). We are not intercsted in the counter oreilov)
in this pa iculat application becduse rre will nerer count pdst 65635, but if we were
to count ?ast thaL the code to rcset the interrupt lag dnd keep t lck of the overfo\)s
wouLd haw to be a&Led to the progran at the appropriate location. It miSht ercn be
necessary to close o e of the gatzs (meaninS: stap avery fitst prccess)bejbre we gat to
the o.)eilow to stop ewrythine while v,e got this done.
Study lhe wiring diagram for the marble couoter (Figure 17.5) so you lully undcr
stand how the hardware is wired on the controller
In this program, each marble interupts the lR bcam, which feeds into 8.0, the inter
rupt receiving pin. Any change in B.0 causes an interrupt and de bounces the incoming
1
2 39
3 3a
37
5 36
6 35
7
o 8 33
o- 9 32
O- 1 0 31
30
1 2 29
l 3 2A
27
1 5 26
l 6 25
1 7 IVARBLES
1 8 23
1 9 22
20 2 1
22 Plcolarad Capacitors
lFiirniitllt;!::i Wiringdjagram lorcounling marbles inlo counterTMR1. (The four PORTD and
the three POBTE ines, marked with circles in lhe ligure, go to the LCD.)