- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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");
}
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think we would need to look at project archive -
“File” Designer
“Archive Project”
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I replaced the PSoC, but same problem. I don't remember changing anything in the code that would create this problem...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Found the problem, it was the ptr1 and ptr2 not resetting correctly. Thanks for your help!