DatasheetQ Logo
Electronic component search and free download site. Transistors,MosFET ,Diode,Integrated circuits

PIC16C432-I View Datasheet(PDF) - Microchip Technology

Part Name
Description
Manufacturer
PIC16C432-I
Microchip
Microchip Technology 
PIC16C432-I Datasheet PDF : 106 Pages
First Prev 31 32 33 34 35 36 37 38 39 40 Next Last
The code example in Example 7-1 depicts the steps
required to configure the comparator module. RA3 and
RA4 are configured as digital output. RA0 and RA1 are
configured as the V- inputs and RA2 as the V+ input to
both comparators.
EXAMPLE 7-1:
INITIALIZING
COMPARATOR MODULE
FLAG_REG EQU
0X20
CLRF FLAG_REG ;Init flag register
CLRF PORTA
;Init PORTA
MOVF CMCON,W
;Move comparator contents to W
ANDLW 0xC0
;Mask comparator bits
IORWF FLAG_REG,F ;Store bits in flag register
MOVLW 0x03
;Init comparator mode
MOVWF CMCON
;CM<2:0> = 011
BSF
STATUS,RP0 ;Select Bank1
MOVLW 0x07
;Initialize data direction
MOVWF TRISA
;Set RA<2:0> as inputs
;RA<4:3> as outputs
;TRISA<7:5> always read ‘0’
BCF
STATUS,RP0 ;Select Bank 0
CALL DELAY 10 ;10ms delay
MOVF CMCON,F
;Read CMCON to end change condition
BCF
PIR1,CMIF ;Clear pending interrupts
BSF
STATUS,RP0 ;Select Bank 1
BSF
PIE1,CMIE ;Enable comparator interrupts
BCF
STATUS,RP0 ;Select Bank 0
BSF
INTCON,PEIE ;Enable peripheral interrupts
BSF
INTCON,GIE ;Global interrupt enable
7.2 Comparator Operation
A single comparator is shown in Figure 7-2, along with
the relationship between the analog input levels and
the digital output. When the analog input at VIN+ is less
than the analog input VIN-, the output of the comparator
is a digital low level. When the analog input at VIN+ is
greater than the analog input VIN-, the output of the
comparator is a digital high level. The shaded areas of
the output of the comparator in Figure 7-2 represent
the uncertainty due to input offsets and response time.
7.3 Comparator Reference
An external or internal reference signal may be used,
depending on the Comparator Operating mode. The
analog signal that is present at VIN- is compared to the
signal at VIN+, and the digital output of the comparator
is adjusted accordingly (Figure 7-2).
PIC16C432
2000-2013 Microchip Technology Inc.
Preliminary
DS41140C-page 35

Share Link: 

datasheetq.com  [ Privacy Policy ]Request Datasheet ] [ Contact Us ]