SPI TX Buffer Question, SPI "Done" Transmitting? | Cypress Semiconductor
SPI TX Buffer Question, SPI "Done" Transmitting?
Hopefully this code snippet is enough information...
txBuffCount = SPIM_1_GetTxBufferSize();
Why does GetTxBufferSize() return 0?? I've got an 8-byte buffer and I'm writting 9 bytes here, but no matter...the 0xFF writes were because it was returning 0 even with a 5-byte write
I'm using software-controlled chip-select for this project and am running into issues with figuring out when my transmission is really done. I'm trying this -
while(SPIM_1_GetTxBufferSize() != 0) //wait on empty buffer
while((SPIM_1_ReadTxStatus() & SPIM_1_STS_SPI_DONE) != SPIM_1_STS_SPI_DONE); //wait on empty FIFO
The reason I'm not just using the SPIM_1_STS... like in the 2.0 datasheet example code is because I have an 8 byte receive buffer and interrupts that are running "under the hood" to transfer that data from the FIFO to the buffer are coming in occasionally and slowing my code down while the SPI master keeps transmitting. That is, I was having trouble with the FIFO emptying out during an ISR from the receive array, even though more transmit data was still in the buffer. The SPIM_1_STS... line ended up returning a FALSE and exiting, letting my software chip select go high when it shouldn't.