Inputs: None (hardware trigger or manual conversion)
Outputs: Dynamic based on enabled ADC cores
The block automatically creates output ports based on enabled ADC cores:
Example Output Configuration:
The block outputs uint16 raw values directly from ADC data registers.
| Output Type | Range | Description |
|---|---|---|
| uint16 | 0 to 4095 (12-bit) | Raw ADC counts, right-aligned |
| uint16 | 0 to 1023 (10-bit) | Resolution selectable per core |
| uint16 | 0 to 255 (8-bit) | Lower resolution for faster conversion |
| uint16 | 0 to 63 (6-bit) | Maximum speed option |
Scaling formula: Voltage = ADC_counts × (VREF / ADC_max)
Where ADC_max depends on resolution setting (4095 for 12-bit, 1023 for 10-bit, etc.).
| Device Family | Module Type | Dedicated Cores | Shared ADC |
|---|---|---|---|
| PIC32MK | DOS_02508_adc_sar_ctrl_upb_v1_PIC32MK | 6 (ADC0-ADC5) | ADC7 (configurable) |
| dsPIC33C (WACP) | DOS_02508_WACP_adc_sar_ctrl_upb_v1 | 3 (ADC0-ADC2) | ADC7 (configurable) |
| dsPIC33C (Standard) | DOS_02508_adc_sar_ctrl_upb_v1 | 5 (ADC0-ADC4) | ADC7 (configurable) |
Resolution 6/8/10/12-bit selectable per core Dedicated Cores 3-6 dedicated ADC cores (chip dependent) Shared ADC7 Software-configurable multiplexed core Speed Up to 3.25 Msps per core Triggers Independent triggers per core Special Inputs VBat, IVref, Temperature, CTMU
| Parameter | Description | Options |
|---|---|---|
| ADC0_Enable | Enable ADC0 dedicated core | on / off |
| ADC0_pin | Analog input pin assignment for ADC0 | Displays pin mapping (e.g., “AN0 / PA0 / Pin[46]”) |
| ADC0_SELRES | Resolution for ADC0 | 6-bit / 8-bit / 10-bit / 12-bit |
| ADC0_SAMC | Sample time (in TAD cycles) | 0-1023 TAD |
| ADC0_Trig | Trigger source for ADC0 | Manual, PWM, Timer, External (dynamic list) |
| … Similar parameters for ADC1-ADC6 (if available on chip) |
| Parameter | Description | Options |
|---|---|---|
| ADC7_Enable | Enable shared ADC7 | on / off |
| ADC7_ANx checkboxes | Select which analog inputs to connect to ADC7 | Individual checkboxes for each available ANx (typically AN7+) |
| ADC7_SELRES | Resolution for ADC7 | 6-bit / 8-bit / 10-bit / 12-bit |
| ADC7_SAMC | Sample time (in TAD cycles) | 0-1023 TAD |
| ADC7_Trig | Trigger source for ADC7 | Manual, PWM, Timer, External (dynamic list) |
| Parameter | Description | Availability |
|---|---|---|
| Vbat | Battery voltage monitoring | PIC32MK, dsPIC33C-WACP |
| IVref | Internal voltage reference | All variants |
| IVTemp | Internal temperature sensor | All variants |
| CTMU_Temp | CTMU temperature measurement | PIC32MK, dsPIC33C-WACP |
| Parameter | Description | Formula/Range |
|---|---|---|
| ADC_R (impedance) | Source impedance selection | <200Ω to <50kΩ (determines min TAD) |
| SAMC | Sample time in TAD cycles | Calculated: |
| TAD | ADC clock period | Function of system clock and dividers |
| Trigger Type | Description | Use Case |
|---|---|---|
| Manual | Software-initiated conversion | On-demand sampling, debugging |
| PWM Special Event | Triggered by PWM generator at specific phase | Motor control - current sensing at exact PWM point |
| Timer Compare | Triggered by timer match event | Periodic sampling with precise timing |
| External Pin | Hardware trigger from external source | Synchronization with external events |
| Scan Trigger | Sequential triggering of multiple cores | Multi-channel coordinated acquisition |
Independent Triggering Example:
Proper synchronization between PWM generation and ADC sampling is essential for motor control and power conversion. The High-Speed SAR ADC with dedicated cores provides exceptional flexibility for implementing optimal sampling strategies. Understanding when and how to trigger ADC conversions directly impacts control accuracy and system performance.
The MCHP_ADC_HighSpeed_SAR block supports four fundamental synchronization strategies for different control requirements:

