LPCOMP — Low-power comparator

Low-power comparator (LPCOMP) compares an input voltage against a reference voltage.

Listed here are the main features of LPCOMP:

In System ON, the LPCOMP can generate separate events on rising and falling edges of a signal, or sample the current state of the pin as being above or below the selected reference. The block can be configured to use any of the analog inputs on the device. Additionally, the low-power comparator can be used as an analog wakeup source from System OFF or System ON. The comparator threshold can be programmed to a range of fractions of the supply voltage.

Note: LPCOMP cannot be used (STARTed) at the same time as COMP. Only one comparator can be used at a time.
Figure 1. Low-power comparator
Low-power comparator

The wakeup comparator (LPCOMP) compares an input voltage (VIN+), which comes from an analog input pin selected via the PSEL register, against a reference voltage (VIN-) selected via registers REFSEL and EXTREFSEL.

The PSEL, REFSEL, and EXTREFSEL registers must be configured before the LPCOMP is enabled through the ENABLE register.

The HYST register allows enabling an optional hysteresis in the comparator core. This hysteresis shall prevent noise on the signal to create unwanted events. Figure below illustrates the effect of an active hysteresis on a noisy input signal. It is disabled by default, and shall be configured before enabling LPCOMP as well.

Figure 2. Effect of hysteresis on a noisy input signal
Effect of hysteresis on a noisy input signal

The LPCOMP is started by triggering the START task. After a startup time of tLPCOMP,STARTUP, the LPCOMP will generate a READY event to indicate that the comparator is ready to use and the output of the LPCOMP is correct. The LPCOMP will generate events every time VIN+ crosses VIN-. More specifically, every time VIN+ rises above VIN- (upward crossing) an UP event is generated along with a CROSS event. Every time VIN+ falls below VIN- (downward crossing), a DOWN event is generated along with a CROSS event. When hysteresis is enabled, the upward crossing level becomes (VIN- + VHYST/2), and the downward crossing level becomes (VIN- - VHYST/2).

The LPCOMP is stopped by triggering the STOP task.

LPCOMP will be operational in both System ON and System OFF mode when it is enabled through the ENABLE register. See POWER — Power control for more information about power modes. Note that it is not allowed to go to System OFF when a READY event is pending to be generated.

All LPCOMP registers, including ENABLE, are classified as retained registers when the LPCOMP is enabled. However, when the device wakes up from System OFF, all LPCOMP registers will be reset.

The LPCOMP can wake up the system from System OFF by asserting the ANADETECT signal. The ANADETECT signal can be derived from any of the event sources that generate the UP, DOWN and CROSS events. In case of wakeup from System OFF, no events will be generated, only the ANADETECT signal. See the ANADETECT register (ANADETECT) for more information on how to configure the ANADETECT signal.

The immediate value of the LPCOMP can be sampled to RESULT by triggering the SAMPLE task.

See RESETREAS for more information on how to detect a wakeup from LPCOMP.

Shared resources

The LPCOMP shares analog resources with SAADC. While it is possible to use the SAADC at the same time as the LPCOMP, selecting the same analog input pin for both modules is not supported.

Additionally, LPCOMP shares registers and other resources with other peripherals that have the same ID as the LPCOMP. See Peripherals with shared ID for more information.

The LPCOMP peripheral shall not be disabled (by writing to the ENABLE register) before the peripheral has been stopped. Failing to do so may result in unpredictable behavior.

Pin configuration

You can use the LPCOMP.PSEL register to select one of the analog input pins, AIN0 through AIN7, as the analog input pin for the LPCOMP.

See GPIO — General purpose input/output for more information about the pins. Similarly, you can use EXTREFSEL to select one of the analog reference input pins, AIN0 and AIN1, as input for AREF in case AREF is selected in EXTREFSEL. The selected analog pins will be acquired by the LPCOMP when it is enabled through ENABLE.

Registers

Instances

InstanceDomainBase addressTrustZoneSplit accessDescription
MapAttDMA
LPCOMP : S
LPCOMP : NS
APPLICATION0x5001A000
0x4001A000
USSNANoLow-power comparator

Register overview

RegisterOffsetTZDescription
TASKS_START0x000Start comparator
TASKS_STOP0x004Stop comparator
TASKS_SAMPLE0x008Sample comparator value
SUBSCRIBE_START0x080Subscribe configuration for task START
SUBSCRIBE_STOP0x084Subscribe configuration for task STOP
SUBSCRIBE_SAMPLE0x088Subscribe configuration for task SAMPLE
EVENTS_READY0x100LPCOMP is ready and output is valid
EVENTS_DOWN0x104Downward crossing
EVENTS_UP0x108Upward crossing
EVENTS_CROSS0x10CDownward or upward crossing
PUBLISH_READY0x180Publish configuration for event READY
PUBLISH_DOWN0x184Publish configuration for event DOWN
PUBLISH_UP0x188Publish configuration for event UP
PUBLISH_CROSS0x18CPublish configuration for event CROSS
SHORTS0x200Shortcuts between local events and tasks
INTENSET0x304Enable interrupt
INTENCLR0x308Disable interrupt
RESULT0x400Compare result
ENABLE0x500Enable LPCOMP
PSEL0x504Input pin select
REFSEL0x508Reference select
EXTREFSEL0x50CExternal reference select
ANADETECT0x520Analog detect configuration
HYST0x538Comparator hysteresis enable

