I am trying to configure ADC1 on the STM32F303RE Nucleo board and I have not been able to find any good documentation on how differential mode works. I used CubeMX to setup the HAL with ADC1 Channel 8 configured for differential mode. It seems from experiment that the ADC Offset Number must be set to enable signed output, and by setting the offset to 2048 I do get differential behavior between the inputs.

  sConfig.Channel = ADC_CHANNEL_8;
  sConfig.Rank = ADC_REGULAR_RANK_1;
  sConfig.SingleDiff = ADC_DIFFERENTIAL_ENDED;
  sConfig.SamplingTime = ADC_SAMPLETIME_4CYCLES_5;
  sConfig.OffsetNumber = ADC_OFFSET_1;
  sConfig.Offset = 2048;

However, when I test with ADC1_IN8M = 1.5V and swing ADC1_IN8P from 0 to 3.3V (Vref = 3.3V on the Nucleo), the data only runs from -1024 to +1024 and reads zero at 1.5V. Why am I only getting 11bit dynamic range in differential mode? When I switch to single ended it runs from 0 to 4095 as expected.

It is also not clear whether 0V falls within the common mode range for differential mode. The STM documentation says VSSA to Vref is the conversion range, but I get weird conversion results when one of the inputs gets close to zero volts.

Edit: From the STM32F3x reference manual:

When reading data from ADCx_DR (regular channel) or from ADCx_JDRy (injected channel, y=1,2,3,4) corresponding to the channel “i”:

  • If one of the offsets is enabled (bit OFFSETy_EN=1) for the corresponding channel, the read data is signed.
  • If none of the four offsets is enabled for this channel, the read data is not signed.

What does this mean? Why are there four offsets for each channel and what do they do?


2 Answers 2


Range is VREF in single and 2 * VREF in differential mode. If you use differential mode as pseudo-differential ( one input at a fixed voltage), you lose one bit.

from - https://community.st.com/s/question/0D53W00000OU6Xb/stm32l476rg-differential-adc-functioning-as-singledended

  • \$\begingroup\$ Why would this be? I've seen nothing to indicate this in the STM documentation and the link you provided is discussing the ADC on Microchip devices. \$\endgroup\$
    – Mike
    Jun 22, 2021 at 4:30

Just think about the maximum range that you can provide to differential inputs.

  1. The maximum value is when \begin{equation} V_{IN+} = V_{ref+}\\ V_{IN-} = V_{ref-} \end{equation}
  2. The minimum value is when \begin{equation} V_{IN+} = V_{ref-}\\ V_{IN-} = V_{ref+} \end{equation}

So if this range has 12 bits then in your case you are able to use only 11 bits, because you set \begin{equation} V_{IN-} = \frac {V_{ref+} + V_{ref-}}{2} \end{equation} and it never goes to extreme values.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.