IMX8DX M4 Can't use playback AND record routing on SGTL5000

Hello there !

I’ve been working on an audio app running on the M4 core of an iMX8DX. I’m currently having troubles with the routing of my codec.
In short, the SDK allows me to route the codec from I2S_IN → DAC → HP and play music just fine like this. It also allows me to route it like MIC_IN → ADC → I2S_OUT and record voice without problem. But the moment I try to configure my codec to allow both of these paths simultaneously, I lose everything. Suddenly I have no more DMA callbacks and, thus, can’t record or play anything.

I try to use my codec as close as possible to what the Linux simple-sound-card did, my SAI registers are basically the same, apart for some error callbacks and the stop mode that i do not use.

My CODEC currently has a simple configuration to allow it to play 16 bit samples at 48kHz, without using the PLL. More importantly, it is the master of the I2S bus and, on the slave SAI side, my RX block is synced to the TX one.

I am completely lost as to why my app would allow me to play with one simple route configuration, record with another, and lose all DMA callbacks when I try to combine them.
Does anybody know if there’s a specific way to allow both routes from the M4? I haven’t found anything of the sort online. I’ll send a minimal example tomorrow.

Thanks for any idea.
Have a good day,
Tom

Edit : found it, it was a simple software issue.

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello!

Thank you for your detailed description. This is a fairly common challenge when working with simultaneous playback and recording on embedded audio codecs, especially given the interplay between SAI peripheral configuration, DMA operation, and codec routing.

Points To Check

  1. Mixer and Signal Routing
    Double-check that the codec is configured to mix or enable both paths (I2S_IN→DAC→HP and MIC_IN→ADC→I2S_OUT) simultaneously. On many codecs, some internal mixers or signal paths must be explicitly enabled for both RX and TX.

  2. SAI Peripheral Configuration

    • Since your RX is synced to TX and the codec is the I2S bus master, make sure:
      • SRCR and SRCT (source registers) are correctly paired.
      • TX (playback) and RX (record) blocks should be enabled together.
      • The transmitter (TX) should be the last enabled and first disabled.
    • Incorrect ordering or missing synchronization can cause the SAI FIFO or DMA not to generate events as expected.
  3. DMA Configuration
    Ensure separate, properly sized DMA buffers for TX and RX. If you reuse the same channel or buffer inappropriately, both streams can interfere and result in lost interrupts or callbacks.

  4. Callback Registration

    • Confirm TX and RX DMA callbacks are both actively set and aren’t being overwritten or disabled when both are enabled.
  5. Clock Setup

    • Since your codec is the master, ensure your SAI expects to be clocked externally for both blocks and that internal clocking is not accidentally enabled for one.

Some Practical Debug Ideas

  • Try enabling only TX first, then RX, and observe if DMA callbacks still occur on each.
  • If there is a configuration status register for DMA or SAI, print/read back the status after initializing both paths.
  • Increase the DMA buffer sizes temporarily to see if shortfalls/underruns are part of the issue.

Documentation Link

The approach matches the handling described for similar architectures:

Sharing your minimal example when you have it will help in offering more pointed advice.

If you’d like, I can offer a generic sample structure for simultaneous playback and recording initialization—let me know!

Best regards,
Toradex AI Assistant.