SX Users Manual Rev. 3.1
161
© 2000 Scenix Semiconductor, Inc. All rights reserved.
www.scenix.com
Chapter 7
Analog Comparator
7.1 Introduction
The SX has an analog voltage comparator. The comparator circuit, when properly enabled and
configured, compares the analog voltages supplied to two Port B input pins. The comparator
determines which voltage is higher and reports the logical result in an internal register and also on a
Port B output pin (if enabled for that purpose). The application program can read the result from the
internal register, and an external device can read the result from the Port B output pin.
The comparator uses Port B pins RB2, RB1, and RB0. RB2 and RB1 are the comparator inputs, with
RB2 operating as the positive input and RB1 operating as the negative input. If the voltage on RB2 is
greater than the voltage on RB1, the result of a comparison operation is logic 1. Otherwise, the result
is logic 0.
This result is reported on the RB0 pin, which is configured to operate as an output. If the result is only
needed by the SX software and not by an external device, then RB0 does not need to be used for the
comparator function. Instead, it can be used as a general-purpose I/O pin or a Multi-Input Wakeup
input pin.
7.2
Comparator Enable/Status Register (CMP_B)
The Comparator Enable/Status Register (CMP_B) is a Port B control register used to enable operation
of the comparator, to enable the comparator output pin, and to read the comparison results. The register
format is shown below.
There are three non-reserved bits in this register:
CMP_EN (Comparator Enable). To enable operation of the comparator, clear this bit to 0. You
must also configure RB2 and RB1 to operate as inputs by setting bit 2 and bit 1 in the RB Data
Direction register.
CMP_OE (Comparator Output Enable). Using the RB0 pin as a comparator output is optional.
To do this, clear this bit to 0.
CMP_EN
CMP_OE
Reserved
CMP_RES
7
6
5
4
3
2
1
0