HomeAbout UsContact Us

Fixing STM32H7 ADC Calibration Timeout Failures

By Jithin Tom
Published in Embedded Concepts
November 21, 2026
11 min read
Fixing STM32H7 ADC Calibration Timeout Failures

Table Of Contents

01
Problem Statement
02
Root Cause Analysis
03
The Hardware Calibration Engine
04
Complete Solution Implementation
05
Verification and End-of-Line Production Testing
06
Production Debug Flowchart
07
Summary
08
Related Reading
09
References
10
Frequently Asked Questions

ADC calibration failures on STM32H7 can look like intermittent hardware faults, especially when the application waits in HAL_ADCEx_Calibration_Start() during boot. The result may be HAL_ERROR or a watchdog reset while a polling loop is still executing. But a calibration timeout does not, by itself, identify an ADC silicon defect.

This article examines the software polling budget, ADC clock and power prerequisites, silicon-revision differences, and dual-ADC sequencing. It also shows a defensible way to bound calibration time, check a known reference during production testing, and keep the procedure compatible with the installed STM32CubeH7 release. Numerical timings and code paths must be verified for the exact STM32H7 part, revision, and HAL driver; family-wide claims are not safe substitutes for those checks.

Problem Statement

Three distinct symptoms are often grouped together under “ADC calibration timeout”:

  1. Fast HAL_ERROR return: the HAL’s loop-count budget expires before ADC_CR.ADCAL clears, or the API fails a prerequisite such as disabling an active ADC.
  2. Long blocking wait or watchdog reset: the ADC never finishes, and the timeout implementation or watchdog service interval does not match the system’s needs.
  3. Board-dependent failures: supply, clock-tree, regulator startup, reset state, or silicon-revision differences can change whether the calibration sequence completes.

STM32H7 ADC1/ADC2 support 16-bit conversion on the device family discussed here. The calibration subsystem includes offset correction and, where implemented, linearity correction. The ADC clock, not the CPU’s instruction rate, determines calibration hardware progress; the HAL’s software loop is a separate timing mechanism. A HAL HAL_ERROR result should therefore be correlated with a snapshot of ADC_CR, ADC_ISR, the HAL state/error fields and the clock configuration.

Why This Problem Escapes Development Testing

Calibration can appear reliable during board bring-up yet fail later when a project changes clock settings, compiler optimisation, HAL package version or initialization order. Prototype and production hardware can also differ in supply quality and analog routing; do not assume a specific percentage of defective PCBs or that ST evaluation boards use a particular VREF regulator arrangement without checking their schematics.

Useful initial observations are the MCU marking, HAL_GetDEVID(), HAL_GetREVID(), SystemCoreClock, the ADC kernel clock source and prescaler, ADC_CR.ADCAL, ADC_CR.ADEN, ADC_CR.ADVREGEN, and the exact line in the installed HAL source where execution waits.

+--------------------------------------------------------------------------+
| STM32H7 ADC CALIBRATION: TWO DIFFERENT TIME BASES |
| |
| Hardware: calibration progress is clocked by the ADC. |
| Example planning count used by some HAL versions: N = 165010 |
| N / 50 MHz = 3.3002 ms |
| N / 36 MHz = 4.5836 ms |
| N / 10 MHz = 16.501 ms |
| |
| Software: a HAL loop counter counts polling iterations. |
| Iterations are NOT CPU cycles and are NOT milliseconds. |
| Duration depends on core clock, bus latency and compiler output. |
| |
| Check the target datasheet, ADC clock and installed HAL source. |
| Do not use these example values as universal hardware limits. |
+--------------------------------------------------------------------------+

Root Cause Analysis

A reliable diagnosis distinguishes (1) a software timeout, (2) device-revision-specific ADC clock and BOOST configuration, (3) a clock or internal regulator that is not ready, (4) an invalid multi-ADC sequence, and (5) an analog reference or board problem. The following cases are diagnostic hypotheses to confirm with registers and measurements, not five proven defects present on every STM32H7.

1. The HAL Loop Counter Bug: Software Polling vs Asynchronous Hardware

Some STM32CubeH7 HAL implementations poll calibration as follows (condensed excerpt; the full function has locking, ADC disable and state-management logic):

/* Illustrative excerpt from stm32h7xx_hal_adc_ex.c. */
__IO uint32_t wait_loop_index = 0U;
while (LL_ADC_IsCalibrationOnGoing(hadc->Instance) != 0UL)
{
wait_loop_index++;
if (wait_loop_index >= ADC_CALIBRATION_TIMEOUT)
{
/* The actual HAL also updates state and unlocks the handle. */
return HAL_ERROR;
}
}

