Hi,
On our KL27 device we have observed that SAI receive transfers will put the SAI peripheral in a certain state that it will not be able to transmit anymore.
We have to functions, play() and record() which make repeated calls to SAI_TransferSendDMA() and SAI_TransferReceiveDMA() respectively.
We are able to call play() repeatedly, and the audio is transferred to the codec.
We are able to call record() repeatedly, and the audio is received from the codec.
We are able to call record() after play(), but a play() following a record will not work. No DMA callbacks are invoked, and the FIFO Error Flag (I2S0_TCSR:FEF
) is set before initiating the transmission and cannot be cleared.
In our configuration TX is in Async mode, and RX is in Sync mode, which is the default configuration for that driver.
We have seen other similar discussions on the forums regarding SAI problems. One of them recommended clearing the FIFO error flag before every enable operation, but that did not solve the issue.
Any suggestions on how to resolve this issue would be gladly appreciated.
Best,
Solved! Go to Solution.
I've had the exact same problem. You need to service both FIFOs in synchronous mode, it sounds like your record is operating synchronously but only reading the RX FIFO while using TX asynchronously. When you run the record the TX FIFO is put in an error state that you don't seem to be resetting. That's why the order matters.
It's not obvious and not mentioned in the reference manual but makes sense once you think about it.
Two ways to solve it for anyone else who stumbles on I2S or SAI hanging:
I've had the exact same problem. You need to service both FIFOs in synchronous mode, it sounds like your record is operating synchronously but only reading the RX FIFO while using TX asynchronously. When you run the record the TX FIFO is put in an error state that you don't seem to be resetting. That's why the order matters.
It's not obvious and not mentioned in the reference manual but makes sense once you think about it.
Two ways to solve it for anyone else who stumbles on I2S or SAI hanging:
Hi, Javier,
Could you paste your project here so that we can have a review for the code?
BR
Xiangjun Rong