2024-11-24 05:02 AM
Hello,
I'm having some issue with audio playback using SAI(with DMA configured as circular) as soon as DCache is enabled.
I'm using cache clean on half/full interrupt but this doesn't help. I'm suspecting that whenever I got half/full complete interrupt, DMA is allowed to use already another part of the buffer(before I manage to perform a cache clean on that portion of the buffer).
Is there a way around it or there only option is to exclude this buffer from caching(or maybe not use circular DMA)?
2024-11-24 05:41 AM
Hi,
And I am doing exactly the same, playing audio from sd-card, with circular DMA -> SAI 3x I2S streams to the DACs. On H743 , I+D caches on, need to have some cache management.
After moving the data to the play buffer, on half or full callback, clean cache. That's all, to have it playing perfectly.
2024-11-24 05:46 AM
Hi,
That's interesting, could you share your SAI/DMA configurations and also how you do cache management? I'm sure I do cleans in the right moment, on the right buffer portions.
Which ram are you using? what are the MPU properties of it?
2024-11-24 06:25 AM
No, I can't show you my settings, because I made the program about 2 years ago and it's on my old PC.
But if you sure, you clean the cache on right time....it should work fine anyway.
MPU - i dont use.
Ram - I use all, itcm for stack and heap, main ram for data in buffer and flac and MP3 decoder buffers, ram1 for the play buffers and circular DMA.
What might be the thing you should do:
Play buffers in other ram than main and 32 byte-aligned, to match the cache lines.
Then clean cache just at end of callbacks and it will play smoothly.
2024-11-24 06:33 AM
All buffers are aligned according to the needs.
Do you remember how big was your play buffer(or half of it?) I'm running on relatively small buffers(max 4kB, maybe it's a timing problem where it's not yet cleaned but DMA already takes portions of it.
This is the first time I have DMA problems, usually it worked with clean...
2024-11-24 06:39 AM
What also confirms my theory is that my other half of the buffer is filled with audio data faster than there is half/full complete callback. When I do a clean there, audio is smooth. So it really looks like DMA takes data from new location before half/full callback complete is finished.