BAT32G1x9 user manual | Chapter 17 Comparator
551 / 1149
Rev.1.02
17.4
Run the instructions
Comparators 0 and comparator 1 can operate independently of each other. The setup method is the same as
running
CMP0 and PGA can be combined to link.
The setup steps for the independent operation and linkage of the comparator are shown in Table 17-3.
Table 17-3
Comparator-related register setup steps
steps
register
bit
Set the value
1
PGACTL
PGAVG0/1/2
Select buff
Note 3
2
PGACTL
PVRVS
0 (Vss pin selection)
Note 3
3
PGACTL
PGAEN
1 (allowed to run)
Note 3
4
Wait for the PGA to settle down (minimum 10μs).
5
COMPSELi
CMP0SEL/CMP1SELi
1
Comparator i positive input selection
6
COMPSELi
CiREFS
Comparator i negative input selection
7
CiRVM
CiRVSn
Sets the value of the built-in reference voltage
8
CVRCTL
CVRVSi
Select the power supply and ground for the built-in reference voltage
9
CVRCTL
CVREi
1 (built-in reference voltage i enable operation)
10
Wait for the reference voltage to settle (min. 20μs).
11
Set VCIN0,
VCIN1x, IVREF0 pins (input), PGAI
(input)
Note 3
as analog input functions.
PMCxx
The VCIN0 pin,
VCi
and
IVREFi
pins feature selection with
PMCxx
position
"1"
(analog input).
Place PMxx
at
"1"
(input mode).
12
COMPMDR
CiENB
1 (allowed to run)
13
Wait for the settling time of the comparator (min. 3
μs).
14
COMPFIR
CiFCK
With or without a digital filter, select the sample clock.
CiEOP, CiEDG
Select the edge detection condition for the interrupt request (rising,
falling, or bilateral edge).
15
COMPOCR
CiOP, i.e.
Set the output of the
VCOUTi
(select Polarity, set Enable or
Disable Output). Refer to
1)".
CiIE
Sets the output that enable or disables interrupt requests.
Refer to "17.4.4 Comparator
C1OTWMD
Set the TIMER WINDOW output license/disable for comparator 1
16
MKxx
Note1
MKL
When using interrupts: Select Mask interrupts.
17
IFxx
Note 1
IFL
When using interrupts: 0
(no interrupt request: initialization)
Note
2
Note1: MKxx, IFxx
is the interrupt control register of the comparator, for details, please refer to "Chapter 25 Interrupt
Function".
Note2: Once the comparator is set, by the time of stable operation, unwanted interrupt requests may be generated, and
the interrupt request flag bits must be initialized.
Note3: The comparator 0 must be set when the PGA is linked
Remark i=0, 1
,
n=0-7
,
x=0-3