4 Replies Latest reply on Nov 13, 2017 7:28 AM by riwhc_2027276

    Missing 4 bits from ADC output

      Hi all,


      I am having some problems with using the ADC and outputting the result over I2C using CY8CKIT-042-BLE and would very much appreciate your help please!


      I am trying to send 12-bit ADC output over I2C and have set up a 6-resistor potential divider to help me understand the different generated output compared to the actual voltage levels.

      I am using:

      Vref = VDDA/2

      Unsigned differential mode

      Vneg is externally set to VDDA/2


      When I use the alternative resolution in the ADC and set this to 8-bit I get the output that I would expect as Vpos is changed from 0 to VDDA (3.3V), that is 0x00-0xFF.


      However, when I change it back to 12-bit I get the following output:

      3.3V     0x00FF

      2.75V     0x006C

      2.2V     0x00C0

      1.65V     0x0016

      1.1V     0x0069

      0.55V     0x00C3

      0V    0x0011


      To me, it looks like the most significant 4-bits are missing.

      In my code I am using the bit-shifting code to access the two bytes:

      i2cbuf[1] = (adcVal >> 8) & 0xFF; // First byte

      i2cbuf[2] = adcVal & 0xFF; // Second byte


      As a test, if I only bit-shift 4 bits then I output a copy of bits 4-7 which makes sense.


      I am most likely making a simple mistake so I would be very grateful if someone could suggest reasons for this error and/or things for me to clarify/check to get to the bottom of this.


      Many thanks,