AnsweredAssumed Answered

Hello,  I had developed one application using STVD

Question asked by KACHHIA.SIDDHARTH on Mar 25, 2017
Latest reply on Mar 27, 2017 by KACHHIA.SIDDHARTH

#include "Filter.h"
#define Samples 3
#include <math.h>
#include <stdlib.h>

 

extern unsigned long int data;
long int Result_Previous,Average,;
unsigned char Stable;

 

void FIR_Filter(unsigned long int Clean)
{
    static unsigned char Index=0;
//    static bit_16 Index1=4000;
    static unsigned long int ADC_Mean[Samples];
    
    unsigned long int Absolute;
    unsigned char Count;
//    Average = Clean>>5;
    Clean >>= 5;
    ADC_Mean[Index] = Clean;
    Average = 0;


    {    
        for(Count=0;Count<Samples;Count++)
        {
            Average+=ADC_Mean[Count];
             }
        Average /= Samples;
    }

 

    if(Index >= (Samples-1))
        Index=0;
    else
        Index++;
    Absolute = abs(Average - Result_Previous);
    
   if(Absolute <5)
    {
        Average = Result_Previous +((Average - Result_Previous)>>2);
    }
    if(Absolute<3)
        Stable++;
    else
        Stable=0; 
    
    Result_Previous = Average;
//    return (Average);
        data = Average;
}

 

this is my code in interrupt function.. i think problem with this statement addition in variable not working in interrupt function  " Average+=ADC_Mean[Count];"

how can addition in that variable??

Help me for this.. Thank you..

Outcomes