I have an application which requires reception of bursts of SPI data (>750 transmissions of 16-bits each) at 20 Mbps. The AM335x McSPI peripheral is in slave mode. The issue I'm finding is that at any data rate above approximately 1 Mbps, an RX overflow flag is being triggered, and I'm losing data accordingly thereafter. I'm using the SPI peripheral in receive-only mode and the FIFO receive buffer is enabled with a "full" trigger level of 16 bytes.
I have been leveraging the McSPI drivers from the TI RTOS SDK for the AM335x. I've tried both interrupt and polling mode. So far, I have not tested this setup with DMA transfers, but that is likely an option for improved performance. Nonetheless, it seems likely that I'm doing something wrong to see failures at such low data-rates. Are there requirements or options to improve the performance of the McSPI or FIFO data movement speeds?
Here's some example code I'm using for receiving the data:
bool receiveSpiData(void){
bool ret_val;
MCSPI_Handle hwHandle = NULL;
appPrint("\n Receiving SPI Data...");
MCSPI_Params spiParams; /* SPI params structure */
MCSPI_Params_init(&spiParams);
spiParams.frameFormat = SPI_POL0_PHA1;
spiParams.mode = SPI_SLAVE;
spiParams.dataSize = 16;
hwHandle = MCSPI_open(BOARD_HVB_SPI_INSTANCE, 0, &spiParams);
uint32_t terminateXfer = 1;
transaction.txBuf = NULL;
transaction.rxBuf = dataVec;
transaction.count = (uint32_t)(NUM_FRAMES * (2 + NUM_INPUTS));
transaction.arg = (void *)&terminateXfer;
ret_val = MCSPI_transfer_v1(hwHandle, &transaction);
MCSPI_close(hwHandle);
if(ret_val == 0){
appPrint("\n SPI Transfer Failed.");
return ret_val;
}
else{
appPrint("\n Done receiving SPI data.");
}
return ret_val;
}
I'm using CCS version 9.2.0.00013 with AM335x PDK version 1.0.16.