ADC Configuration:
ADCx_Trig = 'Timer3 Compare' (or any timer)When to Use:
Limitations:
ADC Configuration:
Key Benefit: Zero latency - control task always uses most recent ADC data (no stale samples).
Configuration Example:
% ADC Block Configuration:
ADC0_Enable = 'on';
ADC1_Enable = 'on';
ADC0_Trig = 'Timer3 Compare'; % Timer trigger
ADC1_Trig = 'Timer3 Compare'; % Same timer
% Timer3 Configuration:
Period = 1/10e3; % 10 kHz sampling rate
% Scheduler Configuration:
% Set control task to trigger on ADC0 interrupt
% Task sample time = 'Inherited' (follows ADC trigger rate)
Best For:
⭐ This is the STANDARD approach for motor control and power conversion applications.
Key Benefits:
ADC Configuration Example (3-Phase FOC with Dedicated Cores):
% PWM Block Configuration (MCHP_PWM_HighSpeed or MCHP_MCPWM):
PWM_Mode = 'Center-aligned';
PWM_Frequency = 20e3; % 20 kHz
SEVTCMP = 0; % Trigger at PWM valley (center point)
% ADC Block Configuration (Dedicated Cores):
ADC0_Enable = 'on'; % Phase A current (AN0)
ADC1_Enable = 'on'; % Phase B current (AN1)
ADC2_Enable = 'on'; % Phase C current (AN2)
% All triggered by PWM valley for simultaneous sampling:
ADC0_Trig = 'PWM1 Special Event';
ADC1_Trig = 'PWM1 Special Event';
ADC2_Trig = 'PWM1 Special Event';
% All use 12-bit resolution:
ADC0_SELRES = '12-bit';
ADC1_SELRES = '12-bit';
ADC2_SELRES = '12-bit';
% Appropriate sample time for low-impedance shunt:
ADC0_SAMC = 10; % TAD cycles
ADC1_SAMC = 10;
ADC2_SAMC = 10;
% Result: All 3 phase currents sampled simultaneously at PWM valley (20 kHz rate)
% Control task triggered by ADC0 interrupt completion
Why Sample at PWM Valley? In center-aligned PWM for 3-phase motor control, the valley (center) is when all three low-side FETs are simultaneously ON. This is the only time when phase currents flow through shunt resistors, enabling accurate current measurement. The dedicated ADC cores allow true simultaneous sampling with zero multiplexing delay. Configuration Example with Shared ADC7 for Auxiliary Measurements:
% Dedicated cores for critical signals (simultaneous):
ADC0_Enable = 'on'; % Phase A current
ADC1_Enable = 'on'; % Phase B current
ADC2_Enable = 'on'; % Phase C current
ADC0_Trig = ADC1_Trig = ADC2_Trig = 'PWM1 Special Event';
% Shared ADC7 for slower auxiliary measurements:
ADC7_Enable = 'on';
ADC7_ANx = [AN10, AN15]; % DC bus voltage, temperature
ADC7_Trig = 'PWM1 Special Event'; % Same instant or slower rate
% Result: 3 phase currents + 2 auxiliary channels sampled at PWM valley
Trigger Source Mapping (Device-Specific):
| PWM Block | PWM Configuration | ADC Trigger Selection |
|---|---|---|
| MCHP_PWM_HighSpeed | Set | TrigOut |
| MCHP_MCPWM | Set | TRIG1/2/3 |
| MCHP_PWM (Standard) | Set | PxSECMP |
Use Case: High-performance control requiring multiple measurements per PWM cycle.
Key Applications:
ADC Configuration Example (Single-Shunt FOC):
% PWM Block (MCHP_PWM_HighSpeed or MCHP_MCPWM):
PWM_Mode = 'Center-aligned';
TrigOut = [1 1 1]; % Enable 3 trigger outputs
TRIG1 = Period * 0.4; % Before valley (sector 1)
SEVTCMP = 0; % Valley (sector 2)
TRIG2 = Period * 0.6; % After valley (sector 3)
% ADC Block Configuration (Dedicated cores for parallel sampling):
ADC0_Enable = 'on'; % Shunt current - Sector 1
ADC0_Trig = 'PWM1 TRIG1';
ADC1_Enable = 'on'; % Shunt current - Sector 2
ADC1_Trig = 'PWM1 Special Event'; % Valley
ADC2_Enable = 'on'; % Shunt current - Sector 3
ADC2_Trig = 'PWM1 TRIG2';
% All measure same shunt at different PWM sectors
% Reconstruct 3-phase currents from single shunt
Advantages:
Considerations:
| Application | Recommended Strategy | ADC Configuration |
|---|---|---|
| 3-Phase FOC Motor Control | PWM → ADC → Task (Strategy 3) | • ADC0-2: 3 phase currents (dedicated cores) |
| Single-Shunt FOC | Multiple Triggers (Strategy 4) | • ADC0-2: Shunt current at 3 PWM sectors |
| BLDC Motor Control | PWM → ADC → Task (Strategy 3) | • ADC0: DC bus current |
| Multi-Motor Control (2+ motors) | Multiple independent PWM→ADC chains | • ADC0-2: Motor 1 (PWM1 trigger) |
| PFC Boost Converter | PWM → ADC → Task (Strategy 3) | • ADC0: Input current |
| Interleaved DC-DC Converters | PWM → ADC → Task (Strategy 3) | • ADC0: Phase 1 current (PWM1 trigger) |
| General Data Acquisition | Timer → ADC → Task (Strategy 2) | • ADC0-6: Multiple sensors at fixed rate |
| Problem | Likely Cause | ADC Configuration Fix |
|---|---|---|
| Phase currents read as zero | ADC not triggered at PWM valley | • Verify: |
| Noisy ADC readings during operation | Sampling during switching transients | • Change trigger to PWM valley or after settling |
| No PWM triggers in dropdown | PWM block not configured with triggers | • In PWM block: Enable |
| Control task not synchronized with ADC | Task triggered by timer, not ADC interrupt | • In Scheduler: Set task trigger source to ADC interrupt |
| Missing ADC samples (overrun) | Next trigger before conversion complete | • Calculate total conversion time: SAMC + Resolution_TAD |
| Simultaneous sampling not working | Cores not triggered by same source | • Verify all cores use identical trigger: |
| ADC7 channels interfering | ADC7 scanning during dedicated core conversion | • Use different trigger for ADC7 (slower rate) |
SAMC_min = 0.002 × R_source + 3SEVTCMP = 0'PWM1 Special Event'This configuration provides optimal current measurement with minimal setup complexity and leverages the dedicated core architecture for true simultaneous sampling.
| Feature | HS SAR (This Block) | dsPIC33A HS 12b | Standard ADC |
|---|---|---|---|
| Simultaneous Sampling | ✅ Yes (dedicated cores) | ❌ No (software sequencing) | ❌ No (multiplexed) |
| Multiple Triggers/Period | ✅ Yes (per core) | ✅ Yes (6 sequences) | ⚠️ Limited (1 special event) |
| Channel Flexibility | ⚠️ Dedicated + 1 shared | ✅ Any channel, any sequence | ✅ Any channel |
| Best For | Multi-phase FOC, high-speed parallel acquisition | Complex sequencing, single-shunt FOC | Legacy support, simple acquisition |
| Register | Purpose | Key Fields |
|---|---|---|
| ADCCONx | ADC control for each core | ON, AICEN, VREFSEL |
| ADCTIMEx | Timing configuration | SAMC, ADCDIV, SELRES |
| ADCTRGx | Trigger source selection | TRGSRC[4:0], STRGSRC |
| ADCDATAx | ADC result register | DATA[11:0] (right-aligned) |
| ADCIMCON1-3 | Input mode control (ADC7) | Channel selection for shared ADC |
| ADCCSS1-2 | Channel scan selection (ADC7) | Bit-mapped channel enable |
Configuration:
Configuration:
Configuration:
Configuration:
| Resolution | Conversion Time | Max Sample Rate (SAMC=3) |
|---|---|---|
| 6-bit | 6 TAD | ~3.25 Msps (@ TAD=307ns) |
| 8-bit | 8 TAD | ~2.4 Msps |
| 10-bit | 10 TAD | ~1.9 Msps |
| 12-bit | 12 TAD | ~1.6 Msps |
Ensure chip has ADC7 shared core capability
Check that desired ANx pins exist on selected chip
Verify ANx not already used by dedicated cores
Increase ADC_R impedance selection
Verify SAMC auto-calculation meets minimum for source impedance
Consider using buffer amplifier for sources >10kΩ
ADC Blocks Overview | Block Reference | Motor Control Examples