If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Hello,

I am trying to send out the ADC value to my microcontroller(hercules) on SPI. The adc needs 18 clocks to push 16 bit data out but hercules has max word length of 16 bits. So I am doing 2 successive receives so that I get 2 16 bit words out then left shifting these by 2 bits to compensate for the 2 clock cycles. But I am not getting the exact reading on miso pin. Could you also help me with the math that I should be using for converting the obtained code to Analog voltage value. (I am using ADC in single ended operation mode)

Thanks,

The result will be a signed, 2's complement 16b code.  You mentioned you are using single ended.  In this case, assuming the analog supply is set to 5V, the VREF input and negative analog input (-IN) should be set to 2.5V.

Applying 0->5V on the positive analog input (+IN) pin will then give the following codes (see Figure 47):

0V input will then give negative full scale code of 1000.0000.0000.0000b.  (-32768d)

2.5V input will give a zero scale code, 0000.0000.0000.0000b  (0d)

5V-1LSB input will give a full scale code, 0111.1111.1111.1111b (32767d)

To calculate the input voltage from the conversion CODE, the formula will then be:

Vinput = 2.5V + 2*Vref*CODE/2^16

CODE=-20000d

Vinput = 2.5V + 2*2.5V*-20000/65536 = 0.97412V

Regards,
Keith Nicholas