Repository navigation
STM32 SAI DMA: copy whole runs of frames, larger halves and queue - #9
Merged
Merged
Conversation
The writer copies as many frames as there is room for and moves the head once; the interrupt refills a half with one or two memcpy() of the queue and moves the tail once - instead of a pass with atomics per frame. A half is 128 frames (an interrupt every 2.7 ms at 48 kHz, not 1.3 ms), the queue 1024 (21 ms): a mixer's 10 ms period fits, so its writer is woken a few times per period instead of every half. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the STM32 SAI DMA, the writer and the interrupt worked one frame at a time, with atomics on every frame:
tx_headonce.memcpy()calls from the queue (two when the queue wraps) and movestx_tailonce. Underruns are counted as before.dmaheap: 4 KB for 4 TDM slots.Part of bringing dmaudio on the STM32F746G-DISCO from ~45 % to ~10 % of the CPU (see choco-technologies/dmaudio, choco-technologies/dmwm8994, choco-technologies/dmdevfs).
Test plan
🤖 Generated with Claude Code