I haven't written one for a PIC, but did it for the MC6802 years ago. It's a "circular buffer." You have an array of bytes, an input pointer (or index) and an output pointer (or index). On initialization, both are set to index 0. To put something into the buffer, store it at the location pointed to by the input pointer, then increment the index (auto-incrementing FSR is nice for this). If you ran off the end of the array, set the pointer back to the beginning of the array. The input index always points to an empty location that is to be next filled. To pull something from the buffer, read the location pointed to by the output pointer, then increment the pointer. Again, if the increment runs you off the end of the buffer, put it back at the start. To check to see if there's anything in the buffer, compare the input and output pointers. They are the same if the buffer is empty. To see if the buffer is full, read the output pointer, add 1 (and if it ran off the end of the buffer, set the result back to the start of the buffer), and compare this result with the input pointer. If they are equal, the buffer is full. Note that there is always 1 unused byte (the one right before the one pointed to by the input pointer). If this were used, you could not tell the difference between a full and empty buffer. You should check to see if the buffer is full before putting anything in it. For more fun, write a routine that tells you how much room is in the buffer so you can see if your new data will fit. For even more fun, write a dynamic buffer that goes and gets more ram when needed, and releases it when it's not needed. We did this in Turbo Pascal for a system where we needed LOTS of variable sized buffers. Harold FCC Rules Online at http://www.hallikainen.com -- "Hulatt, Jon" wrote: Hi All, Has anyone ever written some code for a FIFO buffer? Can't see anything on piclist.com I need one about 10 bytes in size. Maybe I'll have to write it myself!! Jon ________________________________________________________________ The best thing to hit the internet in years - Juno SpeedBand! Surf the web up to FIVE TIMES FASTER! Only $14.95/ month - visit www.juno.com to sign up today! -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics