<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: IMXRT1170-EVKB - SAI TDM in MCX Microcontrollers</title>
    <link>https://community.nxp.com/t5/MCX-Microcontrollers/IMXRT1170-EVKB-SAI-TDM/m-p/2197371#M4303</link>
    <description />
    <pubDate>Mon, 03 Nov 2025 08:56:02 GMT</pubDate>
    <dc:creator>Femio</dc:creator>
    <dc:date>2025-11-03T08:56:02Z</dc:date>
    <item>
      <title>IMXRT1170-EVKB - SAI TDM</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/IMXRT1170-EVKB-SAI-TDM/m-p/2190000#M4257</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'm trying to implement a SAI with TDM protocol for audio data transfer.&lt;/P&gt;&lt;P&gt;Starting from sai_edma_tdm_record_playback without &lt;SPAN&gt;CS42448&lt;/SPAN&gt;, I've changed few configurations in order to implement a loopback between SAI1_RX/TX.&lt;/P&gt;&lt;P&gt;Links are:&lt;/P&gt;&lt;P&gt;TX_BCLK -&amp;gt; RX_BCLK&lt;/P&gt;&lt;P&gt;TX_SYNC -&amp;gt; RX_SYNC&lt;/P&gt;&lt;P&gt;TX_DA0 -&amp;gt; RX_DA0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On an oscilloscope connected to TX_DA0, it is possible to see data sent but they are uncorrect.&lt;/P&gt;&lt;P&gt;someone can explain to me how to correctly configure a TDM communication and what is wrong in the code below?&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;P&gt;-F&lt;/P&gt;&lt;LI-CODE lang="c"&gt;AT_NONCACHEABLE_SECTION_ALIGN(static uint8_t Buffer[BUFFER_NUMBER * BUFFER_SIZE], 4);
#if defined(DEMO_QUICKACCESS_SECTION_CACHEABLE) &amp;amp;&amp;amp; DEMO_QUICKACCESS_SECTION_CACHEABLE
AT_NONCACHEABLE_SECTION_INIT(sai_edma_handle_t txHandle);
AT_NONCACHEABLE_SECTION_INIT(sai_edma_handle_t rxHandle);
#else
AT_QUICKACCESS_SECTION_DATA(sai_edma_handle_t txHandle);
AT_QUICKACCESS_SECTION_DATA(sai_edma_handle_t rxHandle);
#endif
static uint32_t tx_index = 0U, rx_index = 0U;
volatile uint32_t emptyBlock = BUFFER_NUMBER;
edma_handle_t dmaTxHandle = {0}, dmaRxHandle = {0};
extern codec_config_t boardCodecConfig;
codec_handle_t codecHandle;

/*******************************************************************************
 * Code
 ******************************************************************************/
static void rx_callback(I2S_Type *base, sai_edma_handle_t *handle, status_t status, void *userData)
{
    if (kStatus_SAI_RxError == status)
    {
        /* Handle the error. */
    }
    else
    {
        emptyBlock--;
    }
}

static void tx_callback(I2S_Type *base, sai_edma_handle_t *handle, status_t status, void *userData)
{
    if (kStatus_SAI_TxError == status)
    {
        /* Handle the error. */
    }
    else
    {
        emptyBlock++;
    }
}

/*!
 * @brief Main function
 */
