CN / EN
文档反馈
感谢关注汇顶文档,期待您的宝贵建议!
感谢您的反馈,祝您愉快!
无匹配项 共计114个匹配页面

Comparator

Introduction

The comparator compares two analog signals: V1 (input voltage) and V2 (reference voltage), and generates a rising edge interrupt when V1 exceeds V2 or falling edge interrupt when V1 is lower than V2. Here it is assumed that V1 is connected to the positive side of the comparator, and V2 is connected to the negative side of the comparator. It is worth noting that interrupts will also be triggered when V1 is already lower than V2 before the comparator is enabled, or V2 is reset to a value higher than V1. The interrupt can be used to wake the system up from sleep state. These two signals can be derived from any of the eight MSIOs (MSIO_0–MSIO_7). Additionally, the comparator can be used to compare an external signal with one of the following:

  • An internal programmable reference voltage.
  • A programmable divided version of VBATL.

Main Features

  • Input voltage (V1)
    • Internal reference voltage (Vref)
    • VBATL-based reference voltage (Vbatl_ref), internal reference based on VBATL
    • Eight MSIOs (MSIO_0–MSIO_7)
  • Reference voltage (V2)
    • Internal reference voltage (Vref)
    • VBATL-based reference voltage (Vbatl_ref), internal reference based on VBATL
    • Eight MSIOs (MSIO_0–MSIO_7)
  • Configurable 26 mV hysteresis
    • No hysteresis
    • –26 mV negative side of hysteresis
    • +26 mV positive side of hysteresis
    • Fully hysteresis 52 mV (±26 mV)
  • Res degeneration is set for calibration.
    • Negative side calibration of comparator
    • Positive side calibration of comparator
  • Bias current set (COMP_REG_0.ICOM_CTRL).
  • Comparator channel selection

Functional Description

Overview

The following figure shows the overview of the wakeup comparator module.

图 146 COMP overview

The Vbatl_ref comes from Vbatl through resistor divided, as shown in the 图 147. Once enabled by using the COMP_REG_0.COMP_EN register, the comparator starts to work. When the wakeup comparator module is started, V1 starts to be compared with V2 continuously. When V1 exceeds V2, the wakeup interrupt will be triggered. The COMP_REG_0.CHANNEL_SEL_P_3_0 and COMP_REG_0.CHANNEL_SEL_N_3_0 registers are used to select the input of V1 and V2. When Vbatl_ref is selected in the COMP_REG_0.CHANNEL_SEL_N_3_0 or COMP_REG_0.CHANNEL_SEL_P_3_0 register, the bit COMP_REG_1.EN_VBATL_REF should be enabled first. The COMP_REG_0.COMP_VBATL_LVL_CTRL_2_0 register is used to select a level value of Vbatl_ref. The COMP_VBATL_LVL_CTRL_2_0 level value ranges from 0 to 7, and the calculation formula of Vbatl_ref is shown below:

V b a t l _ r e f = [ ( L e v e l + 1 ) / 10 ] × V B A T L
图 147 Set of Vbatl_ref control level

When Vref is selected in the COMP_REG_0.CHANNEL_SEL_P_3_0 or COMP_REG_0.CHANNEL_SEL_N_3_0 register, the bit COMP_REG_1.EN_REF should be enabled first. The COMP_REG_0.COMP_REF_CTRL_7_0 register is used to select a level value of Vref. The COMP_REF_CTRL_7_0 level value ranges from 0 to 255 and can be configured by COMP_REG_0.COMP_REF_CTRL_7_0 register. The calculation formula of Vref is shown below. Iref comes from the relatively constant current generated by the chip's bandgap module and will not be affected by other modules, as shown in the 图 148.

V r e f = 7.45   m V × L e v e l  
图 148 Set of Vref control level
Note:

When Vref is selected as reference, to keep the Iref stable, the chip supply voltage (VBATL) must be equal to or higher than 2.4 V.

The selected analog pins will be acquired by the comparator once it is enabled.

Hysteresis

The configurable 52 mV (±26 mV) hysteresis could be added into the wakeup comparator, which helps ensure the slowly changing voltage or a slightly noisy voltage that will cause the comparator not to output to oscillate frequently when the two input voltages are almost close. This could increase the anti-interference ability of the comparator. The hysteresis mode can be configured in COMP_REG_1.HYS_EN. The hysteresis on both sides mode is illustrated in 图 149. The comparator will trigger a falling edge interrupt whenever V1 becomes lower than V2- (VHYST/2). It will also trigger a rising edge interrupt whenever V1 becomes higher than V2+ (VHYST/2). Here it is assumed that V1 is connected to the positive side of the comparator, and V2 is connected to the negative side of the comparator.

