ΣSigmaStudio Ask AI Русский Log in

maximal buffer length of fir_decim_fract16 function ?

Processors & DSP robertthebobbert Dec 20, 2012 00:00 6 replies Original on forum ↗
Subscribe
robertthebobbert Question
Dec 20, 2012 00:00

Hello,

I try to use the fir_decid_fract16 function which is contained in the VDSP++5.0 IDE. This works fine but only up to the buffer length of 131 072. I intended a length of 2 097 152 but this seems to be ignored. The compiler manual does not say something about a maximum value for the length. As it is an int-type I assumed it will work up to the maximum value of int. The processor I use is a blackfin 526 which has only 132 k of internal RAM could this be the reason for this limitation ?

ADIApproved Reply
Dec 21, 2012 00:00

Hi,

Are you making use of SDRAM for the storage of the buffers? Otherwise you will be limited to the size of internal memory.

Are you able to provide a simple example that demonstrates the issue, so we can look at the buffer placement, SDRAM configuration, etc?

Regards,

Craig.

robertthebobbert Reply
Dec 21, 2012 00:00

Hi Craig,

yes I am using the SDRAM for the storage buffers..I attached a code fragment..(actually this is a modified part of EE-Note 350 in order to test a MEMS microphone)..if I call the fir_decim_fr16 (after initialisation of the fir_state variable) it just operates up to adress 0x1FFFF of the output buffer..I can not imagine why..Regards robert

//INCLUDES//////////////////////////////////////////////////////////////////

#include <fract.h>

#include <filter.h>

//DEFINES///////////////////////////////////////////////////////////////////

BUF_LENGTH 0x200000

COEFFS 25

//VARIABLES/////////////////////////////////////////////////////////////////

fract16 coefs1[25] = {

0, -2, 0, 28, 0, -178, 0, 730, 0,

-2401, 0, 10014, 16384, 10014, 0, -2401, 0, 730,

0, -178, 0, 28, 0, -2, 0

};

fract16 delay1[COEFFS];

fir_state_fr16 state1;

section ("sdram0") fract16 output_buffer[(BUF_LENGTH/2 + COEFFS - 1)];

section ("sdram0") fract16 input_buffer[BUF_LENGTH];

//FUNCTIONS/////////////////////////////////////////////////////////////////

fir_init(state1, coefs1, delay1, COEFFS, 2); //decimation factor 2

fir_decima_fr16(input_buffer, output_buffer, BUF_LENGTH, &state1);

ADIApproved Reply
Jan 15, 2013 00:00

Hi,

The fir_decima_fr16 function (and the fir_decima_fr32 function) uses an unsigned 16-bit divide operation to determine the size of the output buffer. The decimation filter function therefore can only handle input buffers than are no larger than 65536 elements. You can work around this restriction by calling the filter function repeated, processing 64K block at a time, as demonstrated in the following example:

#define MAX_FIR_DECIMA_BUF_LENGTH 0x00010000

#define BUF_LENGTH 0x00200000

#define DECIMATION_FACTOR 2

int input_offset;

int input_len;

<initialize the filter state>

<zero the delay line>

input_len = BUF_LENGTH;

input_offset = 0;

while (input length > MAX_FIR_DECIMA_BUF_LENGTH)

{

fir_decima_fr16 (&input_buffer[input_offset],

&output_buffer[(input_offset/DECIMATION_FACTOR),

MAX_FIR_DECIMA_BUF_LENGTH,

&state1);

input_length = input_length - MAX_FIR_DECIMA_BUF_LENGTH;

input_offset = input_offset + MAX_FIR_DECIMA_BUF_LENGTH;

}

fir_decima_fr16 (&input_buffer[input_offset],

&output_buffer[(input_offset/DECIMATION_FACTOR),

input_len,

&state1);

A modified version of the function should be included in the next update for VisualDSP++ (5.0.11) and the next update for CCES (1.0.2); the modified version will perform a 32-bit division for input buffers greater than 64K. Please find attached modified sources for the fir_decima_fr16 and fir_decima_fr32 functions.

As an aside, looking at your example, it appears that some of the values of the filter coefficients are rather small. This might impact the accuracy of the filter response computed. Using the equivalent 32-bit filter function might provide more accurate result, at the expense of a reduced throughput.

Thank you for bringing this issue to our attention.

Andreas

Updated source files (removed redundant register save/restore).

robertthebobbert Reply
Jan 30, 2013 00:00

Hi Andreas,

thank you very much for this detailed explanation. Your code-proposal which I use now works absolutely fine !

regards from Dresden Robert

Caroll Reply
Oct 1, 2013 00:00

Hi,

VisualDSP++ 5.1 has been released which fixes this issue.

This Update is available to download from: www.analog.com/visualDSP

Regards

Carol

EZAdministrator Reply
Aug 2, 2018 00:00

This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

Thank you,
EZ Admin