ADC_CALIBRATION_TIMEOUT is a number of iterations of this loop. Calling it “CPU clock cycles” or converting it directly to milliseconds is incorrect. Each iteration has different timing depending on instruction generation, flash/cache and peripheral bus access latency.

ST’s early HAL source contained a 64000 timeout value; a reported calibration-timeout issue was acknowledged and addressed in the STM32CubeH7 release history. The particular elapsed time at which that loop expires must be measured on the target, not inferred from an assumed 12 cycles per iteration. ST’s later implementation contains 633600000U, with a comment estimating a worst-case hardware requirement using 165010 / 125000 = 1.32 s; that calculation is in the HAL comment, but the counter still counts loop iterations rather than processor cycles.

The exact calibration count is likewise not a single family-wide constant: the LL driver documents 1,280 ADC clocks for offset and 16,384 for an offset-plus-linearity mode in one definition, while later HAL timeout budgeting uses a conservative 165,010-clock estimate. Follow the applicable silicon datasheet and library revision instead of asserting that all variants always run precisely 165,010 clocks.

For illustration, 165010 / 36000000 = 4.58 ms; it says nothing about how many CPU polling-loop iterations elapse over that interval.

The Patch Dilemma: 633.6 Million Cycles

Recent STM32H7 HAL source includes:

/* In a published STM32H7 HAL release; inspect your local copy. */
#define ADC_CALIBRATION_TIMEOUT (633600000U)

The accompanying comment treats 633600000 as a conservative CPU-cycle budget estimate for the slowest supported ADC clock, but the implementation actually compares that constant to wait_loop_index. It is not a timer register, does not itself impose a 1.32-second deadline, and certainly does not prove a universal 15-25-second boot freeze. Its real duration has to be profiled with the chosen clock/optimisation settings.

A longer guard can conceal a dead or missing ADC clock until the watchdog fires. The safer solution is a reviewed, elapsed-time-aware patch in the HAL driver with intact state transitions and locking; the calibration API is otherwise still blocking. Select a timeout from the slowest documented ADC clock and required calibration mode, with margin, and ensure it is shorter than the applicable watchdog budget.

2. Silicon Revision Mismatch: Rev Y vs Rev V

The STM32H743/753 and STM32H750 Rev Y-to-Rev V migration changes ADC clocking and BOOST interpretation. Confirm the device ID as well as the revision before applying this table; other STM32H7 subfamilies have different ADC IP revisions.

ItemRev Y (illustrative STM32H743/753 family)Rev V
Typical revision ID0x10030x2003
CPU maximum (device/voltage dependent)Up to 400 MHzUp to 480 MHz
ADC analog clockingNo extra internal /2 in this comparisonInternal /2 on the ADC analog path
ADC_CR.BOOSTSingle-bit selectionTwo-bit selection
ADC clock and operating rangeCheck Rev Y limitsCheck Rev V limits and /2
Calibration and linearity factorsUse part-specific calibration guidanceUse part-specific calibration guidance

The revised BOOST encodings are not interchangeable. The HAL implementation’s ADC_ConfigureBoostMode() already checks the hardware revision and computes the appropriate setting when configured correctly. Avoid patching BOOST bits by hand unless your silicon-specific reference manual requires it.

The Internal Divide-by-2 Trap

On the affected Rev V ADC analog path, the effective analog clock is one-half the selected input frequency after the relevant common prescaler. For instance, a 36 MHz source can produce an 18 MHz analog clock. That changes analog timing and the required BOOST range. It does not establish that Rev V boards will fail calibration “twice as often”: a failure depends on the software timeout, clocks and board state.

For Rev V the documented two-bit BOOST selection is:

BOOST bitsRev V analog-frequency range
00Up to 6.25 MHz
01Above 6.25 MHz to 12.5 MHz
10Above 12.5 MHz to 25 MHz
11Above 25 MHz to 50 MHz

Importantly, 11 is a valid mode, not reserved as the original article claimed. Use the HAL driver revision that supports your silicon and verify the clock domain before adjusting either the prescaler or BOOST.

3. ADC Clock Tree Misconfiguration and Domain Synchronization

