1 Reply Latest reply on Jan 6, 2019 10:35 PM by VasanthR_91

    ADC_SAR_Seq_1_StopConvert is causing a bad current read.

    D.Sd_3235936

      For power consumption i added the ADC_SAR_Seq_1_StopConvert after i am done reading the current.

       

      Unfortunately i have discovered that this function is causing a major issue in the device i am working on.

       

      On first run when no current is consumed i get a bunch of correct readings all zero as expected.

       

      But, after that when i do turn on a high consuming peripheral, the first reading that i get is zero as well.

       

      I tried adding delays up to 100 ms between activation of peripheral and the current read -  the first reading remains always zero.

       

      The other way around produces same issue, when i take a bunch of high current samples, than turn off peripheral, the first sample produced is of a very high value.

       

      The only thing that solved the issue is masking  ADC_SAR_Seq_1_StopConvert at the end of conversion function.

       

      my function:

       

      uint16_t MOTOR_GetCurrent(void)

      {

       

          uint16_t motor_current;

          int16 result; // this is what the Cypress function returns, and not uint16_t

          // Start A/D conversion

          ADC_SAR_Seq_1_StartConvert();   // D.S. this does appear in Cypress Example (but only once!,on boot, before the main loop function, in our code there are multiple uses.)

         

          ADC_SAR_Seq_1_IsEndConversion(ADC_SAR_Seq_1_WAIT_FOR_RESULT); // D.S. 29.11.2018 was recommneded by Cypress to add this function.

             

          // Read result from channel 0

          result = ADC_SAR_Seq_1_GetResult16(CHANNEL_0);

         

          int16 cypress_result = ADC_SAR_Seq_1_CountsTo_mVolts(CHANNEL_0, result);

         

          ADC_SAR_Seq_1_StopConvert(); 

       

          return (uint16_t)cypress_result ;

      }

        • 1. Re: ADC_SAR_Seq_1_StopConvert is causing a bad current read.
          VasanthR_91

          Hi,

           

          From your requirement, it means that you need conversions to be done at specific instants of time. Are you using the ADC in free-running mode? In that case you can change it into hardware trigger mode. Now you can call ADC_StartConvert() API each time when you want to start a conversion. In continuous trigger mode the API starts the continuous conversion which makes it necessary to stop the conversion using the StopConvert() API. But in hardware trigger mode each StartConvert() call will act as a single trigger to the ADC to initiate a single conversion, so calling the StopConvert API will not be necessary.

           

          Best Regards,
          VRS