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

IIMEBS  33



                      Bit TRISE.6  Buffer status          1=Still  holds word
                                                          o=Has  been read

                      Bit TRISE.T Input  buffer status    1=Full
                                                          O=Nothing  received

                       Read the datasheet  a couple of limes to get  a better understanding  of these operations.
                    The precedhg is a very bdef ovefliew  and  is intended only to alet  you and  gjve you
                    an idea of what the  possibilities are.



                     PORTE


                     PORTE  is only 3 extemal bits wide and is a bidjrectional poll. The oiher  bits are inter-
                     nal and  are used as mentiooed  earlier under PORTD  (to  which they are  related). AII exter-
                     nai  rhree  pin'  can also be  u\ed a\ analog inpul\.
                       All  the  pins  on PORTE hav€ Schmitt  irigger input buffers  when used as digital inputs.
                       The altemate function of the PORTE  pins dre denned as  follows:
                       Pin REo direction control of Ph  PORTE.0 / RD / AN5

                       Pin RE1 direclior  control of Pin PORTE.  I / WR / AN6
                       Pin RE2 direction control of Pin PORTE.2 / CS / AN7



                     TIMERS


                     The PIC 16F877A  MCU has four timers: a 'vafchdog timer and thr€e regular timers.
                     These allow the accurate  timing (and  counting)  of chronological  events. Timers  are dis-
                     cussed in much  g&ater detail in chapter 6.
                       Some  of the timers  have  (pre-  andpost) scalars  associated  with t}Iem that  can be
                     usedto  multiply the timer setting  by an integer amount.As  youcan imagine, the scal-
                     ing ability is not adequate to allow all timed inte  als  to be created. We  also must
                     consider the unce(ainty  in the frequency  of the clocking  crystal, which is usually
                     not exactly what it is stated to be (and  may drift with ambient  temperature)  This
                     means that though  fairly accurate timings  can be achieved  with the hardware  as
                     received, additional software  adjustnents  may have to be added  if  more accurate
                     results  are desired. This  is doneby having the software  make a correction  to the  time
                     every  so often,  (This  also  means tiat an extemal  source, that  is at least as accurate
                     as the  result we want, is needed  to verify the timing  accuracy ofthe device created  )
                       As always,  the three limers in fhe microconfoller  are  clocked $  a fourth of the oscil-
                     lator speed, meaning  that a timer within a 4 MHz  system  clock gets  a counting signal
                     at I MHz
   39   40   41   42   43   44   45   46   47   48   49