The UART is configured using MPLABĀ® Code Configurator (MCC) as a standard 8-bit
transmission, with no parity bit and a baud rate of 115200. Communication to the Python
program was handled using the standard UART1_Write()
function generated
by MCC, which transmits the byte passed to it over UART.
While a UART is used in this application, virtually any CIP-based communication protocol could be used to feed the FIFO. The only requirement is that data is transferred a byte at a time and that the peripheral can trigger the DMA on receipt of data. For example, CAN, I2C or reading from an SD card could all replace the UART in this application, with no changes to other program functionality.
Each transmission from the Python program sends enough data to fill half of the FIFO. This means that at any time, half of the FIFO can be safely read from by the reader DMA while the other half is written to by the input DMA. For example, if 10 instruction spots are allocated for the buffer, five instructions at a time will be transmitted by the Python program.
Following the logic shown in Figure 4-2, each time new data is requested the number of remaining instructions is decremented. Once there are no remaining instructions in that half of the FIFO, the reader DMA moves on to the other section and 0xAA is sent via UART to the Python program, requesting the next instructions. As the reader DMA continues to copy from the FIFO, the Python program sends the new instructions via DMA. The input DMA then copies this new data to the old section of the FIFO buffer.