User manual

Table Of Contents
Comparator Peripheral Labs
© 2009 Microchip Technology Inc. DS41369A-page 65
Fixed 0.6 reference option
Output clamped to V
SS
The CVREF has 2 ranges with 16 voltage levels in each range. Range selection is
controlled by the CV
REF Range Selection (VRR) bit in the VRCON (Voltage Reference
Control Register) along with the CV
REF
Value Selection bits (VR<3:0>). The Value
Selection bits hold a value based upon some simple calculations to set the internal
reference voltage. The CV
REF voltage is determined using Equation 4-1:
EQUATION 4-1: CV
REF OUTPUT VOLTAGE
This lab will implement the low-range calculation by setting the VRR bit in VRCON
equal to 1. Equation 4-2 demonstrates how to calculate the VR<3:0> values, using the
low-range method, to obtain a 2.5V internal reference. If higher resolutions are
required, the high-range method should be used (see Section 8.10.2 in the PIC16F690
Data Sheet (DS-41262).
EQUATION 4-2: CALCULATING A 2.5V INTERNAL REFERENCE
(LOW-RANGE METHOD)
The Initialize() from the previous lab now must configure both the Comparator 1
peripheral and the CV
REF as follows:
Turn on Comparator 1
•Select CV
REF the non-inverting reference for Comparator 1
Continue to use the C12IN0- pin as the inverting reference
Turn on CV
REF
Select the low-range feature
Set the CV
REF Value Selection bits as per the calculation in Equation 4-2.
Changes to the PICDEM™ Development Board configuration schematic for this lab are
shown in Figure 4-3.
VRR = 1 (Low-Range):
CVREF = (VR<3:0>/24) x VDD
VRR = 0 (High-Range):
CVREF = (VDD/4) + (VR<3:0> x VDD/32)
VRR = 1 (Low-Range):
CVREF = (VR<3:0>/24) x VDD
Known: desired CVREF = 2.5V, VDD approximately 5V
Therefore:
2.5V = (VR<3:0>/24 x 5V
2.5V/5V = (VR<3:0>/24)
(2.5V/5V) x 24 = VR<3:0>
VR<3:0> = 12
10
or 1100
2
VR0 = 0
VR1 = 0
VR2 = 1
VR3 = 1