Page 267 - Making PIC Microcontroller Instruments and Controllers
P. 267
PROJECT 4 265
rletirttillrllLilatl code for a two-temperature instrument (confitnued)
DEFIIIE IJCD COMMAIIDUS 2000 ; delay in micro seconds
DEFIIIE IJCD_DATAUS 50 ; delay in nicro seconds
^ o e e € o - g o 1 o o g
; 1 i n e s ,
D t \ 8 5 . o s p e ( j t f e
; a-!o-D conversions.
; define the AzD setlings
DEFME ADC_BITS A , se! nuriber of bits in resutt
DEFITIE ADC_CLOCK 3 ; set internal clock source (3=rc)
DEFINE ADC SAI{PLEUS 50 ; set smpLing tine in uS
ADCON1=e"o 0 0 0 0 011 ; needed for the 16F8??A LCD
TEMP1 VAR BYTE
TEMP2 VAR BYTE
ADCON1=e"o 0 0 0 0 011
PAUSE 500
I,CDOUT $FE, 1
A.DCIN O, TEMP1
A.DCIN 1, TEMP2
TEMPI=TEMP1 * 100
TEMP2=TEMP2 * 100
\TenD1=z,DEC3 " .
LcDon:r $FE, $40, TEDtPl, i di.play tuqL -enp
sTere2=/,DECa z \
I,CDOUT $re, Scor TEMP2T ; display second tenp
GOTO I,OOP
END ; all programs nust end wrth end
If the DEFINES for the LCD are changed 1{) the standard LAB Xl display, Progam 18.1
can be tcsted on the LAB-XI, and the posiiions of the wiper of POm and POTI will be
displayed on lhe scrcen. The necessdrf substitutions for the fiIst few lines are shown in
hogram 18.2.
''liliitiiiinJg.;ell:
Beplacement code segment
CIEAR ' ctear variables
DEFINE OSC 4 t osc speed
DEFINE LCD DRIG PORTD ; dara register
DEFINE I"CD RSREG PORTE ; register select
DEFINE LCD RgBtr 0 ; register select biE
DEFINE LCD EREG PORIE ; enabLe register
DEFINE LCD EBM L i enabLe bit
DEFINE LCD RWREG PORTE ; read/wriLe register
DEFINE LCD RWBIT 2 i read/write bit
DEFINE LCD BIIS 4 i width of data