Ring buffers are the go to choice by most veteran embedded programmers for asynchronous communications. Assume that data arrives over UART from only a single source and only when a msg is asked for(Master->Slave,Slave->Master), since codes are sequential in nature, we can just implement an ordinary array(max size of data received) to hold the received data. Like so:
#define MAX_SIZE 8
U8 RxBuff[MAX_SIZE]
Once data has been processed and replied,the master and slave can reset the RxBuff.There is no need for a Ring Buffer.
But this got me thinking,do Ring Buffers offer the advantage of a longer SRAM life? I have read that memories like Flash,Ram have limited write cycles but infinite read cycles. By implementing a Ring Buffer that circles around RAM locations every time data arrives,does such an implementation, by reducing the write cycles for constant memory locations of the RxBuff everytime data is received,offer improved memory life?
Or are there other reasons why Ring Buffers are preferred?