The ADC common clock selector can use an asynchronous kernel clock or a synchronous clock from the bus. In the STM32H743-style clock tree, RCC->D2CCIP2R.ADCSEL selects the asynchronous source (for example PLL2_P, PLL3_R or per_ck) and the common ADC CCR.CKMODE selects synchronous versus asynchronous operation. The CCR.PRESC field applies to asynchronous mode. Check the exact reference manual for the selected device and verify that the source is enabled and locked.

+--------------------------------------------------------------------------+
| STM32H7 ADC CLOCK SELECTION (SCHEMATIC, NOT A REGISTER MAP) |
| |
| PLL2_P / PLL3_R / per_ck ---> RCC ADCSEL ----+ |
| | |
| ADC kernel |
| | |
| asynchronous CKMODE = 00 |
| | |
| PRESC /N |
| | |
| HCLK -----------------------------------+ | |
| | | |
| sync CKMODE /1,/2,/4 |
| | | |
| +--+--+ |
| | |
| ADC clock input |
| | |
| Rev V analog path: /2 |
| | |
| ADC calibration engine |
| |
| Only the selected CKMODE branch feeds the ADC. |
+--------------------------------------------------------------------------+

The CKMODE Register Mismatch

For the relevant STM32H74x/H75x ADC common register, CKMODE = 00 selects the asynchronous kernel clock and 01, 10, 11 select the synchronous bus-derived clock with divisors of 1, 2 and 4 respectively. Thus enabling PLL2 is not sufficient if CKMODE selects a synchronous source. Conversely, a correct synchronous configuration does not need PLL2 to be running.

Check hadc->Init.ClockPrescaler, the common ADC12_COMMON->CCR state after HAL_ADC_Init(), and whether the selected clock frequency satisfies the device’s maximum ADC clock and silicon-revision constraints. A high synchronous clock can violate the ADC specifications; that does not, by itself, prove the calibration state machine must hang.

The ADVREGEN Stabilization Requirement

The ADC must leave deep power-down and have its internal analog voltage regulator enabled before calibration. For supported HAL versions, HAL_ADC_Init() and the related HAL power-up code handle these operations and insert a stabilization delay (one published STM32H7 HAL defines ADC_STAB_DELAY_US as 10 us). The exact minimum and additional margin are device-specific: do not present 20 us as a universal STM32H7 mandate.

The valid sequence is: ensure the ADC peripheral clock is enabled; exit deep power-down; enable ADVREGEN; wait at least the specified stabilization interval; keep ADEN = 0; then initiate calibration. Do not attempt a second manual regulator sequence just because the HAL routine is slow. Verify ADC_CR after HAL_ADC_Init() and check that the HAL’s initialization is not being bypassed.

4. The Dual-Mode Configuration Race Condition

In dual-ADC designs, ADC1 and ADC2 have individual calibration engines but share configuration through the ADC12 common block. A robust initialization-order practice is to calibrate each disabled ADC before setting the combined mode, then configure and start the master/slave sequence according to the reference manual. This avoids mixing calibration with an active multimode conversion setup.

/* Safe ordering, assuming hadc1/hadc2 are fully configured. */
if (HAL_ADC_Init(&hadc1) != HAL_OK ||
HAL_ADC_Init(&hadc2) != HAL_OK)
{
Error_Handler();
}
/* Perform the required single-ended offset calibration for both ADCs. */
if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET,
ADC_SINGLE_ENDED) != HAL_OK ||
HAL_ADCEx_Calibration_Start(&hadc2, ADC_CALIB_OFFSET,
ADC_SINGLE_ENDED) != HAL_OK)
{
Error_Handler();
}
if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
{
Error_Handler();
}

This is an ordering example, not proof that calling HAL_ADCEx_MultiModeConfigChannel() first always locks ADC2 or that ADCALLIN requires a master trigger. If the ADC2 calibration does not finish, record ADC2->CR, ADC12_COMMON->CCR, clock configuration and the HAL return path and compare them to the installed HAL source. If the application needs both single-ended and differential inputs, offset-calibrate each required input mode as documented.

5. VREF+ Reference Instability and Dynamic CDAC Loading

A poor analog supply or reference can degrade conversion accuracy, violate startup limits, or make an otherwise marginal design sensitive to temperature. It is worth checking VDDA, VSSA, VREF+, grounding, decoupling and the absolute operating ranges before assuming a software bug. But the claim that a 5 mV peak-to-peak ripple causes calibration to hang indefinitely is not established by the cited sources, nor is there a universal 2 mm capacitor placement rule for every H7 PCB.

