i.MX RT1170 SAI TX Multi-Channel

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX RT1170 SAI TX Multi-Channel

1,716 Views
joséviníciusmel
Contributor II

Hi,

I am developing with a custom i.MX RT1170 board and trying to use the 3 TX channels in the SAI1.

My goal is to use the DMA in the circular mode, and, if possible, with 3 different buffers to feed the TX data lanes (example, buffer0 to TX0, buffer1 to TX1 and buffer2 to TX2), but I was unable to do this with the SDK examples. I was able to test all the channels separately.

I tried to use the "sai_interrupt_transfer" example in the SDK, but the buffer to write in more than 1 channel must be continuous (SAI_TransferTxHandleIRQ->SAI_WriteNonBlocking). In this case I saw that I can modify this behavior doing the interrupt treatments directly in the handler, like in the "sai_interrupt" example.

But again, I would like to work with the circular DMA to achieve the best performance.

To achieve this go I tried to use the "sai_edma_ping_pong_buffer_half_interrupt" example putting the following modifications:

/* Added.. */

DMAMUX_SetSource(DEMO_DMAMUX, DEMO_EDMA_CHANNEL_EXTRA, (uint8_t)DEMO_SAI_TX_SOURCE);
DMAMUX_EnableChannel(DEMO_DMAMUX, DEMO_EDMA_CHANNEL_EXTRA);

...

/* Added.. */

EDMA_CreateHandle(&g_dmaHandleExtra, DEMO_DMA, DEMO_EDMA_CHANNEL_EXTRA);
EDMA_SetCallback(&g_dmaHandleExtra, EDMA_TX_Callback, NULL);
EDMA_ResetChannel(DEMO_DMA, g_dmaHandleExtra.channel);

...

/* Modified.. */

SAI_GetClassicI2SConfig(&saiConfig, DEMO_AUDIO_BIT_WIDTH, kSAI_Stereo, (1U << DEMO_SAI_CHANNEL) | (1U << DEMO_SAI_CHANNEL_EXTRA));

...

/* Added.. */

EDMA_PrepareTransfer(
&transferConfig, buffer, DEMO_AUDIO_BIT_WIDTH / 8U, (void *)destAddrExtra, DEMO_AUDIO_BIT_WIDTH / 8U,
(FSL_FEATURE_SAI_FIFO_COUNTn(DEMO_SAI) - saiConfig.fifo.fifoWatermark) * (DEMO_AUDIO_BIT_WIDTH / 8U),
BUFFER_SIZE * BUFFER_NUM, kEDMA_MemoryToPeripheral);

EDMA_TcdSetTransferConfig(&s_emdaTcdExtra, &transferConfig, &s_emdaTcdExtra);
EDMA_TcdEnableInterrupts(&s_emdaTcdExtra, kEDMA_MajorInterruptEnable | kEDMA_HalfInterruptEnable);
EDMA_InstallTCD(DEMO_DMA, g_dmaHandleExtra.channel, &s_emdaTcdExtra);
EDMA_StartTransfer(&g_dmaHandleExtra);

...

/* Modified.. */

SAI_TxSetChannelFIFOMask(DEMO_SAI, (1U << DEMO_SAI_CHANNEL) | (1U << DEMO_SAI_CHANNEL_EXTRA));

I am attaching the above code.

So, my question is, is it possible do this kind of transfer (different buffers to different channels in the same SAI) using DMA in circular mode? If yes, is there some error in this code?

I would appreciate some help here.

Thanks.

Labels (1)
0 Kudos
Reply
1 Reply

776 Views
chect1
Contributor III

Did you find a solution here?

I'm also looking for info around this. Like can you route multiple SAI Tx and Rx simultaneously using the eDMA?

0 Kudos
Reply