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.

C6Flo FIR object

Other Parts Discussed in Thread: OMAP-L138

Dear TI,

I'm new to DSP programming, but have quite some experience in signal processing and in programming for microcontrollers.

I'm now working on a project which will use the C6742. For development, we therefore use the Logic OMAP-L138 EVM with the C6748 module.

I've started out with C6Flo to create a simple program which captures audio, filters one channel (and delays the other) and ouputs this audio on the line out.

I would now like to use an FIR filter with 48 taps. In the exported C code, I see the following:

 

 

ti_c6flo_c674dsplib_fir_v1_obj firc674_1_obj = {

    {&FilterAudio1Channel48Taps_obj, &thread0_obj, 1, 1},

    /* length (max 16)    = */ 4,

    /* filter taps [15:0] = */ { -0.0403375, -0.0909868, -0.153547, -0.043424,

0.494142, 1.52089, 2.7267, 3.55133,

3.55133, 2.7267, 1.52089, 0.494142,

-0.043424, -0.153547, -0.0909868, -0.0403375 },

    NULL,

    NULL

};

 

It says that the length is 4, but shouldn't that be 16?

Furthermore: Why is the maximum length 16? In the ti_c6flo_c674dsplib_fir_v1_create(), ti_c6flo_c674dsplib_fir_v1_init() and ti_c6flo_c674dsplib_fir_v1_proc() functions, I don't see why it could not be longer. Can the DSPF_sp_fir_gen() function in DSPlib for C674x devices not handle longer filters?

If I want to use a 48 tap function, is it safe to change the taps[16] element from the ti_c6flo_c674dsplib_fir_v1_obj struct to taps[48] and add the 48 filter coefficients to the taps element of all the objects? Or should I concatenate 3 FIR filters (each 16 taps) with some split and delay elements in between?

 

Best regards

 

Admar Schoonen


PS: how can you quote or paste code in this forum?


PS2: there is a small bug in the comment in the generated C code from C6Flo. In the ti_c6flo_c674dsplib_fir_v1_create() function, it says:

//   1) space to hold ny + (nh - 1) * 4 values

I guess this must be:

//   1) space to hold (ny + nh - 1) * 4 values

 

  • Admar,

    The generated code only has room for 16 filter taps, but you can certainly modify your C code to support 48 or more filter taps.  See the red text below for the required changes.

    File include/<app name>.h:

    typedef struct {
        // standard elements (DO NOT CHANGE OR MOVE)
        C6Flo_std_struct_obj std;
        // extra elements
        char length;
        float taps[48];
        float *x_buffer;
        float *h_buffer;
    } ti_c6flo_c674dsplib_fir_v1_obj, *ti_c6flo_c674dsplib_fir_v1_hdl;

    File <app name>_blocks.c:

    ti_c6flo_c674dsplib_fir_v1_obj fir_1_obj = {
        {&fir_c6747_app_obj, &thread0_obj, 1, 1},
        /* length (max 48)    = */ 48,
        /* filter taps [47:0] = */ { <h[47]>,
    <h[46]>, <h[45]>, <h[44]>,
                                     // ...
                                    
    <h[3]>, <h[2]>, <h[1]>, <h[0]>
    },
        NULL,
        NULL
    };

    // ...

    int ti_c6flo_c674dsplib_fir_v1_create(ti_c6flo_c674dsplib_fir_v1_hdl blockp)
    {
        // ...
       
        // copy filter taps to aligned buffer
        memcpy(blockp->h_buffer, blockp->taps + (48 - nh), nh * 4);
       
        return C6Flo_EOK;
    }

    The init and proc functions should be able to handle length-48 filters with no changes.  The "length" parameter is set by the C6Flo GUI, and it defaults to 4.  This lets you apply filter sizes lower than the maximum allowed size (normally 16) without wasting cycles.  If you change the length parameter to 16 in the GUI, then you should see that value reflected when you generate code.

    Also, one thing to note: if you modify your code, be careful not to re-generate it from C6Flo without backing up your work.  You can overwrite and lose any changes you made by hand if you're not careful.

    I don't think that the forum has a dedicated code tag or format scheme, unfortunately.  I normally just copy-paste code and apply font/indent changes to make it look distinct from prose.

  • Hi Joe,

    Thanks a lot! This was exactly what I needed to know.

    I tried playing with different filter lengths before, but somehow always overlooked the fact that I needed to change the value of 16 in ti_c6flo_c674dsplib_fir_v1_create() as well. Gives some strange results!

    I now have a working setup where I can switch between different FIR filters of length 48 at runtime. Will use that to develop the application further.

    Best regards

    Admar