+--------------------------------------------------------------------------+
| ANALOG SUPPLY AND REFERENCE: ILLUSTRATIVE CHECKS |
| |
| Supply / regulator ---- local bypass ----> VDDA |
| | |
| ADC analog rail |
| |
| Reference source ----- local bypass ----> VREF+ |
| | |
| ADC reference |
| |
| Analog return --------------------------> VSSA |
| |
| Check component placement, value, ESR/ESL and routing |
| against the actual datasheet and board reference design. |
| Do not infer an exact timeout threshold from ripple alone. |
+--------------------------------------------------------------------------+

Scope the rails under real boot conditions and record their startup timing, noise and voltage limits. A changing VREF+ may require re-running offset calibration for accuracy even if calibration itself completes. Evaluate reference and layout modifications against the hardware design guide, not a generic capacitor prescription.

The Hardware Calibration Engine

STM32H7 ADC calibration is hardware-assisted. The HAL requests a calibration mode and waits for the hardware ADCAL indication to clear. There are two different types of correction: linearity coefficients for the converter and offset coefficients for the selected input configuration. The procedure and factor-loading mechanism vary by ADC IP revision and HAL version.

Linearity Calibration (ADCALLIN = 1, ADCAL = 1)

For supported ADCs, ADC_CALIB_OFFSET_LINEARITY requests both the linearity and offset sequence. Six linearity coefficient words are managed by the ADC; accessing them correctly involves the documented linear calibration APIs, not treating CALFACT2 as one universally portable 30-bit field. The complete factor representation and access sequence differ across ADC IP variants.

ST AN5354 states that linearity coefficients are determined during manufacturing and stored in Flash. After power-up, the device-specific coefficients can be loaded using a compatible HAL implementation, for example HAL_ADCEx_LinearCalibration_FactorLoad(). The same note allows performing a runtime linearity calibration, recommending controlled conditions such as fADC = 10 MHz and VREF <= 2 V for that option. Consequently, “run complete linearity calibration once on every boot” is not universal advice.

If you choose the factory-calibration loading path, verify API availability and the specific ADC variant. Do not copy calibration words from a different MCU: coefficients are device-specific.

Offset Calibration (ADCALLIN = 0, ADCAL = 1)

ADC_CALIB_OFFSET requests offset calibration without recalibrating linearity. The calibration factor is associated with the selected single-ended or differential mode; run the applicable mode(s) with the ADC disabled and a stable clock, power and reference. One STM32H7 LL definition documents 1,280 ADC clock cycles for offset calibration, but the required elapsed-time budget still depends on the part and actual ADC clock.

ST recommends offset calibration after power-up and repeating it after relevant analog-supply or temperature changes; AN5354 explicitly calls out a VREF change greater than 10% and also recommends recalibrating after changes in VDDA or temperature. It does not prescribe a universal 10-degree-Celsius threshold. A factor of zero is not by itself a documented hardware failure test.

Complete Solution Implementation

The safest production approach is to keep the vendor’s HAL state machine and initialization sequence intact. Before modifying anything, confirm the installed stm32h7xx_hal_adc_ex.c macro and verify that ADC clocks, calibration mode, power-up delay and watchdog budget are consistent. Prefer updating an affected HAL package to a maintained version; do not assume that one particular firmware-package tag fixes all devices.

If a measured timeout defect remains, add an elapsed-time check inside the existing HAL calibration function, preserving the driver’s lock/unlock, state and return paths. The following examples are scoped to the STM32H743/753/H750 HAL family and need adaptation to the concrete hardware and HAL release.

1. Robust Time-Based Calibration Engine

A caller-side wrapper cannot stop the existing HAL_ADCEx_Calibration_Start() once it is blocked. Therefore a real bounded timeout requires editing the HAL’s internal polling loop (or using a fully reviewed LL driver of your own). This example illustrates a target-local HAL source patch, not a replacement HAL API or drop-in library:

/* In application startup, BEFORE calibration, for Cortex-M7 with DWT. */
#include "stm32h7xx_hal.h"
#include <stdbool.h>
static bool adc_dwt_clock_ready(void)
{
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
uint32_t before = DWT->CYCCNT;
for (volatile uint32_t i = 0U; i < 32U; ++i) {
__NOP();
}
return DWT->CYCCNT != before;
}

