The MCHP_ADC_HighSpeed_SAR_dsPIC block configures the high-speed SAR (Successive Approximation Register) ADC peripheral found in dsPIC33CH and dsPIC33CK devices. This ADC architecture features 3-6 dedicated ADC cores (chip-dependent) plus one shared ADC7 core, enabling simultaneous multi-channel acquisition with independent trigger sources and conversion settings per core.
Two blocks configure the same hardware with different parameter organization:
Both blocks target the same peripheral.
The block dialog has 9 tabs: one main configuration tab, one tab per dedicated core (ADC0-ADC6), and one shared ADC tab. Tabs for non-existent cores are automatically hidden based on the selected chip.

Global ADC settings shared across all cores.

Per-core configuration tabs. Only tabs for existing cores are visible.
Shared ADC7 configuration with checkbox selection for auxiliary analog inputs.
None. The ADC is triggered by hardware events (PWM, Timer) or software trigger, configured via block parameters.
Dynamic outputs created based on enabled ADC cores and selected analog inputs. Each enabled core or shared ADC input creates one output port.
Each enabled dedicated core creates one output port named after its analog input:
| Core | Typical Output Name | Description |
|---|---|---|
| ADC0 | AN0, ANA0, ANB0, ANC0 | Dedicated core 0 output |
| ADC1 | AN1, ANA1, ANB1, ANC1 | Dedicated core 1 output |
| ADC2 | AN2, ANA2, ANB2, ANC2 | Dedicated core 2 output |
| … | … | Additional cores as available |
The exact name depends on:
Each selected analog input on shared ADC7 creates one output port named after the input:
When DMA mode is enabled for dedicated cores (ADC0-6), outputs become vectors instead of scalars:
| DMA Mode | Output Size | Description |
|---|---|---|
| Single trigger | 1 element | Standard scalar output |
| 1 trig / 1 element | 1 element | Ping-pong buffer with one element |
| 2 trig / 2 elements | 2 elements | Ping-pong buffer |
| 3 trig / 3 elements | 3 elements | Ping-pong buffer |
| 4 trig / 4 elements | 4 elements | Ping-pong buffer |
Example: With ADC0 enabled and “2 trig / 2 elements” DMA mode, the output is a [1x2] vector containing two consecutive ADC samples.
Type: Popup
Default: “Optimized for PWM resolution & ADC conversion speed”
Options:
Enables the auxiliary PLL (APLL) to generate a faster ADC clock independent of the PWM clock. This allows optimizing ADC speed without affecting PWM resolution.
When to use:
Type: Popup
Default: “Integer (right aligned)”
Options:
Controls the ADCON1Hbits.FORM register bit.
Integer format (FORM=0):
Fractional format (FORM=1):
Type: Checkbox
Default: Off
Visibility: Hidden (not available on most dsPIC33C devices)
Enables the ADCON1Lbits.NRE bit for noise reduction. This feature is only available on dsPIC33EP GS devices. The checkbox is hidden on dsPIC33CH/CK.
Type: Popup
Default: “Single trigger - (default)”
Options:
Enables DMA-based buffering for dedicated cores (ADC0-6 only, not available for shared ADC7). When enabled, the block output becomes a vector containing multiple samples captured on consecutive triggers.
How it works:
Example: “2 trig / 2 elements” with ADC0 enabled and PWM trigger:
[sample1, sample2][sample3, sample4]Limitations:
Type: Popup
Default: “Triggered at end of previous time step”
Options:
Determines how ADC conversions are triggered and synchronized with the Simulink model time step.
“Triggered at end of previous time step” (Timer-synchronized):
“Triggered by custom source” (User-defined trigger):
“Continuously triggered. Output is last conversion” (Free-running):
Type: Popup
Default: “Dynamic Options” (device-dependent)
Visibility: Visible when “Triggered by custom source” selected
Selects the trigger source for ADC conversions. The list is dynamically populated based on the selected chip.
Common trigger sources:
For ADTRG31 (PPS input): On dsPIC33CK devices, when “ADTRG31 (PPS input)” is selected, a second popup appears to select the physical pin to map to the ADCTRG PPS input. The block automatically configures the PPS routing.
Example: Select “PWM1 Trigger 1” to trigger ADC conversions at a specific point in the PWM cycle (e.g., center-aligned PWM for motor control current sensing).
Type: Popup
Default: “Trig model step after all sample using this trigger are converted”
Options:
Controls when the Simulink model advances to the next time step relative to ADC conversion completion.
“None (independant)”:
“Trig model step after all sample using this trigger are converted”:
“Trig model step after all sample from this block are converted”:
How it works internally: The block determines the slowest ADC channel (longest conversion time) and configures an interrupt on that channel’s completion to trigger the Simulink task. For dedicated cores (ADC0-6), the slowest core triggers. For shared ADC7, the last sequential channel triggers.
Type: Edit
Default: 0.001 (1 ms)
Simulink sample time for the block’s output ports. Set to match your control loop period.
Typical values:
Each dedicated core has its own configuration tab with the following parameters:
Type: Popup
Default: “Dynamic Options” (device-dependent)
Options:
Selects the analog input source for this dedicated core. The list is populated based on the chip’s datasheet and includes:
Pin mapping:
The popup displays the pin assignment: ANx / Port / Pin[number]
Hardware limitation: Each dedicated core is hard-wired to specific analog input options defined by the chip architecture. You cannot arbitrarily assign any ANx to any core. Check the device datasheet for core-to-input mapping.
“Not used”: Select this to disable the core. No output port is created.
Type: Popup
Default: “< 10 kOhm”
Options:
Specifies the maximum source impedance connected to this analog input. The block automatically calculates the minimum required sampling time (SAMC) based on this impedance to ensure accurate conversions.
Impedance-to-sampling time formula: @@PROT_1@@
Examples:
“max sampling time”: Select this to use the maximum SAMC value (1023 TAD), allowing accurate conversion of very high impedance sources (e.g., resistive dividers with hundreds of kΩ).
Where SAMC is used:
Info field: The “ADCx Info” read-only field at the bottom of each tab displays the calculated timing: @@PROT_2@@
Type: Popup
Default: “12 bits”
Options:
Sets the ADC resolution for this core via the @@PROT_32@@ field (SELRESx register).
| Resolution | Max Value | Conversion Time (typical) | Use Case |
|---|---|---|---|
| 12 bits | 4095 (0xFFF) | ~272 ns × 12 = 3.3 µs | High precision measurements |
| 10 bits | 1023 (0x3FF) | ~272 ns × 10 = 2.7 µs | Moderate precision, faster |
| 8 bits | 255 (0xFF) | ~272 ns × 8 = 2.2 µs | Fast conversions |
| 6 bits | 63 (0x3F) | ~272 ns × 6 = 1.6 µs | Maximum speed |
Trade-off: Higher resolution → more accurate → slower conversion. Lower resolution → less accurate → faster conversion.
Type: Popup
Default: “signed 16 bits”
Options:
Determines the output data type and the sign configuration for this core.
“unsigned 16 bits”:
“signed 16 bits”:
Typical usage:
Type: Popup
Default: “No Oversampling”
Options:
Enables hardware oversampling/filtering using the ADC’s built-in digital filter (ADCFLTRx register).
“No Oversampling”:
“Burst convert of n samples are Summed”:
“Burst convert of n samples are Averaged”:
When enabled, also configure: “Filter / Oversampling burst of” parameter.
Type: Popup
Default: “256 samples”
Options:
Selects the number of samples (n) for burst oversampling when filtering is enabled.
Register configuration:
Effective resolution increase (Average mode): Oversampling can increase effective resolution by reducing quantization noise: @@PROT_3@@
| Samples | Extra Bits | Effective Resolution (12-bit base) |
|---|---|---|
| 4 | 1 bit | 13 bits |
| 16 | 2 bits | 14 bits |
| 64 | 3 bits | 15 bits |
| 256 | 4 bits | 16 bits |
Conversion time impact: Total conversion time = (sampling time + conversion time) × n_samples
Example: 12-bit resolution, 256 sample average:
Type: Popup
Default: “End sampling and start conversion”
Options:
Controls the behavior of the trigger event via the @@PROT_42@@ bit (STRGEN parameter).
“End sampling and start conversion” (SAMCEN = 0, default):
“Start sampling followed by conversion” (SAMCEN = 1):
Timing diagram:
@@PROT_4@@
Type: Checkbox
Default: Off
Enables synchronous sampling mode via the @@PROT_43@@ bit (SSAMPEN parameter).
When enabled:
When disabled:
The shared ADC7 core uses a software-controlled multiplexer to select from multiple analog inputs. Unlike dedicated cores, you enable individual inputs via checkboxes, and each enabled input creates a separate output port.
Type: Popup per analog input
Default: “Not used”
Options:
Each available analog input (typically AN7 and above) has its own popup. The popup combines multiple settings:
Example selections:
Pin mapping: The prompt string displays the pin assignment: @@PROT_44@@ (example)
Special inputs: On some devices, shared ADC7 can access internal signals:
The availability of these special inputs depends on the chip’s maskset and is detected from the chip database.
Type: Popup
Default: “< 10 kOhm”
Options: Same as dedicated cores
Specifies the maximum source impedance for ALL inputs connected to shared ADC7. The block calculates the required SHRSAMC value for the shared core.
Type: Popup
Default: “12 bits”
Options: 6/8/10/12 bits
Sets the resolution for shared ADC7. All inputs on shared ADC7 use the same resolution.
Displays calculated timing information for ADC7 conversions, including per-channel conversion times and total sequential conversion time.
The block automatically calculates ADC timing parameters and displays them in the “Info” fields on each tab.
1. Sampling Time (tSample): @@PROT_5@@
2. Conversion Time (tConversion): @@PROT_6@@
3. Total Conversion Time: @@PROT_7@@
4. For Oversampling: @@PROT_8@@
5. For Shared ADC7 (sequential channels): @@PROT_9@@
Configuration:
Calculation:
Displayed in Info field: @@PROT_10@@
The ADC clock (TAD) is derived from either the system clock or the auxiliary PLL:
System clock path: @@PROT_11@@
Auxiliary PLL path (if enabled): @@PROT_12@@
The block automatically selects CLKDIV to maximize ADC speed while respecting the maximum fADC specification (typically 50 MHz).
The available trigger sources vary by device family:
Master core:
Slave core:
The block supports four synchronization strategies:
Configuration: “Continuously triggered. Output is last conversion”
Behavior:
Use case: Monitoring applications, non-critical measurements
Configuration: “Triggered at end of previous time step”
Behavior:
Use case: Standard control loops, synchronized data acquisition
Configuration: “Triggered by custom source” + “None (independant)”
Behavior:
Use case: Event-driven acquisition, PWM-synchronized measurements not critical to model timing
Configuration: “Triggered by custom source” + “Trig model step after all sample…”
Behavior:
Use case: Motor control current sensing, PWM-synchronized control loops
For motor control applications, the typical configuration is:
Setup:
Timing: @@PROT_13@@
Benefits:
The block configures the following dsPIC33C ADC registers:
| Register | Bit Field | Description | Configured By |
|---|---|---|---|
| ADCON1H | FORM | Output format (0=integer, 1=fractional) | “Conversion Format” |
| ADCON1L | NRE | Noise reduction enable | “Noise Reduction Enabled” |
| ADCON5H | WARMTIME | Wake-up time (min 10 µs) | Auto-calculated |
| ADCON3H | CLKSEL | Clock source (0=system, 1=aux PLL) | “Auxiliary clock” |
| ADCON3H | CLKDIV | Clock divider | Auto-calculated |
| ADCON3L | REFSEL | Reference source (0=AVdd/AVss) | Fixed to 0 |
| Register | Bit Field | Description | Configured By |
|---|---|---|---|
| ADCON4H | CxCHS | Core x channel select | “Analog input pin” |
| ADCORExL | SAMC | Sample time (TAD cycles) | “Input Impedance” |
| ADCORExH | RES | Resolution (0=6-bit, 1=8-bit, 2=10-bit, 3=12-bit) | “Resolution of conversion” |
| ADCON4L | SAMCxEN | Sample enable mode | “Initial trigger option” |
| ADCON4L | SYNCTRGx | Synchronous trigger | “Ensure synchronous sampling” |
| Register | Bit Field | Description | Configured By |
|---|---|---|---|
| ADTRIGxL | TRGSRCx | Trigger source for core x | “User defined trigger” |
| ADTRIGxH | TRGSRCx | Trigger source (continued) | “User defined trigger” |
| ADLVLTRGL/H | LVLENx | Level trigger enable | Auto (based on trigger type) |
| Register | Bit Field | Description | Configured By |
|---|---|---|---|
| ADCFLTRx | FLEN | Filter enable | “Filter / Oversampling” |
| ADCFLTRx | MODE | Filter mode (0=sum, 3=average) | “Filter / Oversampling” |
| ADCFLTRx | OVERSAM | Oversampling ratio | “Filter / Oversampling burst of” |
| ADCFLTRx | CHNLID | Channel ID (which input) | Auto (core index) |
| Register | Bit Field | Description | Configured By |
|---|---|---|---|
| ADCMPxCON1 | SIGNENx | Signed enable for input x | “Output format” |
| Register | Bit Field | Description | Configured By |
|---|---|---|---|
| ADCON1L | DMABL | DMA buffer length (log2) | “Multiple trigger - Vector output” |
The block automatically configures ADC interrupts when time step synchronization is enabled:
| Register | Bit Field | Description |
|---|---|---|
| ADIExL/H | IEx | Interrupt enable for core x |
| _IPCx | Priority | Interrupt priority (auto) |
The interrupt triggers the Simulink task when the last ADC channel completes conversion.
The block outputs raw ADC counts (unsigned or signed integer). To convert to voltage:
Unsigned:
Voltage = (ADC_counts / ADC_max) × VREF
Signed:
Voltage = ((ADC_counts / ADC_max) × VREF × 2) - VREF
Where:
ADC_max = 2^resolution - 1 (e.g., 4095 for 12-bit)VREF = Reference voltage (typically 3.3V)Unsigned Q15:
Voltage = (ADC_counts / 32768) × VREF
Signed Q15:
Voltage = (ADC_counts / 32768) × VREF
(Signed Q15 range: -1 to +0.9999)
When oversampling is enabled:
Sum mode:
Voltage = (ADC_sum / (ADC_max × n_samples)) × VREF
Average mode:
ADC Output (uint16) ──► Gain: VREF/ADC_max ──► Data Type: single ──► Voltage (V)
For 12-bit unsigned, VREF=3.3V:
ADC Output (uint16) ──► Gain: 3.3/4095 = 0.000806 ──► Voltage (V)
The TLC file (MCHP_ADC_HighSpeed_SAR_dsPIC.tlc) generates initialization code in the model’s Start function and interrupt service routines if time step synchronization is enabled.
Initialization (Start function):
/* ADC common settings */
ADCON1Hbits.FORM = 0; // Integer format
ADCON5Hbits.WARMTIME = 10; // 10 µs warm-up
ADCON3Hbits.CLKSEL = 1; // Auxiliary PLL
ADCON3Hbits.CLKDIV = 7; // Clock divider
ADCON3Lbits.REFSEL = 0; // AVdd/AVss reference
/* Dedicated core configuration */
ADCON4Hbits.C0CHS = 0; // ADC0 -> AN0
ADCORE0L = 23; // Sampling time
ADCON4Lbits.SAMC0EN = 0; // Trigger ends sampling
/* Trigger configuration */
ADTRIG0Lbits.TRGSRC0 = 4; // PWM1 Trigger 1
/* Enable ADC */
ADCON1Lbits.ADON = 1; // Turn on ADC
Interrupt Service Routine (if synchronized):
void __attribute__((__interrupt__, auto_psv)) _ADCAN0Interrupt(void)
{
IFS5bits.ADCAN0IF = 0; // Clear interrupt flag
// Read ADC result
// Trigger Simulink task
}
When “Trig model step after conversion” is enabled, the generated code uses the ADC interrupt to trigger the Simulink task, ensuring measurements are available before the control algorithm executes.
This block targets dsPIC33C family devices:
Dual-core devices with master/slave architecture. Check device datasheet for exact ADC core count.
Example devices:
Single-core high-performance DSCs with up to 6 dedicated ADC cores.
Example devices:
Digital power devices with integrated voltage regulators.
Example devices:
The number of dedicated ADC cores varies by device. The block automatically detects available cores from the chip database (MCHP.ADC.HS_SAR.nDedicatedCore).
| Device Family | Typical Core Count | Notes |
|---|---|---|
| dsPIC33CK MP/MC | 4-6 cores | High pin count devices have more cores |
| dsPIC33CH | 3-6 cores | Varies by device |
| dsPIC33CDV | 3-4 cores | Digital power optimized |
% Add block to model
add_block('MCHP_Blockset/Analog IO/ADC dsPIC\nHigh Speed SAR', [mdl '/ADC_HS']);
% Configure key parameters
set_param([mdl '/ADC_HS'], 'ADC0_pin', 'AN0');
set_param([mdl '/ADC_HS'], 'ADC0_R', '< 10 kOhm');
set_param([mdl '/ADC_HS'], 'ADC0_res', '12 bits');
ADC HighSpeed SAR - PIC32-style interface for the same hardware
ADC - Standard 10-bit ADC for dsPIC30F/33F/33E
PWM Blocks - PWM blocks for motor control trigger sources
PWM Category — ADC Synchronization — See “PWM-ADC Synchronization” section