7 Replies Latest reply on Feb 17, 2018 6:21 AM by user_1377889

    Problems with implementing Scanning SAR ADC in PSoC6

    muhammad.yaqoob_1490236

      Dear all,

       

      I am facing a problem while implementing ADC in PSoC. The use of "uint32 ADC_IsEndConversion(uint32 retMode)" gives an error while inserting retMode i.e.,  ADC_RETRUN_STATUS or ADC_WAIT_FOR_RESULT.

       

      The only way forward is to insert "0" as retMode but still, the ADC results are wrong. I am using the following code:

       

      #include "project.h"

      #include "math.h"

      #include "stdio.h"

       

      float Is;

       

      int main(void)

      {

      Is=0;  

      __enable_irq(); /* Enable global interrupts. */

       

      ADC_Start();

       

      for(;;)

      {

      ADC_StartConvert();

      if(ADC_IsEndConversion(0))

      {

      Is=ADC_CountsTo_Volts(0, ADC_GetResult32(0));

      if (Is<1)   //A simple check for the ADC values

      Cy_GPIO_Inv(test_PORT,test_NUM);

      }

      ADC_StopConvert();

      }

       

      }