Page 212 - Making PIC Microcontroller Instruments and Controllers
P. 212

CREATING  ACCURATE  INTERVALS

                  WITH  TIMERS: THE  METRONOMES




















                  This chapter is about learnjng to use the timers in a PIC.
                    First a note about  the timer functions and availability.  Though there are four timers in
                  the PIC 16F877A,  not all the timers are available  lor our projects,  rcr  are they  available
                  at all times.  The other uses for which a timer may be employed are:

                  a  Used with the HPWM instruction
                  I  Used for conmunications
                  I  Control ofthe  slave  port
                  I  Baud rate  generatioo
                  I  Resources are  shared with a watchdog timer (Watchdog  timer  [timer  #4] is not
                    available for any  programming purposes  but does share scaling resources with
                    Timer2.)


                  GETTII{G  COMFORTABLE

                  Ow goal  is to be comfortable  using the three timers  after we have oeated the metronomes
                  for this poject.  All  the metronomes created in softwarc and hardware behave identi,
                  cally but use  djfferent timers.
                    The metronome prcject is essentially  a software  project in rhat it is about leaming
                  how to use the timers. We should already have the two pieces  of hardware needed to
                  run the metronome software. They are, of course, the LAB-XI  and  the board we made
                  for the last  prcject. the tachomerer  (to which we will  have to add connection  points  lbr
                  a  potentiometer  and a speaker  [or  LED]). The existing  piezo  beeper  on the LAB  X I may
                  also be used.
                    Figure 16.2 show  that back ol fhe metronome  board shown h  Figure 16-1.
   207   208   209   210   211   212   213   214   215   216   217