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.

Circular Buffer for FFT

Other Parts Discussed in Thread: TMS320F28069, CONTROLSUITE

Hi, 

I am trying to implement a Circular buffer in order to implement FFT. I would like to store the readings from my ADCs into circular buffers, and after reaching a certain number of samples, trigger an interrupt and perform the FFTs. 

On the forum I found the following , but not a concrete example: 

http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/109821.aspx

I went over the Technical Reference Manual section 10, but it doesn't say how to manipulate the buffer. 

Thanks. 

Marco.

  • Hi Marco!

    You can try this realisation 1070.Buf_circular.h.

    Regards,

    Igor

  • Thanks for the example Igor. 

    I was thinking more of a hardware circular buffer, I know I can implement my own, I was reading the technical reference manual, section 10 (complex math unit) to make FFTs and they mention circular buffers, but not how to use them. Then I read they reference spru430  and the addressing modes, they have a circular addressing mode, and they talk about specific registers : XAR6, XAR1 however I am not sure how to access those or if they actually work. 

    I was looking for an example that uses the DSP TMS320f28069 circular buffers to store my reading in order to later perform FFTs

    Thanks. 

    Marco

  • Marco,

    First thing I wonder is why you want a circular buffer rather than say a ping-pong buffer approach.  In other words, process ping buffer while you fill pong buffer.

    Second thing I wonder is why you don't use the FFT code in ControlSuite, either fixed or floating point on F2806x.

    Finally, if you really want a circular buffer (for whatever reason), in C it is best to make the buffer of 2^N length.  Then you can implement the circular action using a simple AND operation with a mask on a pointer to the array or the array index.

    The C28x CPU does have a circular addressing mode for the XAR6 register as you noted, but you need to code in assembly code to use this.  The C language does not have simple facilities to do circular addressing.

    Regards,

    David

  • what is the name of the example in ControlSuite? I am looking now into the ping-pong approach using the DMA. I thought that this DSP had a circular buffer that automatically increases the pointer's addres and allows me to store data automatically in the background, while I ran other stuff on the CPU, then when the buffer is full triggers an interupt and then I can do my FFTs ... 

    Thanks. 

    Marco.

  • The FFT stuff in ControlSuite are libraries.  You'll find them in this folder:

    C:\TI\controlSUITE\libs\dsp

    and then go to the sub-folder 'FixedPointLib', 'FPU', or 'VCU' depending on what device you are using (i.e., floating point devices can do floating pt. FFT in 'FPU' lib, devices wth VCU module can do fixed-pt. FFT with 'VCU' lib).

    There are examples with each library.  These are simple examples I believe, and aren't managing any buffers.  They're just showing how to call the library functions.

    Circular buffering is typically used when performing digital filters for example.  In the case of an FFT, you just want to store new data while you process the current data block.  Hence, ping-pong buffering.  This is managed manually, in software.  You setup the DMA (for example) to fill the buffers, and give you an interrupt after the ping is filled, and another interrupt after the pong is filled.

    Regards,

    David

  • I am going through the Technical Reference Manual info about the DMA Section 11. I am wondering if I can read GPIOs, I am using an external ADC with parallel output. I know that you have to read the 32bits of PORT A and then do masking in order to read the value out of the GPIOs. I know I can trigger the interrupt out of these GPIOs using the external interrupts, but can I read the GPIOs through the DMA bus? 

    Thanks. 

    Marco.

  • Marco,

    I believe you are using F2806x device?  The DMA cannot access the GPIO.  Per the device TRM, SPRUH18D, section 11.1, the DMA has access to L5-L8 SARAM, the ADC results, the McBSP TX and RX regs, and ePWM/HRPWM 1-8.

    - David

  • Sorry, but this file is taken from? 1070.Buf_circular.h