0
\$\begingroup\$

I am trying to understand the operation of a Serial Bus protocol converter chip. It connects with the serial bus on one side and on the other side it provides its data on the MCU host interface.

Inside the chip it holds the data in its RAM buffers. There are 4 types of configurable RAM buffers in it. Their brief description is as shown in the following image.

Four methods of RAM Buffers

My understanding of a buffer is like its a data array with start, end, and current pointers. I have read details of the above four data buffer methods many times but so far I could not understand them at the fundamental level of operation.

The fundamental question that I want to understand is that how would I know which method out of these four I should use in a certain scenario? Are their different data scenarios for which one buffer method is more suitable than the other? What can be those data scenarios on the bus?

So far I could think of like periodic data, random or interrupt based data, short data chunks after long intervals, or long data chunks repeating back to back etc.

Can someone clarify when to use these four data buffer methods?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Ping-pong is minimizes chances of missing. It also keeps messages in continuous sequence and isolates reads and writes from each other so processing is safe and easy. But it wastes memory if messages don't fit in the remaining space in one half of the buffer. Max message size that the buffer can handle is limited to half your total buffer memory, even if the buffer is empty.

Circular buffers both minimize wasted memory and chances of missing an incoming message since it can free up memory from old data on the fly after it is processed. It can stack messages the tightest and hold the longest messages for the buffer memory available and free up room the earliest after something is processed, but the most difficult to code for and has the most overhead.

Single buffer is just as memory efficient as circular buffer and can hold messages just as long as circular. Unlike circular, it is simple but you might miss messages if you are slow draining the buffer since it cannot free up memory from old data on the fly.

\$\endgroup\$
7
  • \$\begingroup\$ Can you tell what do you mean by '..has the most overhead.' in Circular buffers case? \$\endgroup\$
    – homecloud
    Commented May 9, 2020 at 2:36
  • \$\begingroup\$ @homecloud Managing the where you are writing to, reading from, preventing them from stepping on each other, whether each pointer needs to wrap around, and calculating whether the buffer is full or empty. \$\endgroup\$
    – DKNguyen
    Commented May 9, 2020 at 2:38
  • \$\begingroup\$ How does Ping-pong isolates reads and writes? Are these two buffers? My understanding was that read and write is separate in all 4 cases. \$\endgroup\$
    – homecloud
    Commented May 9, 2020 at 2:42
  • \$\begingroup\$ One buffer half is written to while the other half is read from. Both do not occur in the same buffer at the same time. Ever try writing to the same book someone is reading from? It's annoying. It's much easier to split the book into two separated halves and alternate. Ping pong is two half-sized buffers that trade places between read and write. Hence ping-pong. \$\endgroup\$
    – DKNguyen
    Commented May 9, 2020 at 2:43
  • \$\begingroup\$ Ping-pong is just two single buffers which are half-sized where they alternate between read and write and never shall the two meet. \$\endgroup\$
    – DKNguyen
    Commented May 9, 2020 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.