Useful tip on using FIFO for large transfers
A lot of tutorials tell you to wait before reading the FIFO:
while(REG_IPC_FIFO_CR & IPC_FIFO_RECV_EMPTY); // if empty, wait..
whatever = REG_IPC_FIFO_RX; // ..then read/receive!
But when mass-transfering variables through the FIFO queue, it is also wise to check before writing/sending, if the queue isn’t full. ‘Cuz if it is, you will have to wait until there’s a spot free, or the write will fail. Note: there is a total of 16 free spots in the queue.
So to add to those lacking tutorials, check the queue before sending data!!
while(REG_IPC_FIFO_CR & IPC_FIFO_SEND_FULL); // if full, wait..
REG_IPC_FIFO_TX = whatever; // ..then write/send!
The above code is safe to do within a loop. Here’s an example:
// OMG!! More than 16!!
while(REG_IPC_FIFO_CR & IPC_FIFO_SEND_FULL);
REG_IPC_FIFO_TX = data[i];
For me, another bug solved!😉 Hehe..