# ADS7822 wrong output values (SPI)

I am facing some issues with the output values from an ADS7822.

The ADC is adequately bypassed and wired up, as follows. Please note that the inverted pins on the schematic are not an issue. I routed the proper wires between the ADC and the MCU.

The ADC is driven by a Teensy 3.6. It should be noted that I am using level shifters at the digital pins. The SPI speed is set at 100 KHz (with SPI mode 0) and has been tested at up to 1MHz, where the signal integrity is still good (due to the speed limitations from the level shifters).

The decoded SPI output is the following:

This output value is wrong since the voltage I am feeding to the ADC's input is a fixed 3.3V which should correspond to 0xA8E. The decoded value shown in the image matches perfectly with the Serial.print debugging outputs from my implemented code. The SPI capture portion of my code is the following. Please ignore the dumb comments and extra lines :P. I successfully tested both techniques for forming the 12-bit word through bit shifting.

To me, the timings are in line with those specified by the datasheet:

I have tried with different input voltages and the decoded output voltage is always the digital equivalent between 4.1v and 4.6V (0xCFF is approx. 4.061V).

Any ideas on what I am missing or doing wrong?

I can elaborate on my explanation if need be.

EDIT: The Vref pin is connected to an LM4040-5 precision voltage reference, thus 5.0V is the voltage reference.

[EDIT 2] I want to clarify that the LM4040-5 is fed by an additional 15V rail that I forgot to edit in the schematic shown here.

• a) what is the reference voltage? b) you are aware that there are 3 bits to be discarded at the beginning? Mar 14 at 17:33
• My apologies for the late reply. I rushed my question and did not specify this important parameter. Vref is 5V coming from a precision voltage reference LM4040-5. I will edit my post and include this Mar 14 at 21:43
• Also, why 3 bits? Both the datasheet and my SPI result show only one null bit (when the pin is in Hi-Z). I configured the DSO as a 12-bit word and, as I mentioned, it matches with the word created by my code after bit shifting and merging the 2 bytes into a uint16_t. In any case, it should be ignoring 3 rising/falling edges, isn't it? Mar 14 at 22:02

The data sheet says pin 1 is a reference input, yet you have marked it as Vref_out, and it isn't shown as being connected to anything apart from a capacitor and a test point.

 Your additional diagram shows the reference voltage coming from a 5 volt shunt regulator, fed from a 5 volt supply, via a 250K resistor. If this is actually correct, the series resistance is remarkably high, and the shunt regulator is doing nothing useful since its voltage is the same as the supply, but it might be dragging the Vref_out down a bit, since the supply current will be below the recommended minimum for regulation (65 uA)

Also the ADS7822 datasheet says the maximum reference current is 40 uA, so you'll be heavily reliant on the 10 uF capacitor to hold the reference voltage up during conversion. Try dropping the resistance by a factor of 100, and maybe use a shunt regulator with a lower voltage, so it has something to regulate.

You say you have checked the reference voltage, did you do this with a DVM (which will show you an average value) or an oscilloscope (which could be triggered to show the actual value during conversion)?

• Vref_out was in a section of my circuit that I forgot to include. I have edited my post. This voltage exists at pin 1 from the ADC. Absolutely confirmed that this voltage is present. Mar 14 at 21:46
• Thank you for your additional response. I measured it using a DVM (Fluke 289). I will measure it with mi DSO, though. Regarding the resistor from the LM4040-5 I did some final adjustments to my design and R1 is actually 20k as I also noticed that it was way too high on my original one. I will play around with it or inject an external voltage and see if there is any change. Cheers Mar 15 at 15:03
• Also, I added clarification regarding the supply voltage from the LM4040-5. It is fed by an additional 15V supply present in my design (not shown here). My apologies for the frequent corrections and incomplete/inaccurate info Mar 15 at 16:42
• "dragging the Vref_out down a bit" - there's a graph in the datasheet. It drops rapidly to something like ~1V. Mar 15 at 17:21

Your conversion of the value received on SPI is wrong.

This ADC needs the first two clock cycles to sample, then outputs a '0' bit and only then starts to transmit data. You record 0xCFF7, or 0b1100_1111_1111_0111 So, we have to skip three bits: The first (left-most) are during the sampling time, then a '0' marking the beginning of the transfer afterwards. I.e. the measured value is 0b0111_1111_1011 or 0x7FB.

That's still not the value you're searching for, but this is impossible to judge unless we can see the full and actual circuit and setup.

• Your comment was certainly helpful. It made me think for a bit, take a step back and visualise my results bit by bit (pardon the pun XD). I will be sharing my results shortly. I think I got what I was looking for Mar 16 at 14:40

Alright, guys. I found the solution.

Basically, all of you gave me very useful hints on how to troubleshoot my problem.

As I told @asdfex, after evaluating the SPI data bit by bit, I realised that my ADC digital code was embedded into the serial stream captured by the MCU (and the DSO, of course).

If we take a closer look at the data, we have the following disection. Please keep in mind that we are injecting 3.36V or 0xAC0 (for those who speak 12-bit hexadecimal, We have to be inclusive here ;) ).

Since we need to form a 12-bit word, where the MSB is transmitted right after the null bit (NB). The datasheet indicates a maximum of 2 clock cycles for the conversion time, before the NB. Then, we should count 12 bits however, we have 13. Therefore, the last bit (zero) should indicate that the conversion had already finished while CS was still low. The datasheet clearly stipulates this (see the first timings diagram that I shared).

Therefore, we must mask the upper 3 bits and do a shift right to get the final value.

Based on the results from the image, we have:

(0xD57A) & (0x1FFF) = 0x157A

then by shifting one position to the right we get:

0x157A >> 1 = 0xABD, obtaining our 12-bit word, which numerically corresponds to:

0xABD (HEX) = 2749/4095 (DEC) = (671.306E-3)(5V) = 3.356V. Et voila! Pretty close to the expected value. *Please read EDIT 2

Please also note that the serial decode is counting the absolute maximum of 16 clocks, which is in line with the datasheet.

I have confirmed this solution with different voltages and the next step is to feed an analog signal and start digitising some stuff.

[EDIT] I forgot to mention that the final serial values were captured after moving the input voltage to 2.5V

[EDIT 2] Thanks to @G36 who pointed out my mistake. The conversion value should be done over 4096 (2^12). Therefore, the actual measured voltage was: 3.355V.

• 0xABD (HEX) = 2749/ 4096 (DEC) is the correct conversion ratio. See the Table 2. page 13 in ADC datasheet.
– G36
Mar 17 at 16:02
• @G36 Of course! My bad. Thanks. I was off by a little bit. Ok, I will stop the puns Mar 17 at 16:13