Need Help on using FIFO Buffer

03 Jan 2012

Hello Guys, recently I am doing some project which will be using FIFO Buffer, but i have no clues on how should I use it. Can anyone give me some guidance such as like how should write it or is there a example for me to reference? Hope you guys can help me! Thanks

03 Jan 2012
03 Jan 2012

great! I hope that i will figure it out, dont really understand. Thanks for your help!

03 Jan 2012

Daryl Tan Wei Guang wrote:

great! I hope that i will figure it out, dont really understand. Thanks for your help!

It ok your not alone, maybe somebody else will help you out;)

03 Jan 2012

Hi Tan.

A FIFO is the same as a stack. As the name implies, first in and first out and it is different from a "Ring Buffer" as used is the "sterio-audio-codedc". A FIFO is typically implemented as a queue of memory chunks (queue elements) where new elements are linked to the top of the queue and elements are removed from top of the queue. Simply allocate a chunk of memory, store a pointer to the previous chunk (element) together with a data item you want to push onto your stack. Pop off from stack by removing the topmost element from queue, unlink and free it and return the data item. Note that you must lock the queue in case you must be thread save.

typedef struct element_tag { struct elementtag *next; void* item; } ELEMENT;

Hope this helps, Guenter.

04 Jan 2012

Guenter, I think a stack is LIFO. http://en.wikipedia.org/wiki/LIFO_(computing)

I would typically refer to a FIFO as a queue. The wikipedia page for FIFO actually points to a circular buffer as an example implementation: http://en.wikipedia.org/wiki/Circular_buffer

04 Jan 2012

Adam Green wrote:

Guenter, I think a stack is LIFO. http://en.wikipedia.org/wiki/LIFO_(computing)

I would typically refer to a FIFO as a queue. The wikipedia page for FIFO actually points to a circular buffer as an example implementation: http://en.wikipedia.org/wiki/Circular_buffer

Ok thanks adamn! and Guenter! I think I need to understand the concept of FIFO buffer 1st. Really appreciate all your help :)

04 Jan 2012

Daryl Tan Wei Guang wrote:

Adam Green wrote:

Guenter, I think a stack is LIFO. http://en.wikipedia.org/wiki/LIFO_(computing)

I would typically refer to a FIFO as a queue. The wikipedia page for FIFO actually points to a circular buffer as an example implementation: http://en.wikipedia.org/wiki/Circular_buffer

Ok thanks adamn! and Guenter! I think I need to understand the concept of FIFO buffer 1st. Really appreciate all your help :)

try this here

http://code.google.com/p/embeddedhobby/downloads/detail?name=FIFO21May2011.rar&can=2&q=

06 Jan 2012

hmm ok thanks! anyway i would like to ask, for example, if i want to use Keypad to enter number into the buffer so is it that I would have to put something like " buffer[row][column] = telepad.getKey(); "? If so how do i go to the next column? Hope you can help