1 2 Previous Next 22 Replies Latest reply on Apr 11, 2016 7:34 AM by user_453804851

    Can't get SAR ADC to work on CY8Ckit-049-42xx

    user_290429181

      For some reason,  I cannot get the ADC to work on this project (attached).    I am using miniprog3 for debugging and have a varying DC signal on the input pin to an op-amp.  The op-amp output is internally wired to one input of the SAR ADC.  Program compiles ok, except I get a warning that one of my variables "result" is declared but not used.  I don't understand that-    code is below.  Anyway when debugging, with 0 V input or 5 V input the "result"   is 0x05DB  (or something like that) and changes a little from read to read, but does not reflect input voltage at all. 

         

      What stupid thing am I doing wrong?

         

       

         

      #include <project.h>

         

      int main()
      {
          int16 result;
          
               ADC1_Start();    
           
          for(;;)
          {
           
              ADC1_StartConvert();
              ADC1_IsEndConversion(ADC1_WAIT_FOR_RESULT);
              result = ADC1_GetResult16(0);
              ADC1_StopConvert();
                   
          }
      }

        1 2 Previous Next