How can I configure multi-channel SAI using edma?

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

How can I configure multi-channel SAI using edma?

2,373 Views
henrique1
Contributor III

Hi!X

I'm trying to configure an imx RT1020 board to do an audio transfer from 1 input to 2 outputs. All lines are mapped to SAI1 and I'm using channel 0 for RX and channels 1 and 2 for TX.

I've been trying for some time now to use the SDK sai_edma workflow, based on the evkmimxrt1020_sai_edma_transfer example. I can successfully setup 1 channel in and 1 channel out, however things get more complicated when I try to include the second TX channel. It appears that the SDK isn't designed for multi-channel SAI edma transfers (e.g. in the function SAI_TransferTxCreateHandleEDMA there's a private handle (s_edmaPrivateHandle) that's used for each TX handle, so I shouldn't really be using 2 different handles. And if I try to manually change the handle.channel  value before calling SAI_TransferSendEDMA, I get weird behaviours in the outputs).

My guess is that I can't use a single edma handler for both channels, since each edma handler is naturally assigned to a dma channel.

My question is: is there a correct way to setup the SAI edma for multi-channel usage using the SDK or do I need to go around it?

Thank you for your time!

Henrique

Labels (1)
2 Replies

1,928 Views
henrique1
Contributor III

Hi!

Thank you for your response! I was looking exactly for something like this, however I'm having trouble figuring out more information about this combined mode. For example, I'd seen that application note before but it doesn't seem to have any relevant information, it just briefly mentions this mode. Also, looking into the imx RT1020 datasheet there seems to be no reference to this mode either. The register bits TCR4[FCOMB] are even defined as reserved...


Nevertheless I was able to get it working by tweaking the fsl_sai_edma library. Inside SAI_TransferSendEDMA there's a call to EDMA_PrepareTransfer. By doubling the destwidth parameter I can have the dma write simultaneously to channel 0 and channel 1, which is exactly what I need. From my understanding this is very similar to the combined mode but it somehow works even with those bits disabled. I would much rather do it the correct way though.

For the ppl having the same issue I recommend starting by looking into this thread and using the altered fsl_sai_edma library.

Best regards,

henrique

0 Kudos

1,928 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

First of all, sorry for the later reply.

There is an application note AN12090 about using multi-channel Feature of i.MX RT SAI module.

The SAI FIFO has combine mode for Tx, please refer below picture for the detailed info:

pastedImage_1.png

With the FIFO combine mode 0b10:

TCR4[FCOMB] =10; DMA/CPU writes 1 TDR; 4 FIFOs are used; 4 shift register/TxD line are used.

         We would recommend to use FIFO combine mode.

         Wish it helps.

best regards,

Mike