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
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I think we would need to look at project archive -

   

 

   

    

   

          

   

“File”                                                           Designer

   

“Archive Project”

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Thanks for the quick reply Dana!

0 Likes
Anonymous
Not applicable

 I replaced the PSoC, but same problem. I don't remember changing anything in the code that would create this problem...

0 Likes
Anonymous
Not applicable

 I think there's something going on in the filter portion, if I comment the filter out and place the ADCINC14_iClearFlagGetData() directly in the UART_DB_PutSHexInt(ADCINC14_iClearFlagGetData()); it works without hanging.

0 Likes
Anonymous
Not applicable

 Found the problem, it was the ptr1 and ptr2 not resetting correctly. Thanks for your help!

0 Likes