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.

CCS/TMS320C6713B: Problems using fft function from DSPLIB

Part Number: TMS320C6713B


Tool/software: Code Composer Studio

Hi,
I have some problems using DSPF_sp_cfftr2_dit function from DSPLIB (dsp67x.lib) in CCS v5.3 (DSK6713). If the following line is included in the code:

DSPF_sp_cfftr2_dit(fft_in, coeffs, wlen);

I am always getting the noise signal from the codec output (even if the fft result is not directed at the headphone output - please see the code below).

I am getting no errors or warnings while building my project. My configuration is:

linker search paths:
- path to dsplib/lib/dsp67x.lib
- path to rts6700.lib

include options:
- path to dsplib/include

 

#define CHIP_6713 1

#include <stdio.h>
#include <c6x.h>
#include <csl.h>
#include <csl_mcbsp.h>
#include <csl_irq.h>
#include <math.h>

#include "dsk6713.h"
#include "dsk6713_aic23.h"

#include "DSPF_sp_cfftr2_dit.h"
#include "utility.h"


DSK6713_AIC23_CodecHandle hCodec;			    // Codec handle
DSK6713_AIC23_Config config = DSK6713_AIC23_DEFAULTCONFIG;  // Codec configuration with default settings

#define M_PI 3.14159265358979323846
#define wlen 1024
#define hop2 256
#define hop1 203

#pragma DATA_ALIGN(fft_in, 8)
#pragma DATA_ALIGN(coeffs, 8)

volatile float buffer_in[1280];
volatile Uint16 j=0;
volatile Uint8 frame_ready_flag=0;

float fft_in[2*wlen];	// Processing frame
float coeffs[wlen]={0};

interrupt void serialPortRcvISR(void);

void main()
{

	DSK6713_init();		// Initialize the board support library, must be called first
    hCodec = DSK6713_AIC23_openCodec(0, &config);	// open codec and get handle

	// Configure buffered serial ports for 32 bit operation
	// This allows transfer of both right and left channels in one read/write
	MCBSP_FSETS(SPCR1, RINTM, FRM);
	MCBSP_FSETS(SPCR1, XINTM, FRM);
	MCBSP_FSETS(RCR1, RWDLEN1, 32BIT);
	MCBSP_FSETS(XCR1, XWDLEN1, 32BIT);

	// set codec sampling frequency
	DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_44KHZ);

	// interrupt setup
	IRQ_globalDisable();			        // Globally disables interrupts
	IRQ_nmiEnable();				        // Enables the NMI interrupt
	IRQ_map(IRQ_EVT_RINT1,15);		// Maps an event to a physical interrupt
	IRQ_enable(IRQ_EVT_RINT1);		// Enables the event
	IRQ_globalEnable();				// Globally enables interrupts

	Uint8 frame_status = 0;
	Uint16 pin=0, pout=0;
	Uint16 i=0;

	tw_genr2fft(coeffs, wlen);
	bit_rev(coeffs, wlen>>1);

	// Wait until the first frame will be ready to process
	while(frame_status != 4){
		frame_status += frame_ready_flag;
		frame_ready_flag = 0;
	}

	while(1)
	{
		if (frame_ready_flag == 1){
			frame_ready_flag = 0;

			for (i=0; i<1024; i++){
				fft_in[2*i]   = buffer_in[(i+pin)%1280];
				fft_in[2*i+1] = 0;
			}
			DSPF_sp_cfftr2_dit(fft_in, coeffs, wlen);
			bit_rev(fft_in, wlen);

			pin += 256;
		}
	}
}

interrupt void serialPortRcvISR()
{
	union {Uint32 combo; short channel[2];} temp;

	temp.combo = MCBSP_read(DSK6713_AIC23_DATAHANDLE);

	buffer_in[j] = (float)temp.channel[0];
	j++;
	// Set frame_ready_flag to 1 if the next frame is ready
	if (j%256 == 0){
		frame_ready_flag = 1;
	}
	// Clear circular buffer index
	if (j == 1280){
		j = 0;
	}

	MCBSP_write(DSK6713_AIC23_DATAHANDLE, temp.combo);
}

Could you please point me what could be a reason of that?

  • Hi Ka,

    I've forwarded this to the DSPLib experts. Their feedback should be posted here.

    BR
    Tsvetolin Shulev
  • Ka,

    Why would you want to run the FFT function on a discontinuous buffer of data?

    You imply that if the DSPF_sp_cfftr2_dit() function line is commented out then the output sounds like the input and you do not hear noise. Is that correct?

    Within the noise that you hear on the output, can you hear some of the input signal coming through?

    In the DSPLIB Programmer's Reference Guide under the description of the DSPF_sp_cfftr2_dit function, the Implementation Notes section include the following note:

    Implementation Notes said:
    Interruptibility: This code is interrupt-tolerant but not interruptible.

    "not interruptible" means that while the function is running, no interrupts will occur. Since you are servicing your McBSP data on a sample-by-sample basis, your design requires an interrupt to occur once for every sample of data. If the function takes longer than two sample periods, then data will be lost. This will result in a noisy output.

    You can learn more about designing audio systems using more advanced features of the C6713, such as the EDMA, by looking at the available documentation on TI.com and at the archived TMS320C6x1x DSP Integration Workshop.

    Or, you can replace the DSPLIB call with an interruptible implementation using the supplied C-language implementation.

    Regards,
    RandyP


  • Hi Randy,
    thanks for the answer. Regarding to your question:

    You imply that if the DSPF_sp_cfftr2_dit() function line is commented out then the output sounds like the input and you do not hear noise. Is that correct?

    Yes, that is correct.

    Within the noise that you hear on the output, can you hear some of the input signal coming through?

    Yes, I can hear my input signal with some noise and clicks.

    I tried to use C implementation, but there is still the same problem. So the only way to use it is EDMA?

  • Ka,

    Ka said:
    So the only way to use it is EDMA?

    That depends: what are you trying to do? EDMA is an important part of the C6713 that can alleviate a lot of DSP processing load. Not using the EDMA can be like driving your car in the summer with the air conditioner on and all the windows down.

    The C6713 is an old processor, and we have many newer processors that are much more powerful. It is also possible that your application would be better with the C6748 or C6655. I do not know.

    Ka said:
    I tried to use C implementation, but there is still the same problem.

    Did your C implementation disable interrupts during some parts of the execution. If you can avoid blocking interrupts, then the current problem should go away.

    Please find the DSP Integration Workshop materials from below link. (Refer Lab4 - audioapp)

    processors.wiki.ti.com/.../TMS320C6x1x_DSP_Integration_Workshop

    You will benefit from the discussions of realtime processing and the labs that show how to get there.

    Regards,
    RandyP