RT1021 how to transfer data from SPDIF to I2S (SAI1, channel 0).

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

RT1021 how to transfer data from SPDIF to I2S (SAI1, channel 0).

969 Views
carlos_takeo_ta
Contributor II

I'm using the IMX RT-1021 and I need to make a SPDIF to I2S converter.
I managed to do this via interrupt:
I configured SPDIF to generate interrupts with half the FIFO full (8 samples);
In the interrupt routine, I first copy the left data from the SPDIF FIFO to the TDR register of SAI-1 channel 0, then I copy the right data to the same TDR register.

This worked, but I notice interruptions in the audio stream when the processor is more demanding.

I believe it is due to the high rate of SPDIF FIFO interruptions.
In the case of SPDIF, the sample rate of the signal I use is 44.1 KHz, that is: 44.1K[samples] / 8[samples] = 5512 [int/s].

I want to know if it is possible to transfer SPDIF FIFO data via DMA to SAI1 channel 0, directly from peripheral to peripheral, without using a buffer.
Could you give me an example code?

Best Regards.

0 Kudos
Reply
4 Replies

804 Views
carlos_takeo_ta
Contributor II

Hello Gavin.

Thank you very much for your feedback.

I managed to develop a solution using DMA from peripheral to peripheral.
As you said in your last post, the data format of the two interfaces is different.
SPDIF receives data from the left and right sides in separate FIFOs, while SAI uses a single FIFO for both sides.
I managed to make it work by setting the SPDIF RX FIFO Full threshold to 1.
I configured the SPDIF DMA to transfer data from both sides (left and right) of the SPDIF to the same address as the TDR register.
I needed to change the "SPDIF_TransferReceiveEDMA" function to make it work.

However, the operation was not good, I noticed the same symptoms of flow interruptions.
I believe it is because of the DMA overhead when making the SPDIF RX FIFO Full threshold equal to 1.
If I increase the threshold, for example to 8, the playback becomes strange, it seems that DMA transfers all 8 data on the left side first and then the 8 on the right.

I'm going to try to do it via DMA using a buffer, a DMA request from SPDIF to fill the buffer and another from SAI to empty it.

Thank you very much for the tips.

 

Best Regards.

0 Kudos
Reply

915 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @carlos_takeo_ta ,

Thanks for your interest in NXP MIMXRT series!

The drivers for SPDIF are not implemented in the RT1020's SDK, but the good news is that they are implemented in the RT1170 SDK and include sample projects that use both interrupts and EDMA. They should serve as a good reference for you.

They are located in this path: MIMXRT1170-EVK_SDKRoot\boards\evkmimxrt1170\driver_examples\spdif\edma_transfer\cm7

Hope it could help you!

Best regards,
Gavin

0 Kudos
Reply

896 Views
carlos_takeo_ta
Contributor II

Thank you very much for the feedback.

The link you tried to give me is not working.
But I think it should be similar to the RT-1050 SDK that has examples for SPDIF.
I've already seen the RT-1050 SDK examples, but they don't solve my problem.
The examples I saw in the SDK only show how to do interrupt transfer or DMA from peripheral to memory and vice versa.
As I mentioned before, I'm trying to transfer via DMA from peripheral to peripheral.
I want to transfer the data received in the input FIFO of the SPDIF interface, directly to the output FIFO of the SAI1-CH0 interface.
I've already managed to make this scheme work via interrupt.
I would like to know how to do it via DMA.

Best Regards.

0 Kudos
Reply

812 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @carlos_takeo_ta ,

Thanks very much for your kind patience.  I've spent a lot of work these days talking to internal teams about whether existing resources exist. Unfortunately there are no existing demos that are immediately executable, but for this issue we have identified a solution idea for it that you may need to try on your own. I apologize in advance for any inconvenience this may cause you.

The idea is as I mentioned before, the second half of the sai_edma_playback_demo's logic is to play through sai, and the first half of spdif_edma_playback is to receive through edma, and we may need to port both parts of the code to accomplish your goal. The edma carrying data via interrupts triggering sai playback. Also, it may be important to note that the data format sent by i2s is not the same as the data format received by spdif, so data reorder may have to be implemented in the callback.

I hope these thoughts will help you in your development, and again, I apologize for the inconvenience.

Best regards,
Gavin

0 Kudos
Reply