TASKS_START

Address offset: 0x000

Start comparator

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
AWTASKS_STARTStart comparator
Trigger1Trigger task

TASKS_STOP

Address offset: 0x004

Stop comparator

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
AWTASKS_STOPStop comparator
Trigger1Trigger task

TASKS_SAMPLE

Address offset: 0x008

Sample comparator value

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
AWTASKS_SAMPLESample comparator value
Trigger1Trigger task

SUBSCRIBE_START

Address offset: 0x080

Subscribe configuration for task START

Bit number313029282726252423222120191817161514131211109876543210
IDBAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWCHIDX[0..255]DPPI channel that task START will subscribe to
BRWEN
Disabled0Disable subscription
Enabled1Enable subscription

SUBSCRIBE_STOP

Address offset: 0x084

Subscribe configuration for task STOP

Bit number313029282726252423222120191817161514131211109876543210
IDBAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWCHIDX[0..255]DPPI channel that task STOP will subscribe to
BRWEN
Disabled0Disable subscription
Enabled1Enable subscription

SUBSCRIBE_SAMPLE

Address offset: 0x088

Subscribe configuration for task SAMPLE

Bit number313029282726252423222120191817161514131211109876543210
IDBAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWCHIDX[0..255]DPPI channel that task SAMPLE will subscribe to
BRWEN
Disabled0Disable subscription
Enabled1Enable subscription

EVENTS_READY

Address offset: 0x100

LPCOMP is ready and output is valid

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWEVENTS_READYLPCOMP is ready and output is valid
NotGenerated0Event not generated
Generated1Event generated

EVENTS_DOWN

Address offset: 0x104

Downward crossing

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWEVENTS_DOWNDownward crossing
NotGenerated0Event not generated
Generated1Event generated

EVENTS_UP

Address offset: 0x108

Upward crossing

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWEVENTS_UPUpward crossing
NotGenerated0Event not generated
Generated1Event generated

EVENTS_CROSS

Address offset: 0x10C

Downward or upward crossing

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWEVENTS_CROSSDownward or upward crossing
NotGenerated0Event not generated
Generated1Event generated

PUBLISH_READY

Address offset: 0x180

Publish configuration for event READY

Bit number313029282726252423222120191817161514131211109876543210
IDBAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWCHIDX[0..255]DPPI channel that event READY will publish to
BRWEN
Disabled0Disable publishing
Enabled1Enable publishing

PUBLISH_DOWN

Address offset: 0x184

Publish configuration for event DOWN

Bit number313029282726252423222120191817161514131211109876543210
IDBAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWCHIDX[0..255]DPPI channel that event DOWN will publish to
BRWEN
Disabled0Disable publishing
Enabled1Enable publishing

PUBLISH_UP

Address offset: 0x188

Publish configuration for event UP

Bit number313029282726252423222120191817161514131211109876543210
IDBAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWCHIDX[0..255]DPPI channel that event UP will publish to
BRWEN
Disabled0Disable publishing
Enabled1Enable publishing

PUBLISH_CROSS

Address offset: 0x18C

Publish configuration for event CROSS

Bit number313029282726252423222120191817161514131211109876543210
IDBAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWCHIDX[0..255]DPPI channel that event CROSS will publish to
BRWEN
Disabled0Disable publishing
Enabled1Enable publishing

SHORTS

Address offset: 0x200

Shortcuts between local events and tasks

Bit number313029282726252423222120191817161514131211109876543210
IDEDCBA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWREADY_SAMPLEShortcut between event READY and task SAMPLE
Disabled0Disable shortcut
Enabled1Enable shortcut
BRWREADY_STOPShortcut between event READY and task STOP
Disabled0Disable shortcut
Enabled1Enable shortcut
CRWDOWN_STOPShortcut between event DOWN and task STOP
Disabled0Disable shortcut
Enabled1Enable shortcut
DRWUP_STOPShortcut between event UP and task STOP
Disabled0Disable shortcut
Enabled1Enable shortcut
ERWCROSS_STOPShortcut between event CROSS and task STOP
Disabled0Disable shortcut
Enabled1Enable shortcut

INTENSET

Address offset: 0x304

Enable interrupt

