how to set up multiple i2s lines on rt1061

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

how to set up multiple i2s lines on rt1061

762 Views
ian_l
Contributor II

We have 2 codecs connected to the RT1061, so using 2 i2s input lines and 2 i2s output lines. RT1061 is the clock master that generates MCLK=12.288M, BCLK=3.072M, FS=48k, bitwidth=32.
The codec is CS4272.
What is the proper way to set up the SAI and EDMA? We tried (probably) all the combinations it still get no audio input or output.


sai_transfer_format_t format = {0};
format.bitWidth = kSAI_WordWidth32bits;

format.channel = 0U;
format.channelMask = kSAI_Channel0Mask | kSAI_Channel1Mask; // Is this right

format.sampleRate_Hz = kSAI_SampleRate48KHz;
format.protocol = config.protocol;
format.stereo = kSAI_Stereo;
format.isFrameSyncCompact = false;
format.watermark = FSL_FEATURE_SAI_FIFO_COUNT / 2U;

// Configure SAI EDMA,
SAI_TransferRxCreateHandleEDMA(SAI1, &s_saiRxHandle, saiEdmaCallback, NULL, &s_dmaRxHandle);
SAI_TransferTxCreateHandleEDMA(SAI1, &s_saiTxHandle, NULL, NULL, &s_dmaTxHandle);

int mclk = SAI1_CLK_FREQ; // this is 12.288M
SAI_TransferTxSetFormatEDMA(SAI1, &s_saiTxHandle, &format, mclk, mclk);
SAI_TransferRxSetFormatEDMA(SAI1, &s_saiRxHandle, &format, mclk, mclk);


Thanks!

Labels (1)
Tags (2)
0 Kudos
2 Replies

751 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi ian_l,

   About the SAI configuration, I highly suggest you use the mcuxpresso IDE, the clock, peripherals tool.

1. clock

kerryzhou_0-1616480626769.png

 Please note, in the pin configuration, you need to output the MCLK, as your codec need it.You also can check the codec wave.

2. About the SAI module, your SAI should be master.

kerryzhou_1-1616480863694.png

You can configure the output at first, just tx, then check the related SAI_TX_data, mclk, bCLK pin, whether it has the output data.

About the detail EDMA and sai control code, you can refer to the SDK code:

SDK_2.9.2_EVK-MIMXRT1060\boards\evkmimxrt1060\driver_examples\sai\edma_record_playback

Please also note, you need to add the DMA handler code.

3. About your codec

  The MIMXRT1060-EVK board is using the I2S to control the codec, you also need to write your codec related code.

 

Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

 

0 Kudos

756 Views
ian_l
Contributor II

If we do this, we see audio data coming in and out, but the frame sync runs at 96k instead of 48k.

format.bitWidth = 64;

....

int mclk = SAI1_CLK_FREQ;
int bclk = SAI1_CLK_FREQ / (2 - SAI1_CLOCK_SOURCE_PRE_DIVIDER);
SAI_TransferTxSetFormatEDMA(SAI1, &s_saiTxHandle, &format, mclk, bclk);
SAI_TransferRxSetFormatEDMA(SAI1, &s_saiRxHandle, &format, mclk, bclk);
0 Kudos