Showing results for 
Search instead for 
Did you mean: 

Differential Mode SDADC Codes

Associate II
Posted on May 26, 2016 at 04:57

I need to know what the differential mode SDADC conversion code is. Is it 2's compliment such that the code:

  int16_t D = (int16_t)HAL_SDADC_GetValue(&hsdadc3);

Will return to D a signed result such that if the positive input is less than the negative input D will be a negative value and that:

  float V = D * VDDA / (1 << 16);

will result in V being the signed voltage across the inputs? (Assuming unity gain.)

I have looked for this in the documentation and I cannot find it. It would help for me to know where this is.

The processor is an STM32F373VCT.

ST Employee
Posted on May 26, 2016 at 10:17

Hi Stephen,

Referring to application note

(Getting started with STM32F37x/38x SDADC (Sigma-Delta ADC)): ''In differential mode, the SDADC converts the difference between SDADCx_AINyP and SDADCx_AINyM. The result can be either positive or negative depending on which input is at higher voltage.''

In this application note, you find some examples that may be helpful for you.

Please let us know if you have any comment or feedback.


To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Associate II
Posted on May 26, 2016 at 20:20

Thank you for the link. This is just what I was looking for.

There is something I noticed in AN4207 though. For every other 16 bit converter I am familiar with the voltage resolution is the full scale voltage divided by the number of possible output codes. This would be VDDA/65536. The highest possible value output code of 65535 would cover the input voltages between VDDA*65535/65536 and VDDA. The lowest possible value of zero would cover input voltages between 0 and up to, but not including, VDDA/65536.

The number of possible codes AN4207 seems to be based on is 65535, as this is the divisor used in the equations. Is this really correct?

I realize this is a trivial difference. But I am a stickler for detail and accuracy.

Posted on May 26, 2016 at 22:17

I realize this is a trivial difference. But I am a stickler for detail and accuracy.

ST historically has used the N-1 philosophy for the ADC transforms. ie 0xFF for 8-bit, 0xFFF for 12-bit

I'm more in the 0..N-1 has N states camp, but assume it is going to make very little difference compared to the noise, and fact it simply can't measure rail-to-rail.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..