Bit number313029282726252423222120191817161514131211109876543210
IDDCBA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWREADYWrite '1' to enable interrupt for event READY
Set1Enable
Disabled0Read: Disabled
Enabled1Read: Enabled
BRWDOWNWrite '1' to enable interrupt for event DOWN
Set1Enable
Disabled0Read: Disabled
Enabled1Read: Enabled
CRWUPWrite '1' to enable interrupt for event UP
Set1Enable
Disabled0Read: Disabled
Enabled1Read: Enabled
DRWCROSSWrite '1' to enable interrupt for event CROSS
Set1Enable
Disabled0Read: Disabled
Enabled1Read: Enabled

INTENCLR

Address offset: 0x308

Disable interrupt

Bit number313029282726252423222120191817161514131211109876543210
IDDCBA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWREADYWrite '1' to disable interrupt for event READY
Clear1Disable
Disabled0Read: Disabled
Enabled1Read: Enabled
BRWDOWNWrite '1' to disable interrupt for event DOWN
Clear1Disable
Disabled0Read: Disabled
Enabled1Read: Enabled
CRWUPWrite '1' to disable interrupt for event UP
Clear1Disable
Disabled0Read: Disabled
Enabled1Read: Enabled
DRWCROSSWrite '1' to disable interrupt for event CROSS
Clear1Disable
Disabled0Read: Disabled
Enabled1Read: Enabled

RESULT

Address offset: 0x400

Compare result

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARRESULTResult of last compare. Decision point SAMPLE task.
Below0Input voltage is below the reference threshold (VIN+ < VIN-)
Above1Input voltage is above the reference threshold (VIN+ > VIN-)

ENABLE

Address offset: 0x500

Enable LPCOMP

Bit number313029282726252423222120191817161514131211109876543210
IDAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWENABLEEnable or disable LPCOMP
Disabled0Disable
Enabled1Enable

PSEL

Address offset: 0x504

Input pin select

Bit number313029282726252423222120191817161514131211109876543210
IDAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWPSELAnalog pin select
AnalogInput00AIN0 selected as analog input
AnalogInput11AIN1 selected as analog input
AnalogInput22AIN2 selected as analog input
AnalogInput33AIN3 selected as analog input
AnalogInput44AIN4 selected as analog input
AnalogInput55AIN5 selected as analog input
AnalogInput66AIN6 selected as analog input
AnalogInput77AIN7 selected as analog input

REFSEL

Address offset: 0x508

Reference select

Bit number313029282726252423222120191817161514131211109876543210
IDAAAA
Reset 0x0000000400000000000000000000000000000100
IDR/WFieldValue IDValueDescription
ARWREFSELReference select
Ref1_8Vdd0VDD * 1/8 selected as reference
Ref2_8Vdd1VDD * 2/8 selected as reference
Ref3_8Vdd2VDD * 3/8 selected as reference
Ref4_8Vdd3VDD * 4/8 selected as reference
Ref5_8Vdd4VDD * 5/8 selected as reference
Ref6_8Vdd5VDD * 6/8 selected as reference
Ref7_8Vdd6VDD * 7/8 selected as reference
ARef7External analog reference selected
Ref1_16Vdd8VDD * 1/16 selected as reference
Ref3_16Vdd9VDD * 3/16 selected as reference
Ref5_16Vdd10VDD * 5/16 selected as reference
Ref7_16Vdd11VDD * 7/16 selected as reference
Ref9_16Vdd12VDD * 9/16 selected as reference
Ref11_16Vdd13VDD * 11/16 selected as reference
Ref13_16Vdd14VDD * 13/16 selected as reference
Ref15_16Vdd15VDD * 15/16 selected as reference

EXTREFSEL

Address offset: 0x50C

External reference select

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
A-RWEXTREFSELExternal analog reference select
AnalogReference00Use AIN0 as external analog reference
AnalogReference11Use AIN1 as external analog reference

ANADETECT

Address offset: 0x520

Analog detect configuration

Bit number313029282726252423222120191817161514131211109876543210
IDAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWANADETECTAnalog detect configuration
Cross0Generate ANADETECT on crossing, both upward crossing and downward crossing
Up1Generate ANADETECT on upward crossing only
Down2Generate ANADETECT on downward crossing only

HYST

Address offset: 0x538

Comparator hysteresis enable

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWHYSTComparator hysteresis enable
Disabled0Comparator hysteresis disabled
Enabled1Comparator hysteresis enabled

Electrical specification

LPCOMP Electrical Specification

SymbolDescriptionMin.Typ.Max.Units
tLPCANADETTime from VIN crossing (≥ 50 mV above threshold) to ANADETECT signal generated2.7µs
VINPOFFSETInput offset including reference ladder error-4040mV
VHYSTOptional hysteresis38mV
tSTARTUPStartup time for LPCOMP2851134µs