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.

Ring / Circular Buffer example for CCS C++

Hi,

 

Is there any CCS C++ example for ring / circular buffer implementation on TMS32C55xx ?

 

Regards,

Christos

 

 

 

  • Go to the Texas Instruments documents site and download SPRU376A, TMS320VC55x DSP Programmer's Guide.

    Section 3.4.5 on page 3-35 covers exactly how to write your C code so that it uses the intrinsic assembly capabilities of the processor for circular addressing.

  • Hi Brian,

     

    Thanks for the hint.

    Sorry for ommiting this but I was refering to the hardware registers used for ring buffers of C55xx and something like the example described in

    http://focus.ti.com/lit/ug/spru371f/spru371f.pdf section 6.11

    I was wondering if we can have some ready made csl funcs on it for C++ to allocate and utilize 'hardware' ringbuffs via the specific registers.

     

    Regards,

    Christos

     

     

     

  • If you look at the assembly output of the C compiler, then you'll see that the source code on the pages that I cited will use those specific registers that you're talking about.  I have confirmed this with a specific case that I needed for my own firmware.

    Admittedly, the example is not C++, and it is not a complete class, but I think you could easily whip something up.

    However, part of the problem may be that if you add too many variables and configurable elements, as a C++ class would naturally have, then the optimization may not be possible to the same degree.  Another thing to consider is that C5000 development often involves hand-placement of buffers to take advantage of the 8K dual access static memory, so there is somewhat of a limit to how abstract you can make this.

    Why not write something up and see how it performs?  A quick benchmarking firmware should be easy to write in CCS.

  • The Programmer's Guide (SPUR376A) cited by Christos is somewhat out-of-date.  The C55x C compiler can generate hardware circular addressing when the Small Memory Model is used.  For other memory models the advice given in the Programmer's Guide still applies.

    For Small Model the rule for writing C code that will use hardware circular addressing is the following:

    In a region including a loop the compiler can recognize references to an array A indexed by a variable I as a circular buffer of size S if the following hold:

    • I is initialized with a positive constant
    • All modifications of I in the region are "modulo S" increments (always '% S') for a constant S
    • Increments of I are always by positive constants
    • Index expressions of a reference to A are of the form 'a*I+b' where a and b are positive constants.

    The example in the Programmer's Guide can be changed to use these definitions for the macros

      #define CIRC_UPDATE(var, inc, size)  (var) = ((var) + (inc)) % (size)
      #define CIRC_REF(var, size) (var)

    and, in Small Model, hardware circular addressing will be used.

  • Paul, thank you for the information.

     

  • hi,

    Can some one please help me for coding buffer circular with language c .

    The dsp is TMS320.

    i haven't study the dsp before and now i don't know what do you do for programming this buffer.

    Thanks a lot for every one.