ADCINC14 stops working

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

cross mob
Anonymous
Not applicable

 If ADCINC14_fIsDataAvailable() used to return available data consistently and code inside executes properly, but now ADCINC14_fIsDataAvailable() always returns false after less than a minute of executing the code, what could be the problem?

   

The code hasn't changed, but now I do not get any data anymore. Could the PSoC be damaged and I just need to replace it?

   

 

   

if(ADCINC14_fIsDataAvailable()){

   

ADC_Filter1[Ptr1] = ADCINC14_iClearFlagGetData();

   

/* Simple moving average filter stage 1 */

   

Filter1_Result=0;

   

for(i=0;i<FILTER1_DEPTH;i++)

   

{

   

Filter1_Result += ADC_Filter1;

   

}

   

/* Wrapping around the Filter1 pointer */

   

if(Ptr1++ == FILTER1_DEPTH)

   

{

   

Ptr1 = 0;

   

}

   

/* Providing first stage result to second stage current pointer */

   

ADC_Filter2[Ptr2] = Filter1_Result >> SHIFTER;

   

   

/* Second stage filter reset to current value of the change is more than noise threshold */

   

if (((ADC_prev_Value - ADC_Filter2[Ptr2]) > THRESHOLD) || ((ADC_Filter2[Ptr2] - ADC_prev_Value) > THRESHOLD) && (ADC_Filter2[Ptr2] !=0))

   

   

for(i=0;i<FILTER2_DEPTH;i++)

   

{

   

ADC_Filter2 = ADC_Filter2[Ptr2];

   

}

   

}

   

   

/* Simple moving average filter stage 2 */

   

Filter2_Result=0;

   

for(i=0;i<FILTER2_DEPTH;i++)

   

{

   

Filter2_Result += ADC_Filter2;

   

}

   

   

ADC_prev_Value = ADC_Filter2[Ptr2];

   

   

/* Wrapping around the Filter2 pointer */

   

if(Ptr2++ == FILTER2_DEPTH)

   

{

   

Ptr2 = 0;

   

}

   

   

/* Final shift to divide for moving average filters output shift */

   

Filter2_Result = Filter2_Result >> SHIFTER;

   

UART_DB_PutSHexInt((signed int)Filter2_Result);

   

UART_DB_PutCRLF();

   

UART_BT_CPutString("write ");

   

UART_BT_PutSHexInt((signed int)Filter2_Result);

   

UART_BT_CPutString(",");

   

UART_BT_PutCRLF();

   

}else {

   

UART_DB_CPutString("No ADC data\r\n");

   

}

0 Likes
5 Replies