Skip to main content
Associate
Jun 4, 2024 6:19 AM UTC
Question

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

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.

ADC.png

 

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.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING
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?

This topic has been closed for replies.

4 replies

MasterT
Lead II
Jun 4, 2024 1:14 PM UTC

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
Chief
Jun 4, 2024 1:51 PM UTC

I do not see the calibration step!

Jun 27, 2024 11:49 PM UTC

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

waclawek.jan
Super User
Jun 28, 2024 5:00 AM UTC

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

JW