i have a trouble when i am using SPI to communicate with a fram .I would like to know why using spi communication must use a delay function after sending a byte and before reading it, if no delay function is used, there will be a shift.(0x01,0x02,0x03 will become 0x00 0x01 0x02).And the delay time is different, the shift is different
I guess the reason is you need to make sure the TX was completed - the data was written to FRAM(by checking RX buffer status) before reading the data from FRAM.
/* Start transfer */ SPIM_SpiUartWriteTxData((uint32) wrBuf[i]); /* Wait for the end of the transfer. The number of transmitted data * elements has to be equal to the number of received data elements. */ while (PACKET_SIZE != SPIM_SpiUartGetRxBufferSize()); /* Clear dummy bytes from TX buffer */ SPIM_SpiUartClearTxBuffer(); /* Read data from the RX buffer */ tmpBuffer[i] = (uint8) SPIM_SpiUartReadRxData();