Module nrf52::acomp

source ·
Expand description

Analog Comparator Peripheral Driver, for nrf52

Partially based on sam4l implementation of an analog comparator.

The comparator (COMP) compares an input voltage (VIN+) against a second input voltage (VIN-). VIN+ can be derived from an analog input pin (AIN0-AIN7). VIN- can be derived from multiple sources depending on the operation mode of the comparator.

Main features of the comparator are:

  • Input range from 0 V to VDD
  • Single-ended mode
    • Fully flexible hysteresis using a 64-level reference ladder
  • Differential mode
    • Configurable 50 mV hysteresis
  • Reference inputs (VREF):
    • VDD
    • External reference from AIN0 to AIN7 (between 0 V and VDD)
    • Internal references 1.2 V, 1.8 V and 2.4 V
  • Three speed/power consumption modes: low-power, normal and high-speed
  • Single-pin capacitive sensor support
  • Event generation on output changes


  • The nrf52840 only has one analog comparator, so it does need channels However, the HIL was designed to support having multiple comparators, each one with a separate channel. So we create a dummy channel with only one possible value to represent this. Code for channels is based on Sam4l implementation


  • Uses only comparator, with VIN+=AIN5 and VIN-=AIN0