MCP3425 (ADC) problem

adc

I am having problems with this ADC. Here is the datasheet:

http://ww1.microchip.com/downloads/en/DeviceDoc/22072a.pdf

I connected it in Single-Ended Input, so I have 15-bits from 0v (0x0000) to 2.048v (0x7FFF).

According to the page 8 of the datasheet, the output code is (max code + 1)*((Vin+ – Vin-)/2.048)

So if I measure 0.994v (Vin+ – Vin-) I should get 15904 (decimal), but I get 7957 instead. This rule of the "half part" is always true.

Any idea of what I am doing wrong?

Thank you.

Best Answer

I figured it out and as pikafu suggested I'll answer the question. I was reading the ADC badly. The 16-bit code is read over i2c with this structure: [15...8] [7...0] [config byte]. I was using this code to read it:

ADC = (buff[0]<<7) + buff[1]

And obviously, as Roger Rowland helped me to notice, it's wrong. This is the correct code:

ADC = (buff[0]<<8) + buff[1]