
PICDEM TM Lab Development Board User’s Guide
4.2.4
4.2.4.1
Lab 1: Simple Compare
NEW REGISTERS USED IN THIS LAB
To configure the peripherals used in this lab, the following registers are used:
1. Comparator C1 Control Register 0: CM1CON0 (Register 8-1 in Section 8 of the
PIC16F690 Data Sheet)
- Enables Comparator C1.
- Configures Comparator output polarity.
- Enables the Comparator result to be available internal only or on the C1OUT
pin (pin 17).
- Select inverting and non-inverting Comparator 1 reference input sources.
4.2.4.2
OVERVIEW
In this lab, Comparator 1 on the PIC16F690 is configured to perform a simple compare.
A potentiometer connected to the inverting input (C12IN0-) of the comparator will be
compared against the 2.5V connected to the non-inverting input (C1IN+) from a simple
voltage divider circuit. An LED connected to the output of Comparator 1 (C1OUT) will
light or turn off as follows:
? inverting reference > non-inverting reference = C1OUT is low = LED OFF
? inverting reference < non-inverting reference = C1OUT is high = LED ON
The PICDEM? Development Board configuration schematic is shown in
Figure 4-1.FIGURE 4-1:
SCHEMATIC FOR COMPARATOR LAB 1
V DD
J 8
1
2
3
4
5
6
U2
C1IN+
C12IN0-
C1OUT
20
19
18
17
16
15
J9
R1
10K ?
R2
7
8
9
10
14
13
12
11
10K ?
V DD
V SS
R3
DS41369A-page 62
R4
470 ?
LED1
V SS
The software flowchart for this lab is shown in
Figure 4-2.100K ?
V SS
? 2009 Microchip Technology Inc.