图 149 Both sides hysteresis enabled in wakeup comparator

Sample Clock

The clock source for collecting the comp output signal is shown in the figure below. The clock can be set as 250 kHz or 2 MHz by configuring the aon_slow_clk_sel. A higher clock frequency will improve the sampling accuracy, but correspondingly increase the power consumption.

图 150 Comp output signal sample clock

Res Degeneration

Res degeneration is set for calibration. The default values of COMP_REG_1.RDEG_N_3_0 register and COMP_REG_1.RDEG_P_3_0 register are 0x8 and are always kept unchanged. The COMP module obtains positive and negative res degeneration which means users can calibrate the comparator by adjusting positive and negative sides. For example, when the comparator outputs a valid signal, the voltage values at N and P sides of the comparator should be approximately equal; if it is found that the actual voltage at P side is too much larger than that at N side, you can set the value of COMP_REG_1.RDEG_P_3_0 smaller, or set the value of COMP_REG_1.RDEG_N_3_0 larger.

CascRes Half

The COMP_REG_1.CASCRES_HALF register is used to ensure that the comparator is in proper operation at different bias currents.

  • The COMP_REG_1.CASCRES_HALF is set to 1 for half resistor when COMP_REG_0.ICOMP_CTRL_3_0 is close to 0000.
  • The COMP_REG_1.CASCRES_HALF is set to 0 for full resistor when COMP_REG_0.ICOMP_CTRL_3_0 is close to 1111.

Bias Current Set

The COMP_REG_0. ICOMP_CTRL_3_0 register is used to configure the bias current. Higher bias currents will reduce the response time of the comparator, but with a corresponding increase in power consumption. Lower bias currents will increase the response time of the comparator, but with a corresponding reduce in power consumption. It is worth noting that this bias current is also from bandgap module, but this current and Iref are independent of each other and will not interfere with each other.

Glitch Remove

When the voltage reaches the threshold, the signal from the comp output will jitter because of noise interference. In order to eliminate jitter, users can specify a time by configuring the PMU_COMP_GLITCH_REMOVE.GLITCH_REMOVE_CYCLE register and the signal is considered valid if it does not change within this period of time. As the following figure shows, if the duration of the signal is less than the user set time Glitch_t, then the probability of triggering the interrupt will be greatly reduced. If the duration of the signal is larger than the user set time Glitch_t, then the interrupt will definitely be triggered.

图 151 Glitch removing of comp

Registers

COMP_REG_0

  • Name: Comparator Register 0
  • Description: This register includes REF_VALUE setting, COMP enablement, and channel selection.
  • Base Address: 0x4000A800
  • Offset: 0x40
  • Reset Value: 0x00000000
表 745 Comparator Register 0
Bits Field Name RW Reset Description

23:20

CHANNEL_SEL_N_3_0

WR

0x0

Wakeup comparator channel N selection:

  • 0–7: MSIO_0–MSIO_7
  • 8: GND
  • 9: Vbatl_ref
  • 10: Vref

19:16

CHANNEL_SEL_P_3_0

WR

0x0

Wakeup comparator channel P selection:

  • 0–7: MSIO_0–MSIO_7
  • 8: GND
  • 9: Vbatl_ref
  • 10: Vref

15:8

COMP_REF_CTRL_7_0

WR

0x0

COMP REF CTRL (Vref)

Changes the BG-based reference: Min = 0 V, Max =1.9 V (step = 7.5 mV).

  • 11111111: 1.9 V
  • 00000000: 0 V

7

COMP_EN

WR

0x0

Enables or disables wakeup comparator.

  • 0: Disable
  • 1: Enable

6:4

COMP_BATT_LVL_CTRL_2_0

WR

0x0

Changes the Vbatl based ref (Vbatl_vref):

  • 000: Vbatl/10
  • 001: 2 Vbatl/10

  • 111 :8 Vbatl/10

3:0

ICOMP_CTRL_3_0

WR

0x0

  • 0000: Max current (1 μA)
  • 1111: Min current (50 nA)

