Showing results for 
Search instead for 
Did you mean: 

Why can't I get a value near 2048 with ADC(12Bit)?

Associate II

I have an issue where I can't obtain values near 2048 in the 12-bit ADC sampling of stm32wb5mmg. The actual data is shown below.



hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.NbrOfConversion = 1;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIG_T2_TRGO
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc1.Init.OversamplingMode = DISABLE;
sConfig.Channel = ADC_CHANNEL_13;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_12CYCLES_5;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;

Despite trying to increase the sampling time and calibrate before starting sampling, the issue was not resolved. Could you tell me the solution?

Senior III

Can't find ADC in stm32wb5mmg. Anyway, seems like DNL error, quite common issue around MSB step in all adc's.

Usually ST's ADC specified to have +-2 LSB, so jumps from 2045 to 2049 is normal.   You can minimize error shifting DC level up or down , if dynamics not suffering. 

Uwe Bonnes
Principal III

I do not see the calibration step!

Christian N
ST Employee

This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.

This may be consequence of inadequate (too high impedance) reference voltage source on VREF+ (or VDDA, if VREF+ is internally connected to it).