
Comparator
Rev.1.00
Jun 06, 2003
page 143 of 290
M16C/6K9 Group
Comparator Circuit
Comparator Configuration
A comparator circuit consists of a switch tree, ladder resistance, comparators, comparator control circuit, the
comparator control register (address 03DE16), comparator data register (address 03DF16), and analog signal
input pins(P50 - P57). The analog input pins (P50 - P57) are shared with the usual digital port I/O pins.
The comparator control register is a 4-bit register and can generate internal analog voltages in steps of 1/16
Vcc with the contens of bits 0 to 3. In Table.JC-2 contents of bits 0 to 3 of the comparator control register
and corresponding internal analog voltage generated are indicated. The compared result of the analog
input voltage and internal analog voltage is stored in the comparator data register. The value of comparator
control register can not be read out.
Comparator Operation
In order to perform comparator operation, first, set the port P5 direction register (address 03EB16) to "0", as
P5 can be used as the analog input pins. Then write a digital value, which corresponds to the internal
analog voltage to be compared, to bits 0 to 3 of the comparator control register (address 03DE16) . The
voltage comparison starts immediately by the writing operation. After 28 cycles of main clock without division
(the cycles needed for comparison, no relation to the frequency), the compared result of the comparator is stored
in the comparator data register (address 03DF16). Each bit of this register becomes as follows depending on the
status of corresponding P50 to P57 pins:
When analog input voltage > internal analog voltage, it is "1".
When analog input voltage < internal analog voltage, it is "0".
For comparing once more, it is necessary to write data into comparator control register again even if the
internal analog voltage is the same.
To read the result, wait 28 cycles of main clock without division (the cycles needed for comparison, no
relation to the frequency) or more after the comparator operation starts.
During the 28 cycles of the comparison, the ladder resistance is turned on and the reference voltage is
generated. When the comparator is not in operation, the ladder resistance is off. Therefore, unnecessary
consumption is prevented.
The comparison is accomplished by capacitive coupling. If the clock frequency is too low, electric charge
will be lost. While the comparator is in operation, the clock frequency must be 1MHz or higher. During this
time, do not execute a STP instruction, a WIT instruction, or an I/O instruction for port P5.
Fig.JC-1 Comparator circuit
VSS
8
P5 (8)
P57
P56
P50
b0
Comparator data
register(03DF16)
Compa
rator
R-ladder connection
signal
Comparator
Control Cricuit
Comparator connection
signal
Compa
rator
Compa
rator
Data bus
b0
Comparator control
register(03DE16)
4
Switch Tree
R-ladder
b3