收数据超慢问题:
采用demo板+STM32F1xx 通过SPI接收数据(DRV_CANFDSPI_ReceiveMessageGet(DRV_CANFDSPI_INDEX_0, APP_RX_FIFO, &rxObj, rxd, MAX_DATA_BYTES);)发现需要200us才可以把数据(8字节)接收完毕,觉得可能是我应用的问题,大侠们是否遇到此问题?
SPI采用18Mbps ,代码如下:
int8_t DRV_SPI_TransferData(uint8_t spiSlaveDeviceIndex, uint8_t *SpiTxData, uint8_t *SpiRxData, uint16_t spiTransferSize)
{
int8_t error = 0;
bool continueLoop;
uint16_t txcounter = 0;
uint16_t rxcounter = 0;
uint8_t unitsTxed = 0;
const uint8_t maxUnits = 16;
if(CANFD_device_SPI != CPLD_CANFD_SPI_Flag()){DRV_SPI_Initialize();}
// Assert CS
//error = DRV_SPI_ChipSelectAssert(spiSlaveDeviceIndex, true);
MCP251xFD_CS_Enable();
//
for(txcounter=0;txcounter<spiTransferSize;){//txcounter++){
if (SPI_I2S_GetFlagStatus(CANFD_SPI_CH, SPI_I2S_FLAG_TXE) != RESET){
SPI_I2S_SendData(CANFD_SPI_CH, SpiTxData[txcounter++]);
}
while (txcounter != rxcounter){
while (SPI_I2S_GetFlagStatus(CANFD_SPI_CH, SPI_I2S_FLAG_RXNE) == RESET);
SpiRxData[rxcounter++] = SPI_I2S_ReceiveData(CANFD_SPI_CH);
}
}
// error = DRV_SPI_ChipSelectAssert(spiSlaveDeviceIndex, false);
MCP251xFD_CS_Disable();
return (0);
}
|