Microchip Technology DM183037 Data Sheet
2012 Microchip Technology Inc.
DS30575A-page 473
PIC18F97J94 FAMILY
FIGURE 22-13:
INSIDE WINDOW COMPARISON OPERATION
22.7.5.3
Outside Window Comparison
When the Compare Mode bits CM<1:0> are
programmed as '11', the converter compares the
sampled value to see if it falls outside of the threshold
values in the buffer and mirrored channel location.
Again, since the value in the mirrored channel location
is always the greater value of the two thresholds, the
condition is met when either:
Converted Value >Threshold 2
or
Threshold 1 > Converted Value
In these cases, the following occurs:
• The Compare Hit bit (CHHn) for the correspond-
programmed as '11', the converter compares the
sampled value to see if it falls outside of the threshold
values in the buffer and mirrored channel location.
Again, since the value in the mirrored channel location
is always the greater value of the two thresholds, the
condition is met when either:
Converted Value >Threshold 2
or
Threshold 1 > Converted Value
In these cases, the following occurs:
• The Compare Hit bit (CHHn) for the correspond-
ing channel is set.
• If the converted value is greater than Threshold
2, the CHHn bit for the mirrored channel is also
set. If it is less than Threshold 1, the mirrored
channel bit remains '0'.
set. If it is less than Threshold 1, the mirrored
channel bit remains '0'.
• If the Write Mode bits, WM<1:0>
(ADCON5L<3:2>), are programmed to '01':
- If the converted value is above Threshold 2,
- If the converted value is above Threshold 2,
the converted value is written to the mirrored
channel address, replacing the upper thresh-
old value.
channel address, replacing the upper thresh-
old value.
- If the converted value is below Threshold 1,
the converted value is written to the channel
address, replacing the lower threshold value.
address, replacing the lower threshold value.
• If WM<1:0> = 10, the converted value is
discarded.
The changes to the result buffer and the Compare Hit
register are shown in
register are shown in
(over the upper
threshold) and
(under the lower thresh-
old).
Note that when a Windowed Comparison mode is
selected and channel mirroring is enabled, nothing pre-
vents a conversion from another operation from being
stored in the mirrored channel location. In the previous
examples of windowed operation, if AN10 is included in
a Threshold Detect operation, a conversion on AN10
might be tested against the upper threshold for AN2,
stored in that location. This could result in the threshold
value being overwritten and/or the CHH10 bit being set.
Note that when a Windowed Comparison mode is
selected and channel mirroring is enabled, nothing pre-
vents a conversion from another operation from being
stored in the mirrored channel location. In the previous
examples of windowed operation, if AN10 is included in
a Threshold Detect operation, a conversion on AN10
might be tested against the upper threshold for AN2,
stored in that location. This could result in the threshold
value being overwritten and/or the CHH10 bit being set.
ADC1BUF15
—
ADC1BUF14
—
ADC1BUF13
—
ADC1BUF12
—
ADC1BUF11
—
ADC1BUF10
Threshold 2
ADC1BUF9
—
ADC1BUF8
—
ADC1BUF7
—
ADC1BUF6
—
ADC1BUF5
—
ADC1BUF4
—
ADC1BUF3
—
ADC1BUF2
Threshold 1
ADC1BUF1
—
ADC1BUF0
—
Before Conversion and Comparison
AD1CHITL
15
14
13
12
11
10
9
8
0
0
0
0
0
0
0
0
7
6
5
4
3
2
1
0
0
0
0
0
0
1
0
0
After Conversion and Comparison
Compare Only
(‘10’)
Compare and
Store (‘01’)
ADC1BUF15
—
—
ADC1BUF14
—
—
ADC1BUF13
—
—
ADC1BUF12
—
—
ADC1BUF11
—
—
ADC1BUF10
Threshold 2
Threshold 2
ADC1BUF9
—
—
ADC1BUF8
—
—
ADC1BUF7
—
—
ADC1BUF6
—
—
ADC1BUF5
—
—
ADC1BUF4
—
—
ADC1BUF3
—
—
ADC1BUF2
Threshold 1
Conversion Value
ADC1BUF1
—
—
ADC1BUF0
—
—
AD1CHITL
15
14
13
12
11
10
9
8
0
0
0
0
0
0
0
0
7
6
5
4
3
2
1
0
0
0
0
0
0
0
0
0