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

socxETs uT aAltD ual   129



                                                                Labs
                  W               Using  the DSl620  (microEngineefing  program  to read
                   tempeBturc)  (Cor nued)
                   INCI.I'DE'UODEDE!S.Bf,S''    ;
                   DEFTNE LCD DRIG  PORID       ;  define  1cd  pins
                   DEFTNE I.CD-DEIT  4          ;
                   DEFINE  I.CD-RSRIG           PORTE;
                   DEFINE  I'CD_RSBIT  O        ;
                   DEFINE  ',CD_EREG POR'E
                   DEFINE t,CD EBIT  !          }
                                                :  dliqs  pins
                   R S I  R  P O R E C . o      :  ' e s e  p i  '
                       V
                   D Q A R  P O R E C . I       :  d a . .  p i n
                   CIIR VAR PORIC.3             :   lo-l<  pii
                                                ;  allocate   variables
                   lElllP  VAR WORD             ;  storage   for  tenperature
                   Loil  Rgt                    ;  rese!   the  device
                   ADCON1  -%000001U            ;  set  PORTA and  POR?E to  digital
                   Loit  PoREE.2                ;  lcd  r/w  line  low  (w)
                    PAUSE 100                   ;  wait   for  lcd  to  start
                   LCDO(,!I  SFE,  1,   "IE!'P   IN  DEGREES C"   j  d:spl-y   sign  on  nessage
                                                ;  foop  to  xead  the  temp  and  display
                                                ;  on  lcd
                   uau[t  oP:
                   RgE=  1                      ;  enable  device
                    SEIFEOI'I  DQ,  CLt,  I,SBFIRSI.  ISEEI   ;  start   conversion
                   R g f - 0
                    PAvsE  1000                 ;  wait  1  second  for  conversion   to
                                                ;  conplete
                   R S I = 1
                    sslFEottT  DQ.  ctK.  t sBFlRsI.   ISAAI   ;  send  read  comnd
                    gHIellN   OQ. CliK,  I/SBPRER, IEEMP\9]   ;  read  9  bit   temperature
                   R S t - 0
                                                ;  display   the  decimal   temperaLure
                    r,cDouE  $FE,  1,  DEC (IEMP >>  1),   {.",   DEC (tEMP.o  *   5),
                    \DEGREES   C/
                    GO4IO IIAINLOOP             ;  do  it   forewer
                    El[D                        ;  end  progran
   134   135   136   137   138   139   140   141   142   143   144