ADC_SAR_Seq_1_StopConvert is causing a bad current read.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
D_Sd_3235936
Level 4
Level 4
25 sign-ins 50 questions asked 25 replies posted

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 ;

}

0 Likes
1 Solution
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

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

View solution in original post

0 Likes
1 Reply
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

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

0 Likes