cancel
Showing results for 
Search instead for 
Did you mean: 

(BTC) Two's complement of ADC input

sanjib
Associate III
Posted on January 29, 2014 at 10:24

Is it possible to get the 2's compliment of ADC input in STM32F407vg. If It is possible how it can be achieved

2 REPLIES 2
chen
Associate II
Posted on January 29, 2014 at 12:21

Hi

''Is it possible to get the 2's compliment of ADC input in STM32F407vg.''

Not sure what you are trying to ask here.

Are you asking if the ADC can read negative voltages (and therefore return a negative number and what format will the number be in)?

Posted on January 29, 2014 at 16:52

Your expressed goal is not clear, please try again or diagram

The ADC cannot measure negative voltages, and can't do anything with the data sample other than change the alignment. ie if the 12-bits fill the top or bottom half of a 16-bit word for example.

The measurement from the ADC in 12-bit mode will fall in the 0x000 - 0xFFF (4095) range for an input in the 0 - 3V (VREF) range.

If you need to add a DC bias to an AC signal to put it in the center of this range (1.5V) then you'll need to subtract 0x800 from the signed variable holding the measurement to get a 2's complement value to work with while processing the signal.

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