Information

33.8.1 CMP Functional Modes
There are three main sub-blocks to the comparator module: the comparator itself, the
window function and the filter function. The filter, CR0[FILTER_CNT] can be clocked
from an internally or external clock source. Additionally, the filter is programmable with
respect to how many samples must agree before a change on the output is registered. In
the simplest case, only 1 sample must agree. In this case, the filter acts as a simple
sampler.
The external sample input is enabled using CR1[SE]. When set, the output of the
comparator is sampled only on rising edges of the sample input.
The "windowing mode" is enabled by setting CR1[WE]. When set, the comparator output
is sampled only when the WINDOW input signal is equal to one. This feature can be
used to ignore the comparator output during time periods in which the input voltages are
not valid. This is especially useful when implementing zero-crossing-detection for certain
PWM applications.
The comparator filter and sampling features can be combined as shown in the following
table. Individual modes are discussed below.
Table 33-29. Comparator Sample/Filter Controls
Mode # CR1[EN] CR1[WE] CR1[SE]
CR0[FILTER_C
NT]
FPR[FILT_PER] Operation
1 0 X X X X Disabled
Refer to the Disabled Mode (# 1).
2A 1 0 0 0x00 X Continuous Mode
Refer to the Continuous Mode (#s
2A & 2B).
2B 1 0 0 X 0x00
3A 1 0 1 0x01 X Sampled, Non-Filtered mode
Refer to the Sampled, Non-Filtered
Mode (#s 3A & 3B).
3B 1 0 0 0x01 > 0x00
4A 1 0 1 > 0x01 X Sampled, Filtered mode
Refer to the Sampled, Filtered
Mode (#s 4A & 4B).
4B 1 0 0 > 0x01 > 0x00
5A 1 1 0 0x00 X Windowed mode
Comparator output is sampled on
every rising bus clock edge when
SAMPLE=1 to generate COUTA
Refer to the Windowed Mode (#s
5A & 5B).
5B 1 1 0 X 0x00
Table continues on the next page...
CMP Functional Description
K20 Sub-Family Reference Manual, Rev. 6, Nov 2011
788 Freescale Semiconductor, Inc.