After verifying that DWT CYCCNT advances, replace only the calibration wait/timeout block in the matching stm32h7xx_hal_adc_ex.c implementation; keep all the source’s surrounding error-state and lock management. For a 480 MHz core a 500 ms budget is 240 million cycles, below half the counter range, so unsigned subtraction remains valid across wraparound:

/* PATCH FRAGMENT INSIDE HAL_ADCEx_Calibration_Start():
* Enter this code with the ADC start sequence and HAL lock already done.
* Check that adc_dwt_clock_ready() returned true before calling this API.
*/
#define ADC_APP_CAL_TIMEOUT_MS 500UL
const uint32_t cycle_start = DWT->CYCCNT;
const uint32_t cycle_budget =
(SystemCoreClock / 1000UL) * ADC_APP_CAL_TIMEOUT_MS;
while (LL_ADC_IsCalibrationOnGoing(hadc->Instance) != 0UL)
{
if ((uint32_t)(DWT->CYCCNT - cycle_start) >= cycle_budget)
{
ADC_STATE_CLR_SET(hadc->State,
HAL_ADC_STATE_BUSY_INTERNAL,
HAL_ADC_STATE_ERROR_INTERNAL);
__HAL_UNLOCK(hadc);
return HAL_ERROR; /* Match the existing HAL error contract. */
}
}

SystemCoreClock must reflect the actual active core clock; the DWT counter must be available, enabled and not stopped by the chosen power/debug mode. A tick-based alternative uses HAL_GetTick() with unsigned elapsed-time subtraction, only when its interrupt-driven time base is running throughout calibration. Neither method makes the ADC calibration operation non-blocking. Choose the budget from the slowest valid ADC clock and hardware sequence and arrange watchdog servicing or staged startup accordingly. Do not patch vendor driver source silently: record the diff and revalidate it after HAL updates.

2. Silicon Revision Detection and Clock Setup

Use the HAL’s device and revision identification to aid diagnosis, but let the revision-aware HAL configure BOOST; manually writing ADC_CR.BOOST based on a guessed analog frequency can make the problem worse.

#include "stm32h7xx_hal.h"
/* Intended for STM32H743/753/H750-style DEVICE_ID 0x450 devices. */
typedef enum {
ADC_SILICON_REV_Y,
ADC_SILICON_REV_V,
ADC_SILICON_OTHER
} adc_silicon_revision_t;
static adc_silicon_revision_t adc_get_silicon_revision(void)
{
if (HAL_GetDEVID() != 0x450UL) {
return ADC_SILICON_OTHER;
}
if (HAL_GetREVID() == REV_ID_Y) {
return ADC_SILICON_REV_Y;
}
if (HAL_GetREVID() == REV_ID_V) {
return ADC_SILICON_REV_V;
}
return ADC_SILICON_OTHER;
}
/* Basic H743-style asynchronous-clock readiness check.
* It is not a frequency measurement or full clock-tree validator.
*/
static HAL_StatusTypeDef adc_check_async_clock_source(void)
{
uint32_t source = RCC->D2CCIP2R & RCC_D2CCIP2R_ADCSEL;
if (source == 0U && (RCC->CR & RCC_CR_PLL2RDY) == 0U) {
return HAL_ERROR; /* PLL2_P selected, but PLL2 not ready. */
}
if (source == RCC_D2CCIP2R_ADCSEL_0 &&
(RCC->CR & RCC_CR_PLL3RDY) == 0U) {
return HAL_ERROR; /* PLL3_R selected, but PLL3 not ready. */
}
return HAL_OK; /* per_ck and actual frequencies need separate checks. */
}

Use adc_check_async_clock_source() only if ADC12_COMMON->CCR.CKMODE selects asynchronous clocking; otherwise it is irrelevant. A complete validation must calculate the actual clock source, divider, silicon-revision analog /2 (where applicable), VDDA range and BOOST requirements using the HAL and datasheet for the target. Do not use the simplistic BOOST = 0b10 from the original code at every Rev V speed; valid BOOST settings span all four encodings. Initialization should fail closed on an unrecognized revision rather than assuming a Rev V profile.

3. Dual-Mode Safe Initialization Sequence

The following example keeps ADC calibration separate from multimode setup and checks every HAL return value. hadc1, hadc2 and multimode must already be filled with valid device-specific settings by the application or CubeMX. Initialize the HAL time base and clocks before calling this function; enable the DWT counter separately if the HAL wait loop has been patched to use it.

