44.7.12 Comparator Control 0

Table 44-13. Register Bit Attribute Legend
SymbolDescriptionSymbolDescriptionSymbolDescription
RReadable bitHCCleared by Hardware(Grey cell)Unimplemented
WWritable bitHSSet by HardwareXBit is unknown at Reset
KWrite to clearSSoftware settable bit
Name: COMPCTRL0
Offset: 0x34
Reset: 0x00000000
Property: PAC Write-Protection, Enable Protected

Bit 3130292827262524 
 SUT[5:0]OUT[1:0] 
Access R/WR/WR/WR/WR/WR/WR/WR/W 
Reset 00000000 
Bit 2322212019181716 
 FLEN[2:0]HYST[1:0] SPEEDSWAP 
Access R/WR/WR/WR/WR/WR/WR/W 
Reset 0000000 
Bit 15141312111098 
  MUXPOS[2:0] MUXNEG[2:0] 
Access R/WR/WR/WR/WR/WR/W 
Reset 000000 
Bit 76543210 
  RUNSTDBYINTSEL[1:0]SINGLE ENABLE  
Access R/WR/WR/WR/WR/W 
Reset 00000 

Bits 31:26 – SUT[5:0] Start-up Time

Each time a comparator is enabled, the comparison will be enabled after the startup time specified by these bits using the formula:

SUT = (20us / ((2^PRESCALER) x t(GCLK_AC))).

Refer to electrical specifications for minimum analog comparator start-up time required to initialize COMPCTRLn.SUT bits to.

Note:
  1. If COMPCTRLn.SINGLE=1 even if comparator COMPCTRLn.ENABLE=1 the comparator is turned off to conserve power. When CTRLB.STARTn is set by the user to start the comparison the comparator is enabled, after COMPCTRLn.SUT time has expired the comparison is made and then the comparator is again shut off to conserve power ready for the next time.
  2. These bits can be written only while COMPCTRLn.ENABLE is zero.
  3. Zero value is not allowed and can lead to unpredictable behavior.

Bits 25:24 – OUT[1:0] Output

These bits configure the output selection for comparator n. COMPCTRLn.OUT can be written only while COMPCTRLn.ENABLE is zero.

Note: If the asynchronous path is selected, the filter settings are ignored.
Note: If OUT = 0x2 = Sync, Filtering must be enabled, FLEN>0.
ValueNameDescription
0x0OFFThe output of COMPn is not routed to the COMPn I/O port
0x1ASYNCThe asynchronous output of COMPn is routed to the COMPn I/O port
0x2SYNCThe synchronous output (including filtering) of COMPn is routed to the COMPn I/O port

Bits 23:21 – FLEN[2:0] Filter Length

These bits configure the filtering for comparator n. COMPCTRLn.FLEN can only be written while COMPCTRLn.ENABLE is zero.

Note: If COMPCTRLn.OUT=0x1 (Asyncronous Mode), these bits are ignored.
ValueNameDescription
0x0OFFNo filtering

(Not valid if COMPCTRLn.OUT = 0x2 = sync)

0x1MAJ33-bit majority function (2 of 3)
0x2MAJ55-bit majority function (3 of 5)
0x3-0x7N/AReserved

Bits 20:19 – HYST[1:0] Hysteresis Level

These bits indicate the hysteresis level of comparator n when hysteresis is enabled (COMPCTRLn.HYSTEN=1). Hysteresis is available only for continuous mode (COMPCTRLn.SINGLE=0). COMPCTRLn.HYST can be written only while COMPCTRLn.ENABLE is zero.

ValueNameDescription
0x0HYST1010mV (Refer to AC Electrical Specifications)
0x1HYST2020mV (Refer to AC Electrical Specifications)
0x2HYST4040mV (Refer to AC Electrical Specifications)
0x3HYST6060mV (Refer to AC Electrical Specifications)

Bit 17 – SPEED Speed Selection

This bit indicates the speed/propagation delay mode of comparator n. COMPCTRLn.SPEED can be written only while COMPCTRLn.ENABLE is zero.

