cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Differential Mode Reading Incorrect

James613
Associate II

Hi,

I got some problem with using ADC Differential Mode. 

When I am using ADC Single Ended Mode:

Channel 8 Reading: ~8735
Channel 9 Reading: ~10907

When I am using ADC Differential Mode:
Reading: ~7106

That's weird. ADC Differential Mode should be subtracting both reading so suppose I should get 8735-10907=-2172? Why I will get 7106? Is it the signing problem? I already use int16_t instead of uint16_t

Does anyone can help me on this?

Thank you!!!!

 

Screenshot 2024-10-21 at 14.22.14.png

Screenshot 2024-10-21 at 14.22.26.png

 

 

  

1 ACCEPTED SOLUTION

Accepted Solutions

Differential conversion results are mid-centered and half-gain to fit the full range. 

8192 + (-2172 / 2) = 7106.

See relevant sections of ADC chapter in RM.

JW

P.S. Read also relevant sections of datasheet, note the rather limited common-mode range.

View solution in original post

6 REPLIES 6

Differential conversion results are mid-centered and half-gain to fit the full range. 

8192 + (-2172 / 2) = 7106.

See relevant sections of ADC chapter in RM.

JW

P.S. Read also relevant sections of datasheet, note the rather limited common-mode range.

James613
Associate II

Hi,

Oh I see! Thank you so much!!!!

James613
Associate II

Hi,

But is there anyway to directly output signed value from ADC?

 

 

Try data alignment "right adjust"

> But is there anyway to directly output signed value from ADC?

See Offset section of Data management subchapter of ADC chapter in RM, and description of ADC_OFRy register.

JW

Hi,

Thank you so much! I did it!

ADC1->OFR1 = 0; // Clear the offset register first

ADC1->OFR1 |= (8192 << ADC_OFR1_OFFSET1_Pos); // Set the OFFSET to 8192

ADC1->OFR1 |= (1 << ADC_OFR1_SSAT_Pos); // Enable signed saturation

ADC1->OFR1 &= ~(1 << 24); // Set POSOFF to 0 (negative offset)

ADC1->OFR1 |= (8 << ADC_OFR1_OFFSET1_CH_Pos); // Apply the offset to ADC Channel 1

 

And also set left shift bit by 1 to mutiply the result by 2.