#include "stm32h7xx_hal.h"
HAL_StatusTypeDef DualADC_Robust_Init(
ADC_HandleTypeDef *hadc1,
ADC_HandleTypeDef *hadc2,
ADC_MultiModeTypeDef *multimode)
{
HAL_StatusTypeDef status;
if (hadc1 == NULL || hadc2 == NULL || multimode == NULL) {
return HAL_ERROR;
}
status = HAL_ADC_Init(hadc1);
if (status != HAL_OK) return status;
status = HAL_ADC_Init(hadc2);
if (status != HAL_OK) return status;
/* For supported H743/753/H750 HAL versions, restore this MCU's
* factory-programmed linearity factors before offset calibration.
* If your device/driver lacks this API, use its documented
* alternative calibration procedure instead.
*/
status = HAL_ADCEx_LinearCalibration_FactorLoad(hadc1);
if (status != HAL_OK) return status;
status = HAL_ADCEx_LinearCalibration_FactorLoad(hadc2);
if (status != HAL_OK) return status;
status = HAL_ADCEx_Calibration_Start(
hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED);
if (status != HAL_OK) return status;
status = HAL_ADCEx_Calibration_Start(
hadc2, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED);
if (status != HAL_OK) return status;
/* Set multimode while both ADCs are not converting. */
status = HAL_ADCEx_MultiModeConfigChannel(hadc1, multimode);
if (status != HAL_OK) return status;
/* Start the master/slave conversions using the required HAL
* functions for the chosen dual mode after this initialization.
*/
return HAL_OK;
}

Do not manually force ADEN or spin forever on ADRDY after this function: let the relevant HAL start API sequence ADC enabling, and handle its return status. If the application requires differential inputs, carry out their offset calibration at the proper point too. An existing HAL/CubeMX-generated MX_ADC1_Init() should not be called again on the same handle without a reason.

Verification and End-of-Line Production Testing

Successful calibration means the calibration sequence completed; it does not by itself prove ADC accuracy. A production test should confirm that a known voltage produces counts within a justified tolerance after stabilization, ideally using an external precision reference and multiple input points. VREFINT can assist in checking the analog reference voltage, but it is not an independent complete ADC linearity test.

The original code used 0x1FF1E778 as a universal VREFINT calibration address and rejected zero calibration factors. Both assumptions are unsafe. The STM32H743-style HAL defines VREFINT_CAL_ADDR (commonly 0x1FF1E860 on that device), and calibration data interpretation depends on the model. Use the installed device headers, not a hard-coded address.

/* STM32H743-style VREFINT diagnostic, for ADC instance that supports it.
* Configure hadc for a single 16-bit regular conversion, no DMA/oversampling,
* adequate internal sampling time and valid reference/channel path first.
*/
#include "stm32h7xx_hal.h"
#include "stm32h7xx_ll_adc.h"
#include <stdbool.h>
#include <stdint.h>
bool ADC_Production_Verification_Screen(ADC_HandleTypeDef *hadc,
uint32_t min_vref_mv,
uint32_t max_vref_mv,
uint32_t *actual_vref_mv)
{
const uint32_t sample_count = 16U;
uint32_t sum = 0U;
ADC_ChannelConfTypeDef channel = {0};
if (hadc == NULL || hadc->Instance != ADC3 ||
hadc->Init.Resolution != ADC_RESOLUTION_16B ||
actual_vref_mv == NULL || min_vref_mv == 0U ||
min_vref_mv > max_vref_mv) {
return false;
}
/* Select only an ADC channel/instance supporting internal VREFINT.
* On STM32H743, consult ADC3's channel mapping.
*/
channel.Channel = ADC_CHANNEL_VREFINT;
channel.Rank = ADC_REGULAR_RANK_1;
channel.SamplingTime = ADC_SAMPLETIME_810CYCLES_5;
channel.SingleDiff = ADC_SINGLE_ENDED;
channel.OffsetNumber = ADC_OFFSET_NONE;
if (HAL_ADC_ConfigChannel(hadc, &channel) != HAL_OK) {
return false;
}
for (uint32_t i = 0U; i < sample_count; ++i) {
if (HAL_ADC_Start(hadc) != HAL_OK) return false;
if (HAL_ADC_PollForConversion(hadc, 20U) != HAL_OK) {
(void)HAL_ADC_Stop(hadc);
return false;
}
sum += HAL_ADC_GetValue(hadc);
if (HAL_ADC_Stop(hadc) != HAL_OK) return false;
}
const uint32_t mean = sum / sample_count;
const uint32_t factory = (uint32_t)(*VREFINT_CAL_ADDR);
if (mean == 0U || factory == 0U || factory == 0xFFFFU) {
return false;
}
/* Apply correct factory data resolution/conversion for this ADC.
* This formula assumes factory and sample values use matching 16-bit
* scaling; verify VREFINT_CAL and ADC configuration in the datasheet.
*/
*actual_vref_mv = (factory * VREFINT_CAL_VREF) / mean;
return (*actual_vref_mv >= min_vref_mv &&
*actual_vref_mv <= max_vref_mv);
}

