ACC SAMx Block Icon
Analog Comparator Controller (ACC) SAMx Block The ACC SAMx block configures the Analog Comparator Controller peripheral on SAM E70/S70/V71 devices. This block compares two analog signals and outputs a digital result, with optional DAC integration for programmable threshold comparison.

Block Inputs/Outputs

Inputs: Dynamic based on configuration

Port NameData TypeDescriptionOptional
DACC Inputuint16 / singleDAC value when using DAC as minus inputYes

Outputs: Dynamic based on configuration

Port NameData TypeDescriptionOptional
Comparator OutputbooleanCurrent comparator output stateYes
Comparator Edge OutputbooleanEdge detection flag (rising/falling/any)Yes

Dynamic Port Configuration

  • DACC Input appears when DAC0 or DAC1 is selected as the minus input (SELMINUS)
  • Comparator Output and Comparator Edge Output are individually configurable as block outputs

Block Input/Output Datatype

I/O TypeData TypeRangeDescription
DACC Input (16-bit)uint160-4095Raw DAC value (12-bit resolution)
DACC Input (normalized)single0.0-1.0Normalized floating point
DACC Input (Volts)single0.0-3.3Physical voltage scaling
Comparator Outputboolean0/1Current comparison result
Edge Outputboolean0/1Edge event detected

Supported Device Families

FamilySeriesACC ModulesDAC ChannelsNotes
SAME70E70ACCDAC0, DAC1Full support
SAMS70S70ACCDAC0, DAC1Full support
SAMV71V71ACCDAC0, DAC1Full support

Note: This block is specifically for SAMx7 devices with ACC and DACC peripherals. Other SAM families (E5x, C2x, D2x) use different comparator architectures.

Block Parameters

Input Selection
ParameterDescriptionOptions
SELPLUSPositive input selectionAFE0_AD0-AD5, AFE1_AD0-AD1 (with pin mapping)
SELMINUSNegative input selectionTemperature Sensor, VREFP, DAC0, DAC1, AFE0_AD0-AD3

The popup options show both the signal name and the corresponding physical pin.

DAC Configuration

When DAC0 or DAC1 is selected as SELMINUS:

ParameterDescriptionOptions
DACC Initial OutputInitial DAC value at startupNumeric value or MATLAB variable
BlockInput DACC_INPUTDAC input data typeNot a block input, 16-bit unsigned, Normalized float, Volts
DACC SATEnable DAC saturation limitingon/off

DAC Clock: Automatically configured to ~10 MHz (max 12 MHz) based on MCK.

Comparator Configuration
ParameterOptionsDescription
EDGETYPRising, Falling, AnyEdge type for interrupt/fault generation
INVon/offInvert comparator output polarity
HYSTDisabled, 25 mV, 45 mVHysteresis for noise immunity
Interrupt and Fault
ParameterOptionsDescription
CEDisabled, EnabledComparison interrupt enable
FAULTDisabled, By Edge Type, By Comparator OutputPWM fault generation mode

Fault Generation: When enabled, the comparator can generate fault signals for the PWM peripheral.

Output Configuration
ParameterOptionsDescription
Comparator Outputis not a block output, is a boolean block outputEnable comparator state output
Comparator Edge Outputis not a block output, is a boolean block outputEnable edge detection output

Comparator Operation

Signal Sources

Positive Input (SELPLUS):

  • AFE0 channels: AD0-AD5 (mapped to specific pins)
  • AFE1 channels: AD0-AD1 (mapped to specific pins)

Negative Input (SELMINUS):

  • Internal Temperature Sensor output
  • VREFP (voltage reference)
  • DAC0 or DAC1 (programmable threshold)
  • AFE0 channels: AD0-AD3 (external reference)

Hysteresis

Hysteresis prevents output oscillation when input signals are near the threshold:

SettingHysteresis BandUse Case
Disabled0 mVHigh-precision comparison
25 mV±12.5 mVLight noise filtering
45 mV±22.5 mVHeavy noise filtering

Edge Detection

The EDGETYP parameter configures which edges trigger events:

SettingTriggers On
RisingPlus > Minus transition
FallingPlus < Minus transition
AnyBoth transitions

DAC Integration

When DAC0 or DAC1 is selected as SELMINUS, the block automatically:

  1. Enables the DACC peripheral
  2. Configures the DAC clock prescaler
  3. Sets up the selected DAC channel
  4. Creates a block input for dynamic threshold control

DAC Input Scaling

Input TypeFormulaExample
16-bit unsignedVOUT = (Input / 4095) × 3.3V2048 → 1.65V
Normalized [0-1]VOUT = Input × 3.3V0.5 → 1.65V
Volts [0-3.3]VOUT = Input1.65V → 1.65V

Implementation Details

Register Configuration

RegisterDescription
ACC_MRMode register (SELPLUS, SELMINUS, EDGETYP, INV, HYST)
ACC_ACRAnalog control register
ACC_IER/IDRInterrupt enable/disable
DACC_MRDAC mode register
DACC_CDRDAC conversion data register

Peripheral Clock

The block automatically enables peripheral clocks using PMC_PCER registers based on peripheral IDs for both ACC and DACC modules.

Usage Examples

Example 1: Voltage Threshold Detection

Compare an analog input against a fixed DAC threshold:

Configuration:
- SELPLUS: AFE0_AD0 (external analog signal)
- SELMINUS: DAC0 (threshold)
- DACC Initial Output: 2048 (1.65V threshold)
- BlockInput DACC_INPUT: is not a block input (fixed threshold)
- Comparator Output: is a boolean block output

Result: Output is HIGH when input voltage > 1.65V

Example 2: Dynamic Threshold with PWM Fault

Programmable threshold with fault generation for motor control:

Configuration:
- SELPLUS: AFE0_AD2 (current sense)
- SELMINUS: DAC1 (overcurrent threshold)
- BlockInput DACC_INPUT: is a 16 bits unsigned block input
- FAULT: Defined by Comparator Output
- EDGETYP: Rising

Result: PWM fault generated when current exceeds DAC-programmed threshold

Example 3: Temperature Monitoring

Compare external sensor against internal temperature reference:

Configuration:
- SELPLUS: AFE0_AD3 (external thermistor)
- SELMINUS: Temperature Sensor (TS) Output Voltage
- HYST: 25 mV
- Comparator Output: is a boolean block output

Result: Output indicates relative temperature comparison

Troubleshooting

Comparator Not Responding

Problem: Comparator output doesn’t change with input.

Solutions:

  • Verify input pin selection matches physical connections
  • Check that input voltage is within ADC range (0-3.3V)
  • Ensure peripheral clock is enabled (check for PMC errors)

DAC Output Incorrect

Problem: DAC threshold voltage is wrong.

Solutions:

  • Verify DACC Initial Output value is in correct range (0-4095 for 16-bit)
  • Check input scaling mode matches your signal type
  • DAC saturation (DACC_SAT) may be limiting the output

Noisy Output Toggling

Problem: Comparator output oscillates rapidly.

Solutions:

  • Enable hysteresis (25 mV or 45 mV)
  • Add external filtering on analog input
  • Ensure reference (DAC) is stable

PWM Fault Not Generated

Problem: FAULT setting enabled but PWM doesn’t respond.

Solutions:

  • Verify PWM block has fault input enabled
  • Check EDGETYP matches expected fault condition
  • Confirm SELFS setting for fault source selection

See Also