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

T|litEBo  215



                    4 Bit value   Prescalar value
                    0000         1.2
                    0001         1r4

                    0010         1:8
                    0011         l:16
                    0100         1:32

                    0101         l:64
                    0 l l 0      1 : 1 2 8
                    0111         l:256

                                                         applicd ilbjt 3  is  set  to 1.
                     lxxx        1:1          No  prescalar
                                              Prescalar  is therefore OFF
                     INTCON  is the intenupt control regisler

                    +FIIeeN4        Bir€     l.t6!+se4+e-eendifter€
                     IlIf€€|++      B+f      +l#$-€€a+r€+4itlr€rg
                     INTCON 2       BiA      Intenupt  flag

                     FIT€€|I'a      S€       l.l€#{€-eoitreHine+e
                     $+F€€N.+       Bit4     l+€|ttse+1i€-eelr{}e].:]]il+es
                     INTCON 5       Bits     Inteflupt enable bit
                     INTCON 6       Bit6     Used with Intemrpt  enable bit

                     INT€oN4        B'ig     +tu+tlse++€-eentr€    g

                     As mentioned in the  preceding,
                                                there is no way to start and stop  Timem. It runs all
                   the time.  Howeve! since it can be written  to, it can be set to 0 or any  value up to 255
                   whenever desired.  Also in the oounter mode, if there  i  s  no signal on TOCK1  ,  the  counler
                   will not inclemenq and so no  intenupt will occur !hus, in a sense  the counter func-
                   tion (but  not the  internally clocked timer function)  car be stopped. lf running free.
                   Timer0  genemtes  an interrupt  every 256 Fosc/4 cycles whether  ary attention is  paid  to
                                                      js
                   the  inteffupt or not, so if its interrupt  l]ag  never cleared, it stays set.
                     Watchdog timer interaction: If the  prcscalar  is  being  used by the watchdog  timer,
                   it cannot be used by  Timer2 and visa  versa.
                     Now that we know where all  the relevart bits are,  we  can  write a  program  tbr  the
                   LAB-X1  to testthings out.ln this  program,  we will sel the  prcscalar  to its maximum
                   value to slow things  down as far as  possible  so  we can see what is  going  on more
                   eas  y.
   213   214   215   216   217   218   219   220   221   222   223