I2S with DMA transferring 32bit stereo audio issue

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by tanabe on Sun Oct 18 22:15:34 MST 2015

I'm using LPC4357 chip, I want to play audio at GPIO interrupt, so setting DMA transfer from memory to I2S peripheral in GPIO interrupt function. then L/R channel output is inverted occasionally.
My procedure is:
1. Setting I2S output format (32bit Stereo)
2. Turn I2S_DAO RESET bit to 0 (STOP bit is 1)

In GPIO interrupt,
1. Set DMA, and start transfer.
2. Wait TX_LEVEL is to higher than TX_DEPTH_DMA1
3. Turn I2S_DAO STOP to 0.

In this procedure, it will occur once per 1000 times that L/R channel inverting in output.
Inverting occurs only at beginning of transfer.

Why occurs Inverting?

And, I found work-around for this problem with substitute procedure in GPIO interrupt.
New procedure in GPIO interrupt is:
1. Write 0 to I2S_TX_FIFO.
2. Turn I2S_DAO STOP to 0.
3. Wait TX_LEVEL is 0.
4. Set DMA, and start transfer.

Then, L/R inverting never occur. But, I don't understand why the procedure can avoid the problem.
Does the work-around do well?

This issue seemed to be related the article in following link, but divied topic, because I use other chip and output audio.