When to use:
When to use:
When NOT to use:
The MCHP Comparator / Op-Amp / Voltage Reference block provides access to the analog comparator, operational amplifier, and voltage reference (CVR) modules found in legacy dsPIC30F and dsPIC33FJ devices (DS70357 & DS70648). This block combines configuration for all three analog functions in a single interface.
Key Features:
The Comparator / Op-Amps / Voltage Reference block opens its custom configuration window (not the Simulink mask) when double-clicked:

The window groups settings by physical peripheral:
AVdd / AVss or Vref+ / Vref- power rail, enter the analog rail voltages, and optionally route the reference to the CVref1O pin.-1 by default.Each comparator/op-amp instance can be independently configured:
| Parameter | Description | Options |
|---|---|---|
| CON (Comparator Mode) | Operating mode selection | Off, Comparator, Op-Amp |
| OPMODE (Op-Amp Mode) | Op-amp configuration | Unity Gain, Non-Inverting, Inverting (device-dependent) |
| CPOL (Comparator Polarity) | Output polarity | Normal, Inverted |
| Parameter | Description | Range |
|---|---|---|
| CVR1OE | CVR1 output enable | On, Off |
| CVR2OE | CVR2 output enable | On, Off |
| VREFSEL | Voltage reference source | Internal, External |
| RLadder | Resistor ladder tap selection | 0-15 (16 levels) |
| AVdd | Positive supply voltage | Voltage value |
| AVss | Negative supply voltage | Voltage value |
| CVRSS | CVR range selection | Low (0 to VDD/4), High (VDD/4 to VDD) |
| Parameter | Description | Options |
|---|---|---|
| OutputPort_COE_RP | Comparator output pin assignment | Pin list or “None” |
| InputP_CREF | Positive input selection | Internal CVR, External pins |
| InputN_CCH | Negative input selection | External pins, Internal reference |
| Parameter | Description | Options |
|---|---|---|
| Trigger_EventInterrupt_EVPOL | Event trigger polarity | Disabled, Rising edge, Falling edge, Both edges |
| BlockOutputEvent | Enable event output port | Enabled, Disabled |
| BlockOutputState | Enable state output port | Enabled, Disabled |
| IntPriority | Interrupt priority level | 0-7 |
| Parameter | Description | Range |
|---|---|---|
| FilterFreq | Digital filter cutoff frequency | 10 Hz to 10 GHz |
| Blanking | Enable blanking functionality | Enabled, Disabled |
| BlankingSignal | Blanking source signals | Signal list |
| BlankingTruthTable | Logic table for blanking conditions | Truth table matrix |
| Port | Description | Data Type |
|---|---|---|
| Event Optional | Comparator event output | Boolean (per instance) |
| State Optional | Current comparator state | Boolean (per instance) |
Note: Output ports are dynamically created based on BlockOutputEvent and BlockOutputState settings.
This block is designed for legacy dsPIC30F and dsPIC33FJ devices. For newer devices:
Available pins vary significantly by device package and configuration. The MCHP Master block detects available pins based on:
CVR output voltage depends on:
Formula:
Digital filtering and blanking features provide noise immunity:
Note: Newer dsPIC33E/C/A devices use separate dedicated blocks:
1. Set CON = "Comparator" for desired instance
2. Configure CREF (positive input) to internal CVR
3. Set RLadder to desired voltage level
4. Configure CCH (negative input) to external pin
5. Enable OutputPort_COE_RP for digital output
1. Set CON = "Op-Amp" for desired instance
2. Select OPMODE (Unity Gain, Non-Inverting, etc.)
3. Map input pins appropriately
4. Verify device supports selected op-amp mode
1. Enable CVR1OE or CVR2OE
2. Set VREFSEL and CVRSS for range
3. Program RLadder for desired voltage
4. Output appears on CVR output pin