int main(void)
{
    sai_transfer_t xfer;
    edma_config_t dmaConfig = {0};
    sai_transceiver_t saiConfig;

    BOARD_InitHardware();

    PRINTF("SAI TDM record playback example started!\n\r");

    /* Init DMA and create handle for DMA */
    EDMA_GetDefaultConfig(&amp;amp;dmaConfig);
#if defined(BOARD_GetEDMAConfig)
    BOARD_GetEDMAConfig(dmaConfig);
#endif
    EDMA_Init(EXAMPLE_DMA, &amp;amp;dmaConfig);
    EDMA_CreateHandle(&amp;amp;dmaTxHandle, EXAMPLE_DMA, EXAMPLE_TX_CHANNEL);
    EDMA_CreateHandle(&amp;amp;dmaRxHandle, EXAMPLE_DMA, EXAMPLE_RX_CHANNEL);
#if defined(FSL_FEATURE_EDMA_HAS_CHANNEL_MUX) &amp;amp;&amp;amp; FSL_FEATURE_EDMA_HAS_CHANNEL_MUX
    EDMA_SetChannelMux(EXAMPLE_DMA, EXAMPLE_TX_CHANNEL, EXAMPLE_SAI_TX_SOURCE);
    EDMA_SetChannelMux(EXAMPLE_DMA, EXAMPLE_RX_CHANNEL, EXAMPLE_SAI_RX_SOURCE);
#endif

#if defined(FSL_FEATURE_SOC_DMAMUX_COUNT) &amp;amp;&amp;amp; FSL_FEATURE_SOC_DMAMUX_COUNT 
#if defined(EXAMPLE_DMAMUX_TX_CHANNEL) &amp;amp;&amp;amp; defined(EXAMPLE_DMAMUX_RX_CHANNEL)
    /* Init DMAMUX */
    DMAMUX_Init(EXAMPLE_DMAMUX_TX);
    DMAMUX_Init(EXAMPLE_DMAMUX_RX);
    DMAMUX_SetSource(EXAMPLE_DMAMUX_TX, EXAMPLE_DMAMUX_TX_CHANNEL, (uint8_t)EXAMPLE_SAI_TX_SOURCE);
    DMAMUX_EnableChannel(EXAMPLE_DMAMUX_TX, EXAMPLE_DMAMUX_TX_CHANNEL);
    DMAMUX_SetSource(EXAMPLE_DMAMUX_RX, EXAMPLE_DMAMUX_RX_CHANNEL, (uint8_t)EXAMPLE_SAI_RX_SOURCE);
    DMAMUX_EnableChannel(EXAMPLE_DMAMUX_RX, EXAMPLE_DMAMUX_RX_CHANNEL);
#else
    /* Init DMAMUX */
    DMAMUX_Init(EXAMPLE_DMAMUX);
    DMAMUX_SetSource(EXAMPLE_DMAMUX, EXAMPLE_TX_CHANNEL, (uint8_t)EXAMPLE_SAI_TX_SOURCE);
    DMAMUX_EnableChannel(EXAMPLE_DMAMUX, EXAMPLE_TX_CHANNEL);
    DMAMUX_SetSource(EXAMPLE_DMAMUX, EXAMPLE_RX_CHANNEL, (uint8_t)EXAMPLE_SAI_RX_SOURCE);
    DMAMUX_EnableChannel(EXAMPLE_DMAMUX, EXAMPLE_RX_CHANNEL);
#endif
#endif

    /* SAI init */
    SAI_Init(DEMO_SAI);

    SAI_TransferTxCreateHandleEDMA(DEMO_SAI, &amp;amp;txHandle, tx_callback, NULL, &amp;amp;dmaTxHandle);
    SAI_TransferRxCreateHandleEDMA(DEMO_SAI, &amp;amp;rxHandle, rx_callback, NULL, &amp;amp;dmaRxHandle);

    /* TDM mode configurations */
    SAI_GetTDMConfig(&amp;amp;saiConfig, kSAI_FrameSyncLenOneBitClk, DEMO_AUDIO_BIT_WIDTH, DEMO_AUDIO_DATA_CHANNEL,
                     kSAI_Channel0Mask);
    saiConfig.frameSync.frameSyncEarly = true;
    saiConfig.masterSlave = kSAI_Master;
    SAI_TransferTxSetConfigEDMA(DEMO_SAI, &amp;amp;txHandle, &amp;amp;saiConfig);
    saiConfig.masterSlave = kSAI_Slave;
    SAI_TransferRxSetConfigEDMA(DEMO_SAI, &amp;amp;rxHandle, &amp;amp;saiConfig);

    /* set bit clock divider */
    SAI_TxSetBitClockRate(DEMO_SAI, DEMO_AUDIO_MASTER_CLOCK, DEMO_AUDIO_SAMPLE_RATE, DEMO_AUDIO_BIT_WIDTH,
                          DEMO_AUDIO_DATA_CHANNEL);
    SAI_RxSetBitClockRate(DEMO_SAI, DEMO_AUDIO_MASTER_CLOCK, DEMO_AUDIO_SAMPLE_RATE, DEMO_AUDIO_BIT_WIDTH,
                          DEMO_AUDIO_DATA_CHANNEL);

    /* master clock configurations */
    BOARD_MASTER_CLOCK_CONFIG();
    /* CS42888 initialization */
    //DEMO_InitCodec();

    memset((uint8_t *)&amp;amp;Buffer,'5', sizeof(uint8_t) * 4096);

    while (1)
    {
        if (emptyBlock &amp;gt; 0)
        {
            xfer.data     = Buffer + rx_index * BUFFER_SIZE;
            xfer.dataSize = BUFFER_SIZE;
            if (kStatus_Success == SAI_TransferReceiveEDMA(DEMO_SAI, &amp;amp;rxHandle, &amp;amp;xfer))
            {
                rx_index++;
            }
            if (rx_index == BUFFER_NUMBER)
            {
                rx_index = 0U;
            }
        }
        if (emptyBlock &amp;lt; BUFFER_NUMBER)
        {
            xfer.data     = Buffer + tx_index * BUFFER_SIZE;
            xfer.dataSize = BUFFER_SIZE;
            if (kStatus_Success == SAI_TransferSendEDMA(DEMO_SAI, &amp;amp;txHandle, &amp;amp;xfer))
            {
                tx_index++;
            }
            if (tx_index == BUFFER_NUMBER)
            {
                tx_index = 0U;
            }
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Oct 2025 13:43:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/IMXRT1170-EVKB-SAI-TDM/m-p/2190000#M4257</guid>
      <dc:creator>Femio</dc:creator>
      <dc:date>2025-10-21T13:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: IMXRT1170-EVKB - SAI TDM</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/IMXRT1170-EVKB-SAI-TDM/m-p/2196772#M4290</link>
      <description>&lt;P&gt;kSAI_FrameSyncLenOneBitClk is typically for I2S. For TDM, you might need a longer sync pulse depending on your frame size.&lt;BR /&gt;You're using kSAI_Channel0Mask, which means only one channel is active. For TDM, you usually want multiple channels (e.g., kSAI_Channel0Mask | kSAI_Channel1Mask | ...).&lt;BR /&gt;Ensure DEMO_AUDIO_DATA_CHANNEL matches the number of active channels in the mask.&lt;/P&gt;
&lt;P&gt;BR,&lt;BR /&gt;Omar&lt;/P&gt;</description>
      <pubDate>Fri, 31 Oct 2025 16:31:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/IMXRT1170-EVKB-SAI-TDM/m-p/2196772#M4290</guid>
      <dc:creator>Omar_Anguiano</dc:creator>
      <dc:date>2025-10-31T16:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: IMXRT1170-EVKB - SAI TDM</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/IMXRT1170-EVKB-SAI-TDM/m-p/2197370#M4302</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DEMO_AUDIO_DATA_CHANNEL&amp;nbsp;is set to 8 but in this example si configured only one channel in the channel mask.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In output, measuring the TX output pin, I see wrong data as shown in the attached image (red is the RX input data and cyan TX output data).&amp;nbsp;Is this behavior related to not having configured the channels correctly?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;BR,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Francesco&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Nov 2025 08:55:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/IMXRT1170-EVKB-SAI-TDM/m-p/2197370#M4302</guid>
      <dc:creator>Femio</dc:creator>
      <dc:date>2025-11-03T08:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: IMXRT1170-EVKB - SAI TDM</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/IMXRT1170-EVKB-SAI-TDM/m-p/2197371#M4303</link>
      <description />
      <pubDate>Mon, 03 Nov 2025 08:56:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/IMXRT1170-EVKB-SAI-TDM/m-p/2197371#M4303</guid>
      <dc:creator>Femio</dc:creator>
      <dc:date>2025-11-03T08:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: IMXRT1170-EVKB - SAI TDM</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/IMXRT1170-EVKB-SAI-TDM/m-p/2199219#M4313</link>
      <description>&lt;P&gt;It can be the issue that channels are not configured correctly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR,&lt;BR /&gt;Omar&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2025 17:18:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/IMXRT1170-EVKB-SAI-TDM/m-p/2199219#M4313</guid>
      <dc:creator>Omar_Anguiano</dc:creator>
      <dc:date>2025-11-05T17:18:20Z</dc:date>
    </item>
  </channel>
</rss>