Set min/max voltage limits from the board specification and measurement uncertainty, not from a universal +/-3% guess. Before using this in production, ensure the VREFINT internal path is enabled, the ADC instance supports it, and the 16-bit data resolution and factory factor scale match. On devices whose factory VREFINT value was measured at 12-bit precision, rescale as prescribed by the LL helper (for example __LL_ADC_CALC_VREFANALOG_VOLTAGE) instead of the raw formula above. Consider testing an external known input at two or more levels for offset, gain and gross nonlinearity checks.

Production Debug Flowchart

Use an ordered diagnostic sequence rather than immediately raising the calibration timeout or swapping capacitors:

+--------------------------------------------------------------------------+
| STM32H7 ADC CALIBRATION FAILURE - DEBUG DECISION FLOW |
| |
| [HAL_ADCEx_Calibration_Start() fails or stays in loop] |
| | |
| v |
| Capture HAL return, ADC_CR / ADC_ISR and CPU/ADC clocks |
| | |
| v |
| Is the ADC disabled, regulated and clocked correctly? |
| NO -> Fix clock, DEEPPWD/ADVREGEN or startup sequence |
| YES |
| | |
| v |
| Inspect the exact HAL source and polling budget |
| | |
| +--> Loop-count limit too short for real ADC timing? |
| | YES -> Update HAL or review elapsed-time patch |
| | |
| +--> ADCAL never clears under a sufficient timeout? |
| YES -> Check silicon rev, BOOST, CKMODE, ADC power |
| and dual-mode ordering; scope VDDA/VREF+ |
| |
| After calibration succeeds: verify VREFINT and known inputs. |
| Keep watchdog recovery and fault logs in production. |
+--------------------------------------------------------------------------+

Log failing state before resetting the peripheral. Compare the result under a known-good clock tree and power supply, then change one configuration variable at a time. Never treat an elapsed-time timeout as proof of a bad analog reference or as evidence that the calibration coefficients are necessarily zero.

Summary

STM32H7 ADC calibration errors require distinguishing the ADC hardware sequence from the HAL polling implementation. The central corrections are:

  1. Timeout units matter: ADC_CALIBRATION_TIMEOUT in affected HAL code is a loop-iteration limit, not a millisecond duration or precise CPU-cycle timer. Neither 64,000 nor 633,600,000 loops has a universal elapsed time.
  2. Clock and silicon revisions matter: verify ADCSEL, CKMODE, PRESC, and the Rev Y/Rev V analog /2 and BOOST behavior. On Rev V, BOOST bit pattern 11 is valid for the highest specified analog-clock range.
  3. Power-up sequencing matters: enable and stabilize the ADC regulator, and start calibration only with ADC disabled. Use the configured HAL sequence and device-specific stabilization time.
  4. Linearity and offset are different: ST describes factory-programmed linearity codes that can be loaded by supported HAL code. Offset calibration remains important after power-up and after material analog operating-condition changes.
  5. Test results, not just status: an ADCAL clear or a nonzero CALFACT value does not establish conversion accuracy. Validate reference and known-channel measurements with target-specific limits.
  6. Keep recovery bounded: a source-reviewed elapsed-time guard, configured watchdog and useful register snapshots are safer than an unexplained increase in a loop counter.

A robust implementation uses the correct HAL and silicon documentation, checks every initialization/calibration return status, and avoids rewriting the ADC state machine with ad-hoc register operations. The samples here are engineering patterns: validate their exact APIs, factory data scaling and clock assumptions on the target STM32H7 before release.


