I2S/SAI received data sometimes shifted by one bit

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

I2S/SAI received data sometimes shifted by one bit

990 Views
matthias
Contributor III

Hello,

I am using a FRDM-K64 board to receive I2S data from an audio codec. I use the KSDK 1.1.0 SAI driver in I2S stereo mode with 32 bit words and eDMA to write the received data into a large buffer. In general this works fine, but sometimes I see that some received words are shifted by one bit. When I look at the I2S signals with an oscilloscope, they look fine. The bit clock has low to high transitions in the middle of the data bits and the frame sync signal switches polarity one data bit before a new word begins.

Does anyone have an idea what can cause such bit shifts?

Regards Matthias

Labels (1)
4 Replies

605 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Matthias,

Would you please share your code for a review? Thanks for your patience!


Have a great day,
Kan

0 Kudos

605 Views
matthias
Contributor III

Hi Kan,

thanks for your reply. My I2S receiver code is part of a larger software project. I extracted the functions that set up and start the SAI and eDMA drivers in the attached files. The files are therefore not a compileable project, but I hope that you can figure out how my I2S receiver is set up.

Regards

Matthias

0 Kudos

605 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Matthias,

I reviewed your code, seems you didn't use EDMA_DRV_Init() and EDMA_DRV_RequestChannel() in the init stage, but per SDK API RM, the eDMA driver should be initialized as below:

To use the DMA driver, follow these steps:

1. Initialize the DMA module: EDMA_DRV_Init().

2. Request a DMA channel: EDMA_DRV_RequestChannel().

3. Configure the TCD:

• Configure the TCD chain in a scatter-gather list. UART transmit/receive is the common case.

• Configure the TCD chain in a loop way. Audio playback/Record is the common case.

• Configure software TCD and push it to registers. Use the DSPI case to configure and push the

TCD to registers.

4. Register callback function: EDMA_DRV_InstallCallback.

5. Start the DMA channel: EDMA_DRV_StartChannel.

6. [OPTION] Stop the DMA channel: EDMA_DRV_StopChannel.

7. Free the DMA channel: EDMA_DRV_ReleaseChannel.

and to interface with an audio codec, we recommend you using sound card driver instead, which also supports SAI+eDMA, you may refer to the sai_demo(C:\Freescale\KSDK_1.1.0\demos\sai_demo) and sound card driver(C:\Freescale\KSDK_1.1.0\platform\composite\src\soundcard) for more details.

Hope that helps,


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

605 Views
matthias
Contributor III

Hi Kan,

thank you very much for your detailed answer and the useful hints. In the code I attached, I forgot to include the initialization for the eDMA driver since it was auto initialized by Processor Expert in my original code.

Regarding the original problem of sporadic bit shifts, we concluded that it must be a hardware problem in the wiring between the audio codec and the Freedom board.

Regards

Matthias

0 Kudos