Note: High speed equates to higher operating current as well as faster response time.
ValueNameDescription
0x0HIGHHigh speed, high power
0x1LOWLow speed, low power

Bit 16 – SWAP Swap Inputs and Invert

This bit swaps the positive and negative inputs to COMPn and inverts the output. This function can be used for offset cancellation. COMPCTRLn.SWAP can be written only while COMPCTRLn.ENABLE is zero.

ValueDescription
0The output of MUXPOS connects to the positive input, and the output of MUXNEG connects to the negative input.
1The output of MUXNEG connects to the positive input, and the output of MUXPOS connects to the negative input.

Bits 14:12 – MUXPOS[2:0] Positive Input Mux Selection

These bits select which input will be connected to the positive input of comparator n. COMPCTRLn.MUXPOS can be written only while COMPCTRLn.ENABLE is zero.

ValueNameDescription
0x0AC_AIN0 Comparator(n) Positive analog input AIN0
0x1AC_AIN1 Comparator(n) Positive analog input AIN1
0x2AC_AIN2 Comparator(n) Positive analog input AIN2
0x3AC_AIN3Comparator(n) Positive analog input AIN3
0x4AVSSInternal AVSS connection
0x5ReservedReserved
0x6ReservedReserved
0x7INTDACInternal DACn

Bits 10:8 – MUXNEG[2:0] Negative Input Mux Selection

These bits select which input will be connected to the negative input of comparator n. COMPCTRLn.MUXNEG can only be written while COMPCTRLn.ENABLE is zero.

ValueNameDescription
0x0AC_AIN0 Comparator(n) Negative analog input AIN0
0x1AC_AIN1 Comparator(n) Negative analog input AIN1
0x2AC_AIN2 Comparator(n) Negative analog input AIN2
0x3AC_AIN3Comparator(n) Negative analog input AIN3
0x4AVSSInternal AVSS connection
0x5BANDGAPInternal 0.8v Bandgap
0x6AVSSAVSS
0x7INTDACInternal DACn

Bit 6 – RUNSTDBY Run in Standby

This bit controls the behavior of the comparator during standby sleep mode. This bit can only be written while COMPCTRLn.ENABLE is zero.

ValueDescription
0The comparator n is disabled during sleep.
1The comparator n continues to operate during sleep.

Bits 5:4 – INTSEL[1:0] Interrupt Selection

These bits select the condition for comparator n (n=0,1) to generate an interrupt or event. COMPCTRLn.INTSEL can be written only while COMPCTRLn.ENABLE is zero.

ValueNameDescription
0x0TOGGLEInterrupt on comparator n output toggle
0x1RISINGInterrupt on comparator n output rising
0x2FALLINGInterrupt on comparator n output falling
0x3EOCInterrupt on end of comparison (single-shot mode only)

Bit 3 – SINGLE Single-Shot Mode

This bit determines the operation of comparator n. COMPCTRLn.SINGLE can be written only while COMPCTRLn.ENABLE is zero.

Note: To initiate a single-shot comparison the user's software must write the respective CTRLB.STARTn = 1. Be aware that If COMPCTRLn.SINGLE=1 even if comparator COMPCTRLn.ENABLE=1 the comparator is turned off to conserve power.

When CTRLB.STARTn is set by the user to start the comparison the comparator is enabled, after COMPCTRLn.SUT time has expired the comparison is made and then the comparator is again shut off to conserve power ready for the next time.

ValueDescription
0Comparator n operates in continuous measurement mode.
1Comparator n operates in single-shot mode.

Bit 1 – ENABLE Enable

Due to synchronization, there is delay from updating the register until the comparator is enabled/disabled. The value written to COMPCTRLn.ENABLE will read back immediately after being written. SYNCBUSY.COMPCTRLn is set. SYNCBUSY.COMPCTRLn is cleared when the peripheral is enabled/disabled.

Writing a one to COMPCTRLn.ENABLE will prevent further changes to the other bits in COMPCTRLn. These bits remain protected until COMPCTRLn.ENABLE is written to zero and the write is synchronized.

ValueDescription
0Writing a zero to this bit disables comparator n.

1Writing a one to this bit enables comparator n.