Problem using I2S DMA

Post here first, or if you can't find a relevant section!
Post Reply
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Problem using I2S DMA

Post by stevestrong »

Hi,

I am currently struggling to get I2S working with DMA as master Tx on STM32F411E disco board.
The I2S data coming out on SD line is very strange.
I attach a good picture, and a bad picture.
The good picture is taken when I write data manually to the SPI data register.
good.jpg
good.jpg (59.48 KiB) Viewed 296 times
The bad picture shows the same data stream when DMA is enabled.
bad.jpg
bad.jpg (58.5 KiB) Viewed 296 times
The (good) data stream is: 40 00 40 00 3f 9C 3f 9c (hex), which can be matched on the good picture, but not on the bad.

The good data is read out from the DMA buffer, so I am pretty sure that the DMA buffer has the right data.

And here are the relevant settings (for SPI3, using DMA channel 0, Tx stream 5):
DMA SCR: 00000451
DMA PAR: 40003C0C
DMA NDTR: 00008FFD
DMA M0AR: 20002900
DMA M1AR: 00000000
DMA FCR: 00000001
SPI CR2: 00000002
I2S CFGR: 00000E00
I2S PR: 0000020D

I use the same settings for both manual write and DMA, actually I am doing one after the other: first I write the data manually from the buffer, then I run the DMA after 1 sec wait time.
The buffer content does not change, so I would expect that same data comes out in both cases (I know DMA can only output in little endian mode).

The bad picture looks like it would send data in 24 bit format somehow scrambled, but I cannot see anything wrong in these settings.
Maybe anyone has another idea what could be wrong.

Any help is appreciated.
by Bakisha » Tue Feb 27, 2024 1:15 pm
As i understand, if enabled, I2S use 16bit Data Register, regardless if SPI is set to use 8bit data format.
Try to set PSIZE, MSIZE bits in DMA SCR register ( and your buffer ) as 16bit size, not as 8bit.
Go to full post
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Problem using I2S DMA

Post by stevestrong »

I have analyzed the output data.

Instead of:
40 00 40 00 3F 9C 3F 9C

the bad stream is:
40 (40) 00 (00) 40 (40) 00 (00) 3F (3F) 9C (9C) 3F (3F) 9C (9C)

So it looks like the DMA sends each byte repeatedly from the buffer: x (x-repeated)

WHY ???
User avatar
Bakisha
Posts: 139
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 5
Contact:

Re: Problem using I2S DMA

Post by Bakisha »

As i understand, if enabled, I2S use 16bit Data Register, regardless if SPI is set to use 8bit data format.
Try to set PSIZE, MSIZE bits in DMA SCR register ( and your buffer ) as 16bit size, not as 8bit.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Problem using I2S DMA

Post by stevestrong »

Man, I own you a beer, thanks a lot, that was it!

Actually, only PSIZE must be changed, because:
In direct mode, MSIZE is forced by hardware to the same value as PSIZE as soon as bit EN = '1'.
(chap. 9.5.5. of RM0383)
Post Reply

Return to “General discussion”