I2S/SAI FIFO Transmitting

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

I2S/SAI FIFO Transmitting

1,493 Views
eddiec
Contributor II

Hi! guys,

I test sai_dma_demo example in MQX4.1, the platform are K60F120M and SGTL5000.

When I played 48kHz/24bit wav file from SD card, I found there is a for loop "for(i = 0; i < requests; i ++)" in "sh_audio.c", the variable "i" will stop on 3 and task stop on

    /*Waiting for there are empty blocks*/
    ioctl(device_ptr, IO_IOCTL_I2S_WAIT_TX_EVENT,NULL);

So I think it's because of data still in FIFO and isn't be transmitted.

Anybody know how to solve it?

Best regards,

Eddie Chang

Tags (4)
0 Kudos
3 Replies

715 Views
pbanta
Contributor IV

Hi,

I'm having the same problem but with a K70FX120 and SGTL5000.  Have you resolved the problem?

Thanks,

Paul

0 Kudos

715 Views
pbanta
Contributor IV

I found the problem, but you may not have the same problem.

Problem

The board we built uses the SGTL5000 but hooks it up to the K70 I2S1 and I2C1.  I'm using the code from the sai_dma_demo example in the MQX distribution.  It worked on the K70-TWR but not on my board.  In sh_audio.c in the Shell_play() function there is little to no error checking of the ioctl() return values.  It happens that ioctl(device_ptr, IO_IOCTL_I2S_START_TX, NULL) was failing.  The reason it was failing was because of a bug in sai_mk70.c:_bsp_get_sai_tx_dma_source().  For channel 1 that function returns a source ID of 79.  There are only 64 entries in the DMAMUX(0/1) tables so range checking of the source ID was returning an error code.  So the DMA start was failing silently.  Four times through the loop and the code waits forever on a semaphore that will never post.

Solution

I modified both _bsp_get_sai_tx_dma_source() and _bsp_get_sai_rx_dma_source() sai_mk70.c to return the correct source IDs for I2S1 based on Table 3-26 in the K70 Reference Manual.  The source IDs happen to be the same for both I2S0 and I2S1 but I2S0 is in DMAMUX0 and I2S1 is in DMAMUX1.

0 Kudos

715 Views
soledad
NXP Employee
NXP Employee

Hi Eddie,

Please refer to the below links:

is there any demo code for using I2S?

I2S/SAI audio clock setting

In addition please refer to the below application notes:

AN4520: An I2S (Inter-IC Sound Bus)Application on Kinetis

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4520.pdf

This application note is a quick start guide on how to use the I2S module as inter-IC sound bus on Kinetis, for the new users. In addition, DMA- and interrupt-based ping-pong buffer scheme is also discussed to reduce the CPU cost for processing the audio data stream. Finally, an example of playing two sine waves of different frequency on each channel is shown for reference.

AN4800: An I2S (Integrated Interchip SoundBus) Application on Kinetis

http://cache.freescale.com/files/32bit/doc/app_note/AN4800.pdf?fpsp=1&WT_TYPE=Application

This application note introduces the I2S module on Kinetis of 2.x silicon, and guides the customers to learn this module quickly.


Have a great day,
Sol

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

0 Kudos