3 Replies Latest reply on Jun 29, 2017 1:07 AM by JoMe_264151

    Quick question: Waiting SPI Status Done




      Is it a good practice to add timeout while waiting SPI Status done after spi_write or is it something highly unlikely to occur?


      while(!(SPIM_1_ReadTxStatus() & SPIM_1_STS_SPI_DONE));





        • 1. Re: Quick question: Waiting SPI Status Done

          Hi Nico


          You can be sure that the SPIM sends the data, so you might wait for it. There is no reason thinkable (except a blown PSoC) why the data will not be sent out. In SPI (as opposed to I2C) there is no acknowledgement following a transfer of data.





          • 2. Re: Quick question: Waiting SPI Status Done

            Hello Bob. Can you comment further on this subject.  Using PSOC5, I have run into a situation where the done flag does not get set after sending data via SPI.  It happens so rarely that I have not been able to discover much about the problem.  (maybe once in a million write cycles).  The SPI is sending 24 bits (in 3 transfers) to a synthesizer chip.  The synthesizer frequency is set continuously in this band scanning application. I send all 3 bytes and then wait for the done flag before exiting the routine.  As I said, very rarely it hangs waiting for done.  I put a counter on it and in normal conditions it always gets the done flag within 3 read cycles.


            I guess my question is, would it be acceptable to not wait for done, as you indicate above?  Does your understanding of the SPI component really indicate that it is impossible that the bytes were not sent?  (On entry to the write routine the TX buffer is cleared, so the next data would not be corrupted if the buffer still contained data.)


            This problem has occurred on 2 out of 3 boards, The third board may not have enough usage for the problem to appear as yet.


            Thanks for any insight you may provide - Russ

            • 3. Re: Quick question: Waiting SPI Status Done

              Russ, I would suggest you to get in contact with Cypress directly. They are quite more experienced concerning SPI than me.


              At top of this page select "Design Support -> Create support case"