Hello Sirs,
We have requirement for fast SPI transfer speed, we want to transfer 128 bytes of data in full duplex as fast as we can
the code below shows how we write and read SPI buffer with 32bit dataSize(4 byte), so there will be 32 sets of 4 bytes to be transfer (total 128 bytes)
the code works well but we found that waiting for McSPIChannelStatusGet() and McSPIReceiveData() will cause delay for approximate 2us
mcspi_chstat_txs_mask = MCSPI_CH0STAT_TXS_MASK; mcspi_chstat_rxs_mask = MCSPI_CH0STAT_RXS_MASK; for(i = 0; i < len; i++) { loop = 1000; /* Wait for transmit empty */ while(((McSPIChannelStatusGet(pCfgMcspi->instAddr, pCfgMcspi->channelNum) & mcspi_chstat_txs_mask) == 0) && (loop--)); /* check if TX buffer is empty */ if(loop == -1) { return; } TmpBuff[1] = tbuff[TxIdx]; TmpBuff[0] = tbuff[TxIdx+1]; TxIdx+=2; /* Program the data to be transmitted. */ McSPITransmitData(pCfgMcspi->instAddr, *(uint32_t*)TmpBuff, pCfgMcspi->channelNum); loop = 1000; /* check if RX buffer */ //GPIO_write(GPIO_TIMING_MEASURE, 1); while(((McSPIChannelStatusGet(pCfgMcspi->instAddr, pCfgMcspi->channelNum) & mcspi_chstat_rxs_mask) == 0) && (loop--)); /* check if RX buffer is full */ if(loop == -1) { return; } //GPIO_write(GPIO_TIMING_MEASURE, 0); *(uint32_t*)TmpBuff = McSPIReceiveData(pCfgMcspi->instAddr, pCfgMcspi->channelNum);//HW_RD_REG32(); //GPIO_write(GPIO_TIMING_MEASURE, 0); /**/ rbuff[RxIdx] = TmpBuff[1]; rbuff[RxIdx+1] = TmpBuff[0]; RxIdx+=2; }
This will cause a "hole" between the transmission, for 32 sets it will cause ~60us overhead, this is too much for us
Are there any solution to reduce the process time, so the "hole" can get shorter? So that we don't wasted that much time?
*This pic shows McSPIChannelStatusGet() + McSPIReceiveData() took about 1.3us to proceed
Thank you