References

  1. STMicroelectronics, AN5354: Getting started with the STM32H7 Series MCU 16-bit ADC, Application Note, Rev 3, 2023. https://www.st.com/resource/en/application_note/an5354-getting-started-with-the-stm32h7-series-mcu-16bit-adc-stmicroelectronics.pdf
  2. STMicroelectronics, RM0433: STM32H742, STM32H743/753 and STM32H750 Value line advanced Arm-based 32-bit MCUs Reference Manual, Rev 8, 2023. https://www.st.com/resource/en/reference_manual/rm0433-stm32h742-stm32h743753-and-stm32h750-value-line-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
  3. STMicroelectronics, AN5312: Migration from RevY to RevV for STM32H743/753 and STM32H750 Value line microcontrollers, Application Note, Rev 2, 2020. https://www.st.com/resource/en/application_note/an5312-migration-from-revy-to-revv-for-stm32h743753-and-stm32h750-value-line-microcontrollers-stmicroelectronics.pdf
  4. STMicroelectronics, ES0392: STM32H742xI/G, STM32H743xI/G, STM32H750xB, and STM32H753xI Device Errata, Errata Sheet, Rev 16, 2023. https://www.st.com/resource/en/errata_sheet/es0392-stm32h742xig-stm32h743xig-stm32h750xb-stm32h753xi-device-errata-stmicroelectronics.pdf
  5. STMicroelectronics, DS12110: STM32H743xI/G Data Sheet - 32-bit Arm Cortex-M7 480MHz MCUs, Datasheet, Rev 8, 2021. https://www.st.com/resource/en/datasheet/stm32h743vi.pdf
  6. ARM Limited, Cortex-M7 Processor Technical Reference Manual, Rev r1p2, ARM DDI 0489F, 2020. https://developer.arm.com/documentation/ddi0489/f/

Frequently Asked Questions

Why does STM32H7 ADC calibration fail with HAL_ERROR or timeout?

A calibration timeout can come from an insufficient software polling budget in a particular STM32CubeH7 HAL version, an ADC clock or regulator configuration problem, a wrong calibration sequence, or a hardware power/reference issue. The HAL polling count is not a calibrated time interval: the actual elapsed time depends on CPU clock, compiler output and bus latency. Inspect the exact HAL driver source, ADC_CR.ADCAL, clock tree and return status before diagnosing the board.

What is the difference between ADC_CALIB_OFFSET and ADC_CALIB_OFFSET_LINEARITY on STM32H7?

ADC_CALIB_OFFSET performs offset calibration for the selected single-ended or differential path; ADC_CALIB_OFFSET_LINEARITY also requests linearity calibration on ADC variants that support it. ST documents factory-programmed linearity coefficients and a HAL function to load them on supported STM32H7 devices, so full runtime linearity calibration is not universally required at every boot. Offset calibration is required after power-up and may need repeating after relevant VREF+, VDDA or temperature changes.

How do I fix the STM32H7 HAL ADC calibration timeout bug?

First identify the exact STM32H7 device, silicon revision and installed STM32CubeH7 HAL implementation. Check clocks, ADC disable state and analog-regulator startup; then use a maintained HAL release. For a verified polling-budget defect, patch the driver to use a functioning elapsed-time source and preserve the HAL lock/state/error handling. Never assume that changing a loop-count macro sets an exact time limit, and do not replace the HAL sequence with an unvalidated register write routine.

Can I skip ADC calibration on STM32H7 if boot time is critical?

Do not skip required offset calibration. Some STM32H7 devices provide factory-programmed linearity calibration factors that can be reloaded through HAL_ADCEx_LinearCalibration_FactorLoad() in a compatible driver; otherwise follow the applicable reference manual's calibration procedure. A custom persistence strategy needs validation for the exact device, power/reset domain and HAL version. No universal 50-60 mV offset error or missing-code figure applies to uncalibrated devices.

Why does ADC calibration fail in Dual Mode on STM32H7?

For dual ADC operation, initialize and calibrate each ADC while it is disabled, then configure multimode and start conversions in the order documented for the device and HAL. If ADC2 hangs, inspect ADEN, ADCAL, shared CCR.DUAL state, clock selection and HAL status; configuring multimode beforehand is a diagnostic possibility, not proof that multimode always locks calibration.

Tags

stm32h7adccalibrationtimeouthalhardware-debug

Share


Previous Article
Fix FreeRTOS ISR Queue Not Waking: xHigherPriorityTaskWoken
Jithin Tom

Jithin Tom

A Closer Look at C/C++, RTOS, and Embedded Systems

Related Posts

Fixing UART DMA Overrun Errors on STM32
Fixing UART DMA Overrun Errors on STM32
August 21, 2026
5 min
© 2026, All Rights Reserved.
Powered By Netlyft

Quick Links

Advertise with usAbout UsContact Us

Social Media