User manual

Table Of Contents
PICDEM
TM
Lab Development Board User’s Guide
DS41369A-page 62 © 2009 Microchip Technology Inc.
4.2.4 Lab 1: Simple Compare
4.2.4.1 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
The software flowchart for this lab is shown in Figure 4-2.
U2
1
2
3
4
5
6
7
8
9
10
20
19
18
17
16
15
14
13
12
11
C1IN+
J9J8
R4
470
LED1
V
SS
V
DD
C12IN0-
C1OUT
R1
10K
R2
10K
V
DD
R3
100K
V
SS
V
SS