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.

How to implement circular buffer using C language



C28x series implement circular buffers in hardware.

How to use this feature from C language. Are any special constructs available

for same?

Regards

  • Hi Nikhil,

    Not that I am aware of. I've always implemented them in pure C. If timing is critical then writing C-callable assembly is the way to go, although you are on your own (you might get ideas by looking at TI FFT library). But I would first make sure that any gains are big enough to justify the effort. You will have additional issues with alignment of the buffer. And if I remember correctly buffer size is quite limited also (and probably can only be power of 2). Pain in the ass to maintain if you ask me.

    Regards, Mitja

  • Mitja Nemec said:
    I've always implemented them in pure C

    Likewise.

    There is a ring buffer module in the StellarisWare package; it is just plain, standard 'C' - nothing specific to Stellaris.
    I would suggest that you take a look at that!

    Mitja Nemec said:
    If timing is critical then writing C-callable assembly is the way to go

    Assembler is not a magic bullet: you need to be a good (possibly very good) assembler programmer to be able to outsmart a modern, optimising 'C' compiler...