COMP_REG_1

  • Name: Comparator Register 1
  • Description: This register includes res degeneration, reference source enable, CascRes Half, and Hysteresis.
  • Base Address: 0x4000A800
  • Offset: 0x44
  • Reset Value: 0x00000088
表 746 Comparator Register 1
Bits Field Name RW Reset Description

15

EN_REF

WR

0x0

  • 1: Enable internal Vref.
  • 0: Disable internal Vref.

14

EN_VBATL_REF

WR

0x0

  • 1: Enable Vbatl_ref.
  • 0: Disable Vbatl_ref.

13

CASCRES_HALF

WR

0x0

CascRes Half:

  • 1: Half resistor (high power when ICOMP_CTRL_3_0 is close to 0000)
  • 0: Full resistor (low power when ICOMP_CTRL_3_0 is close to 1111)

12:10

RSVD

R

0x0

Reserved bits

9:8

HYS_EN

WR

0x0

  • 00: No hysteresis
  • 01: Positive Hysteresis only
  • 10: Negative Hysteresis only
  • 11: Hysteresis on both sides

Hysteresis = 26 mV

7:4

RDEG_N_3_0

WR

0x8

Res degeneration N, for calibration only

3:0

RDEG_P_3_0

WR

0x8

Res degeneration P, for calibration only

MCU_WKUP_CTRL

  • Name: MCU Wakeup Control Register of COMP
  • Description: For each bit, 0 indicates IRQ is disabled, and 1 indicates IRQ is enabled.
  • Base Address: 0x4000A000
  • Offset: 0x80
  • Reset Value: 0x0000FFFF
表 747 MCU Wakeup Control Register of COMP
Bits Field Name RW Reset Description
11 EVT_PMU_MSIO_COMP_F WR 0X1
  • 1: Enable the wakeup function of the comp falling edge.
  • 0: Disable the wakeup function of the comp falling edge.

5

EVT_PMU_MSIO_COMP

WR

0x1

  • 1: Enable the wakeup function of the comp rising edge.
  • 0: Disable the wakeup function of the comp rising edge.

AON_SLP_EVENT

  • Name: AON Sleep Event Register of COMP
  • Description: Events that happen in sleep or active mode, controlled by MCU_WKUP_CTRL.
Note:

When clearing the individual event, do not use read-mask-write but simply write ~ (1<< EVENT_BIT) to AON_SLP_EVENT.

  • Base Address: 0x4000A000
  • Offset: 0x84
  • Reset Value: 0x00000000
表 748 AON Sleep Event Register of COMP
Bits Field Name RW Reset Description
11 EVT_PMU_MSIO_COMP_F WR 0x0 Write 0 to this bit to clear comp falling event.

5

EVT_PMU_MSIO_COMP

WR

0x0

Write 0 to this bit to clear rising comp event.

PMU_COMP_GLITCH_REMOVE

  • Name: COMP Glitch Remove Register
  • Description: To remove voltage jitter, add deglitch circuit on comparator output (glitch: from 4 μs to 28 μs at a 4 μs step).
  • Base Address: 0x4000A000
  • Offset: 0x2C0
  • Reset Value: 0x00000000
表 749 COMP Glitch Remove Register
Bits Field Name RW Reset Description

31:3

RSVD

R

Reserved bits

2:0

GLITCH_REMOVE_CYCLE

WR

0

  • 0: No glitch removal
  • 1–7: 4 μs*N glitch removal

Electrical Specifications

In the table below, the typical values are measured at 25 °C, and the minimum and maximum values are measured at the worst process and temperature conditions.

表 750 Electrical specifications
Symbol Description Min. Typ. Max. Unit
VREF Internal reference voltage in wakeup comparator (when VBATL is equal to or higher than 3 V) 0 1900 mV
VBATL_REF Battery based reference voltage in wakeup comparator Vbatl*0.1 Vbatl*0.8 V
ERR_VREF The error rate of the Internal reference voltage (when VBATL is equal to or higher than 3 V) 1.3 5 %
ERR_VBATL_REF The error rate of the battery based reference voltage 1 5 %
P_HYS Positive hysteresis voltage in wakeup comparator 16 26 36 mV
N_HYS Negative hysteresis voltage in wakeup comparator 16 26 36 mV
T_RES Comparator response time 8 12 μs

扫描关注

打开微信,使用“扫一扫”即可关注。