mg82fel308 Megawin Technology, mg82fel308 Datasheet - Page 65

no-image

mg82fel308

Manufacturer Part Number
mg82fel308
Description
A Single-chip Microcontroller Based On A High Performance 1-t Architecture 80c51
Manufacturer
Megawin Technology
Datasheet
14. Analog Comparator
A single analog comparator is provided in the MG82FE(L)308/316. The comparator operation is such that the
output is a logical “1” when the plus input AIN0 is greater than the minus input AIN1. Otherwise the output is a
zero. There are four analog plus inputs to be selected in on AIN0. They are AC_PI0, AC_PI1, AC_PI2 and
AC_PI3 which are multiplexed by PIS[1:0]. MVRS[3:0] select the 16 inputs on AIN1 that include AC_MI and 15
segments VDD reference. The comparator output is read out by CPU on ACCON.ACOUT.
The default I/O states of AC_MI(P1.5), AC_PI0(P1.4), AC_PI1(P1.3), AC_PI2(P1.2) and AC_PI3(P1.1) are set to
quasi-bidirectional I/O with on-chip pull-up resistor. To use the analog comparator properly, CPU must configure
the selected comparator input channel to Input-Only mode to disable pull-up resistor effect. When enter device
power down mode without comparator operating, must set the I/O ports to quasi-bidirectional, push-pull output or
open-drain output low to fix I/O state for saving current consumption.
Setting the ACEN bit in ACCON enables the comparator. When the comparator is first enabled, the comparator
output and interrupt flag are not guaranteed to be stable for 10 microseconds. The corresponding comparator
interrupt should not be enabled during that time, and the comparator interrupt flag must be cleared before the
interrupt is enabled in order to prevent an immediate interrupt service.
The comparator may be configured to cause an interrupt under a variety of output value conditions by setting the
ACM bits in ACCON. The comparator interrupt flag ACF in ACCON is set whenever the comparator output
matches the condition specified by ACM[2:0]. The flag may be polled by soft-ware or may be used to generate an
interrupt and must be cleared by software.
The analog comparator in MG82FE(L)308/316 supports the wakeup function in Idle or Power-down mode. For
this application, the comparator is conditional enabled during Idle or Power-down modes by ACIDX and ACPDX
in ACCON register. If the comparator and its interrupt are enabled, the comparator can wake up CPU in Idle or
Power-down mode. The detailed function is described in ACCON register description.
14.1. Analog Comparator Structure
The comparator output is sampled at each clock cycle. The conditions on the analog inputs may be such that the
comparator output will toggle excessively. This is especially true if applying slow moving analog inputs. Three
debouncing modes are provided to filter out this noise. In debouncing mode, the comparator uses Timer 1 to
modulate its sampling time. When a relevant transition occurs, the comparator waits until two Timer 1 overflows
have occurred before re-sampling the output. If the new sample agrees with the expected value, ACF is set.
Otherwise, the event is ignored. The filter may be tuned by adjusting the timeout period of Timer 1. Because
Timer 1 is free running, the debouncer must wait for two overflows to guarantee that the sampling delay is at least
1 timeout period. Therefore after the initial edge event, the interrupt may occur between 1 and 2 timeout periods
later.
This document information is the intellectual property of Megawin Technology.
© Megawin Technology Co., Ltd. 2009 All rights reserved.
QP-7300-03D
65/84
AC_PI0 (P1.4)
AC_PI1 (P1.3)
AC_PI2 (P1.2)
AC_PI3 (P1.1)
AC_MI (P1.5)
MVRS[3:0]
PIS[1:0]
ACEN
MEGAWIN
MAKE YOU WIN
0
1
2
3
0
1
AIN0
AIN1
+
-
VDD
Analog Comparator Structure
Timer 1 Overflow
Comparator Interrupt detecting logic,
example of negative edge comparator interrupt with debounce
To ACCON.ACOUT
CF
Start
Compare
Start
MG82FE(L)308/316
Compare
Preliminary, v 0.04
ACCON.ACF

Related parts for mg82fel308