Data coherency with DMA and I2S audio on STM32H7
- March 14, 2023
- 18 replies
- 7788 views
Moving from a audio effect prototype based on the STM32F407 to the STM32H757. Did a lot of stuff on the F4 with audio but on the H7 I'm getting stuck and can't get a simple audio loopback with DMA.
I'm using Cirrus Logic's CS5343 and CS4344 as external ADC/DAC connected to the I2S interface. I2S data frames are read and written in memory with DMA configured in circular RX/TX mode
.
Without DMA, audio loopback is OK. However, with DMA, the RX buffer isn't filled. The half complete and complete callbacks are triggered tho.
I'm aware that DMA can't access DTCM RAM and that with cache enabled, data coherency should be taken care of thanks to the MPU configuration and modification of the linker script :
MPU creates a region of 128kB device memory type (TEX : 0b000, not cacheable, bufferable, shareable)
RX and TX buffers (8kB each) subsections have been placed at 0x30010000 and 0x30012000 (SRAM1 in D2) in the linker script.
I tried to move the buffers in other RAM domains, make the MPU Region as shareable normal memory type but my Rx Buffer remains empty and/or doesn't update.
What I don't get is why my rx buffer isn't filled and updated by the DMA in the first place. If anyone got any clue or hints about what I'm missing, I'm all ears.
You'll find my whole main.c file attached.
And here's the modification of the linker script I've done :
.buffers(NOLOAD) :
{
. = ALIGN(4);
. = ABSOLUTE (0x30010000);
*(.rxBuffer)
. = ABSOLUTE (0x30012000);
*(.txBuffer)
} >RAM_D2
