I'm making a simple communication between an ARM mcu and a GSM module.
The problem I'm facing is how to deal with simultaneously writing and reading to and from the FIFO buffer.
Due to scale of the program I have a big buffer array of 1000 bytes long.
At the moment an interrupt is triggered every time a byte received at UART's data register and the interrupt's routine is filling my 1KB FIFO.
My read routine calculates the available data in FIFO and copies some of the data in a second buffer for further processing.
The interrupt routine stops to put more data when no more space is left in FIFO buffer, to prevent overwriting on reading pointer in the cases my main program didn't have the time to process the data.
Now I'm trying to find the best solution to prevent overwriting on reading pointer while interrupt routine never stops to put data. Is there any solution for this or overwriting is inevitable?