This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Error encountered during linking when trying to call filter function for filtering

Hi,

I am using one of the ADC channel for sampling the incoming signal and trying to filter it as described 

I got the filter coeficients using parametrs fa=3Hz,fb=8Hz,lenght=21,Fs=500Hz  in this  http://arc.id.au/FilterDesign.html .

Then added the fiter coefficients to the FIR_filter_coeff.dat file (file with new coefficients is 0564.FIR_filter_coeff.dat and generated the FIR_filter.s43 using the FIR_filter_codegen tool and then migrated this FIR_filter.s43 IAR to CCS(and it looks  this txt file but with the extension .s43 

		.cdecls C,LIST,"msp430x14x.h" ; Include device header file


		.global FIR_filter
		;RSEG	 CODE
		.text
		.ref input_delay1
		.ref input_delay2
		.ref input_delay3
		.ref input_delay4
		.ref input_delay5
		.ref input_delay6
		.ref input_delay7
		.ref input_delay8
		.ref input_delay9
		.ref input_delay10
		.ref input_delay11
		.ref input_delay12
		.ref input_delay13
		.ref input_delay14
		.ref input_delay15
		.ref input_delay16
		.ref input_delay17
		.ref input_delay18
		.ref input_delay19
		.ref input_delay20
		.ref input_delay0,output
FIR_filter:

			;Stage 0

			mov.w &input_delay0,R12
			mov.w R12,R13
			rra.w R13
			rra.w R13
			add.w R12,R13
			rra.w R13
			rra.w R13
			rra.w R13
			rra.w R13
			rra.w R13
			rra.w R13
			rra.w R13
			rra.w R13
			rra.w R13
			rra.w R13
			rra.w R13
			mov.w R13,R14
			add.w R14,&output

			;Stage 1


			;Stage 2


			;Stage 3


			;Stage 4


			;Stage 5


			;Stage 6


			;Stage 7


			;Stage 8


			;Stage 9


			;Stage 10


			;Stage 11


			;Stage 12


			;Stage 13


			;Stage 14


			;Stage 15


			;Stage 16


			;Stage 17


			;Stage 18


			;Stage 19


			;Stage 20

			mov.w &input_delay19,&input_delay20
			mov.w &input_delay18,&input_delay19
			mov.w &input_delay17,&input_delay18
			mov.w &input_delay16,&input_delay17
			mov.w &input_delay15,&input_delay16
			mov.w &input_delay14,&input_delay15
			mov.w &input_delay13,&input_delay14
			mov.w &input_delay12,&input_delay13
			mov.w &input_delay11,&input_delay12
			mov.w &input_delay10,&input_delay11
			mov.w &input_delay9,&input_delay10
			mov.w &input_delay8,&input_delay9
			mov.w &input_delay7,&input_delay8
			mov.w &input_delay6,&input_delay7
			mov.w &input_delay5,&input_delay6
			mov.w &input_delay4,&input_delay5
			mov.w &input_delay3,&input_delay4
			mov.w &input_delay2,&input_delay3
			mov.w &input_delay1,&input_delay2
			mov.w &input_delay0,&input_delay1
			ret
			.end

   .

Later added the FIR_filter.s43(CCS) ,FIR_sine_data.dat,FIR_filter_coeff.dat to the project where the main.c is sampling the signal at sampling rate of 500Hz.

__interrupt void ADC12ISR(void)
{
if (oldest == 499)
{
oldest= 0;
}
else
{
oldest=oldest+1;
}
result=ADC12MEM0;//Store ADC12MEM0 value to result(variable)
results[oldest]=FIR_filter(result);//calling the FIR_filter function
__bic_SR_register_on_exit(CPUOFF);
}



But it is giving error like this 


Can someone explain why this error is coming as I am not sure if it is something wrong with the filter design steps.
Is it some problem with filter design steps or with the function call or something else.

  • can someone explain me a solution to the problem.

  • It looks like you have to include the FIR_filter.h (header) file into your .c source file.

  • Hello,

    I don't know from where this FIR_filter.h (header) file can be found to include it.Because when I followed the instructions as mentioned here  http://www.ti.com/mcu/docs/litabsmultiplefilelist.tsp?sectionId=96&tabId=1502&literatureNumber=slaa357&docCategoryId=1&familyId=1615 it generated the files as mentioned in my first post of this thread.

    So,can someone explain me about this FIR_filter.h file.

    Thanks.

  • can someone explain me about the FIR_filter header file.

  • I don’t have experience with the software from this site, maybe someone else or you dig yourself a little bit more into this site.

    It looks like you have to declaire FIR_filter function in your main.

    extern void FIR_filter (void);

    I’m not sure if it is possible to pass variables to the function.

    Also you need to define the integer variables input_delay…

  • Thanks Leo Bosch,

    I was able to remove the errors by following your suggestions in this 

    extern FIR_filter(int);
    int input_delay0; to int input_delay20;
    int output = 0;
    __interrupt void ADC12ISR(void)
    {
    if (oldest == 499)
    {
    oldest= 0;
    }
    else
    {
    oldest=oldest+1;
    }
    result=ADC12MEM0;//Store ADC12MEM0 value to result(variable)
    results[oldest]=result;
    input_delay0=result;
    output=FIR_filter(input_delay0);
    results[oldest]=output;
    __bic_SR_register_on_exit(CPUOFF);
    }

    But I am not getting any output data when used as above which was verified by sending the results[oldest] data to the UART and it is showing results[oldest]  data on the terminal when FIR_filter is not used .

    I have doubt with my FIR_filter.s43 fucntion itself (same as this except with the extension 7446.filter_CCS.txt ).

    can someone explain me why this is not giving any output.

    Thanks.

     

  • The FIR_filter doesn’t accept or returns parameters, just call the filter (FIR_filter();). The variable input_delay0 is input and the variable output is the output of the filter.

  • Hi,

    I am calling the FIR_filter(); function each time I get a new ADC sample(where each ADC sample is sampled at 500Hz) as shown below but I am not getting any value into output

    #pragma vector=ADC12_VECTOR
    __interrupt void ADC12ISR(void)
    {
    	if (oldest == 499)
    		{
    		  oldest= 0;
    		}
    	else
    		{
    		oldest=oldest+1;
    		}
    	result=ADC12MEM0;
    	input_delay0=result;
    	FIR_filter();
    	results[oldest]=output;	
    	__bic_SR_register_on_exit(CPUOFF);
    }
    

    can someone help me out in solvign the problem.

  • stefan 12 said:
    but I am not getting any value into output

    There's no such thing as "no value" for variable ;) What's contents of results[], input_delay0 .. input_delayN after 500 ADC and FIR_Filter calls? Maybe your ADC is not working? Or you sample wrong input? Or signal source is not working? :)

  • Hi,

    ADC is working fine and I checked this both with the terminal output and also with the CCS5.4 debug window.

    I checked these using a break point at   results[oldest]=output;

    1)Before calling FIR_filter() function the ADC sample values that are stored in results [] are showing correctly in debug window as shown in the image here 

    2)when the FIR_filter() function is called , it is showing value of 0 for input_delay0 and input_delay1 ..,for the first time run in the debug window.But when it is made to run for second time it is just running in the debug window even when there is a break point as shown here and only stopping when it is stopped manually.

    thanks.

  • I think your problem is in DC offset of your signal. FIR filtering is about AC signal processing. You can't represent AC signal using only positive values. At least not for "classic" DSP algorithms. You need to DC-shift down your ADC data so result swings around 0. If zero offset of ADC input is 1/2 of VREF, then:

    result=ADC12MEM0 - 2047;

    [edit] results[] shall be signed int either.

  • llmars,

    I think FIR filtering (especially low pass) should be able to handle DC signals. Thus a DC bias shouldn't have any problem.

    The bigger problem is the poster has no idea of what he is doing. He cut and past different parts of different working programs together and makes strange changes. I think part of his code is from what I did as an "example" in c for MSP430X. Some other part of his code is from the TI App Note that you suggested, which is in assembly for MSP430. I have no idea how the entire code looks like )and don't want to see it).

    -- OCY

**Attention** This is a public forum