I'm having an issue when reading from the SSI0 Interface using uDMA after a uDMA write (Two separate functions). The data in the uDMA pipeline always seems to be offset by a couple of bytes (due to the uDMA write). I was able to correct this issue by reading back 8 bytes when transmitting as shown in the code below. I always read back 8 bytes no matter of the uDMA tx transaction size. For instance my byte count varies from 1 to 1024.
1. How many bytes should I read back after a uDMA write to clear the buffer preparing me for a uDMA read? These are two different functions. For instance, SPI_READ, SPI_WRITE. Currently reading back 8 bytes after every write fixed my issue but I want to know why? Does it have to do with the SPI FIFO buffer size?
2. Why isn't using the SSI read non blocking command sufficient to clear the FIFO when using uDMA? Below are code snippets and do not imply any consecutive order.
/* SSI Clear buffer */ uint32_t discard; /* Clear RX buffer before initiating read */ while(SSIDataGetNonBlocking(privateData->base, &discard)); /* Configure the RX channel primary control parameters */ ROM_uDMAChannelControlSet(privateData->uDMARxChannel | UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 | UDMA_ARB_8); /* Configure the TX channel primary control parameters */ ROM_uDMAChannelControlSet(privateData->uDMATxChannel | UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE | UDMA_ARB_8); /* SPI WRITE */ /* Prime the uDMA Tx Channel */ ROM_uDMAChannelTransferSet(privateData->uDMATxChannel | UDMA_PRI_SELECT, UDMA_MODE_BASIC, txBuf, (void *)(privateData->base + SSI_O_DR), count); /* Prime the uDMA Rx Channel */ ROM_uDMAChannelTransferSet(privateData->uDMARxChannel | UDMA_PRI_SELECT, UDMA_MODE_BASIC, (void *)(privateData->base + SSI_O_DR), sharedBuf, 8); /* Enable DMA and start the SSI Transfer */ ROM_uDMAChannelEnable(privateData->uDMARxChannel); ROM_uDMAChannelEnable(privateData->uDMATxChannel);