Page 106 - Making PIC Microcontroller Instruments and Controllers
P. 106
E6 TIMEES AIID COUNIERS
iit&iitiilii$all Timerl usage (Budimentary timer operation that depends on vaLue of
POTI) (Continued)
OPTION REG = %00000000 ; Set Bit 7 to 0 and enable PORTB pullups
; A11 other bits are for Tiner 0 and
; noL applicable
PrEl=%00000001 ; See datasheet, enables interrupt.
ADCOTiIO= %11000001 , co!6gure and turn on A/D ]lodule
t brL l 6: ADCSI: LDCSo: ; A/D Conversion Crock SelecL bits
; 00 = Fosc/2
; 0 1 = F O S C / 8
; 1 0 = F O S C / 3 2
t L! = FRc (clock derived fton an Rc oscillation)
; bit 5 3: CHS2:CHS0: Analog Channel Select bits
; 000 = chamel 0, (FAO/ANO)
; 001 = chamel 1, (FA1/AN1)
; 010 = channeL 2, (RA2/}N2)
; 011 = channel l, (RA3/}N3)
, 100 = channel 4, (RA5/aN4)
; 101 = channel 5, {REI]/AN5) (1)
. 110 = channel 6, {RE1/AN6) (1)
; 111 = channel 7, (RE2/AN7) (1)
; bit 2r GOIDONE: a/D Conwersion Stalus brt
; If ADoN = 1 See bit 0
i | = a/D conversion in progress (serting this bit slarts
; the A/D conwersion)
; 0 = A/D conversion not in prosress (This bit is
, autonatically cleared by hardvare then the A/D
ersion is conplete)
; bit 1: uninplenented: Read as ; 0;
; bit 0: !-DON: A/D On bit
; 1 = A/D converLer nrodule is operating
; 0 = A/D conwerter nodule is shutoff and consumes no
; operaLrng current
; The A to D conrrof Reqister for Port A is ADcoNl
ADCONI = %00000010 ; set part of PORTA analog
, The refewan! table is on paqe !L2 af the datasheet
- h - - . ! . r o i q p d o i - i . s
; - s , , i h o e u - d ' d l o s
; and allow the woltage ; reference belween vdd and Vss. We have
; on the third Line .lown in the tabte
; Nex! 1et us set up the port pin directions
IRISA = %11111111 ; set PORTA to alL input
TRISB = %11110000 , set up PORTB for keyboard reads
PoRtB.o = 0 ; seL so we can read ror 1 only for now
(Coktihuet)