Content originally posted in LPCWare by noahk on Tue Feb 19 17:11:47 MST 2013
Hi capiman,
Thanks for catching this. Here is the reasoning for the behavior you are seeing:
In Mode 0 or 2 (CPOL = 0 or 1, CPHA = 0), the SPI protocol requires that at each rising edge new data be put out on MOSI. If you are performing a multi-transmit transfer, then the SPI block delays the final rising edge in order to wait for new data. If you set EOT, then the SPI block is able to complete the transfer, and so it performs the final rising edge and ends the transfer. You can tell when a stall occurs by reading the STALLED bit from the status register. Had you written new data to TXDATCTL before the SPI had put out the final bit of the last transmit, then you would not have seen this stall, as the SPI block would have been able to continue.
Consider the case where you want to send 20 bits out. You send the first 16 bits in the first write to TXDATCTL. At the 15th rising edge, the last bit of data of the first transmit is put out. At the 16th falling edge, that bit is read by the slave. If you had already written the final 4 bits into TXDATCTL, then the SPI block would continue with the 16th rising edge, where it would put out the first bit of the final four bits. But since you haven't written to TXDATCTL, the SPI block stalls. The SPI will now wait for a write of the final four bits. To abort without writing more data you can use the ENDTRANSFER bit of the STATUS register.
Noah