PIC16F627-04 Microchip Technology, PIC16F627-04 Datasheet - Page 59

no-image

PIC16F627-04

Manufacturer Part Number
PIC16F627-04
Description
FLASH-Based 8-Bit CMOS Microcontrollers
Manufacturer
Microchip Technology
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
PIC16F627-04/P
Quantity:
31
Part Number:
PIC16F627-04/P
Manufacturer:
MICROCHIP/微芯
Quantity:
20 000
Part Number:
PIC16F627-04/SO
Manufacturer:
MIC
Quantity:
933
Part Number:
PIC16F627-04/SO
Manufacturer:
MICROCHI
Quantity:
20 000
Part Number:
PIC16F627-04/SS
Manufacturer:
MICROCHIP
Quantity:
13
Part Number:
PIC16F627-04/SS
Manufacturer:
MICROCHIP/微芯
Quantity:
20 000
Part Number:
PIC16F627-04I/P
Quantity:
18
Part Number:
PIC16F627-04I/P
Manufacturer:
MICR
Quantity:
20 000
Part Number:
PIC16F627-04I/SO
Manufacturer:
MICROCHIP/微芯
Quantity:
20 000
The code example in Example 9-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 9-1:
9.2
A single comparator is shown in Figure 9-2 along with
the relationship between the analog input levels and
the digital output. When the analog input at V
than the analog input V
comparator is a digital low level. When the analog input
at V
of the comparator is a digital high level. The shaded
areas of the output of the comparator in Figure 9-2
represent the uncertainty due to input offsets and
response time.
FLAG_REG EQU
CLRF
CLRF
MOVF
ANDLW
IORWF
MOVLW
MOVWF
BSF
MOVLW
MOVWF
BCF
CALL
MOVF
BCF
BSF
BSF
BCF
BSF
BSF
1999 Microchip Technology Inc.
IN
+ is greater than the analog input V
Comparator Operation
FLAG_REG
PORTA
CMCON, W
0xC0
FLAG_REG,F
0x03
CMCON
STATUS,RP0
0x07
TRISA
STATUS,RP0
DELAY 10
CMCON,F
PIR1,CMIF
STATUS,RP0
PIE1,CMIE
STATUS,RP0
INTCON,PEIE ;Enable peripheral interrupts
INTCON,GIE
INITIALIZING
COMPARATOR MODULE
0X20
;Init flag register
;Init PORTA
;Load comparator bits
;Mask comparator bits
;Store bits in flag register
;Init comparator mode
;CM<2:0> = 011
;Select Bank1
;Initialize data direction
;Set RA<2:0> as inputs
;RA<4:3> as outputs
;TRISA<7:5> always read ‘0’
;Select Bank 0
;10 s delay
;Read CMCON to end change condition
;Clear pending interrupts
;Select Bank 1
;Enable comparator interrupts
;Select Bank 0
;Global interrupt enable
IN
–, the output of the
IN
–, the output
IN
+ is less
Preliminary
9.3
An external or internal reference signal may be used
depending on the comparator operating mode. The
analog signal that is present at V
signal at V
is adjusted accordingly (Figure 9-2).
FIGURE 9-2:
9.3.1
When external voltage references are used, the
comparator module can be configured to have the com-
parators operate from the same or different reference
sources. However, threshold detector applications may
require the same reference. The reference signal must
be between V
pin of the comparator(s).
9.3.2
The comparator module also allows the selection of an
internally
comparators. Section 13, Instruction Sets, contains a
detailed description of the Voltage Reference Module
that provides this signal. The internal reference signal
is used when the comparators are in mode
CM<2:0>=010 (Figure 9-1). In this mode, the internal
voltage reference is applied to the V
comparators.
Output
V
V
IN–
IN+
V
V
IN
IN
Comparator Reference
EXTERNAL REFERENCE SIGNAL
INTERNAL REFERENCE SIGNAL
+
IN
generated
+, and the digital output of the comparator
SS
and V
SINGLE COMPARATOR
+
DD
voltage
, and can be applied to either
PIC16F62X
IN
reference
– is compared to the
DS40300B-page 59
IN
Output
+ pin of both
for
the

Related parts for PIC16F627-04