I2S hangup with SPI

cancel
Showing results for 
Search instead for 
Did you mean: 

I2S hangup with SPI

Jump to solution
385 Views
randylee
Contributor IV

I'm using a K22FN512 running at 60MHz. I've got SPI memory @ 8MHz and mastering an I2S bus at 11025 sample rate stereo (356KHz).

I2S is running in transfer mode according to the tools.

Using SDK 2.4.1 (I think) and FreeRTOS 10 with one thread talking to both these things.  All transfers are being done with async (non-blocking) calls like SAI_TransferSendNonBlocking() and DSPI_MasterTransferNonBlocking()

What I'm seeing is that the I2S get's a FIFO underrun and data goes idle during any SPI transfer (which is like 2KB long)

I'm assuming that both of these are interrupt mode transfers in the SDK which, on an a 60MHz CPU, should be no problem to interleave these ISRs but it's like the SPI transfer is swamping the thing and it hasn't got any time to deal with the I2S at all. 

Any thoughts?

Labels (1)
Tags (2)
0 Kudos
1 Solution
165 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Randy,

The SAI demo feed FIFO with 8 word each time. It does not use watermark. So, when the MCU is busy doing DSPI work and SAI interrupt happen, there is no data in SAI FIFO.

There are 2 way to resolve this problem.

  1. Give SAI interrupt higher priority.

  2. Use SAI FIFO watermark. For example, set the value to 4. Each time you feed 4 word into FIFO. When the interrupt comes, you still have 4 data in FIFO.

Regards,

Jing 

View solution in original post

0 Kudos
4 Replies
166 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Randy,

The SAI demo feed FIFO with 8 word each time. It does not use watermark. So, when the MCU is busy doing DSPI work and SAI interrupt happen, there is no data in SAI FIFO.

There are 2 way to resolve this problem.

  1. Give SAI interrupt higher priority.

  2. Use SAI FIFO watermark. For example, set the value to 4. Each time you feed 4 word into FIFO. When the interrupt comes, you still have 4 data in FIFO.

Regards,

Jing 

View solution in original post

0 Kudos
165 Views
randylee
Contributor IV

I've tried playing with watermark and have it set anywhere from 2-6 without change to the problem....  So things are being swamped pretty hard with the SPI ISR it would seem...  Which seems odd to me.

I've got this working on a KL15 using KDS and PE so I know this can be done on this part.  Should be doable with ease. Just don't know how to get this done on this part using SDK and MCUExpresso.

So I'd change the priority of the SAI interrupt but I don't see how to do it in this SDK or the tools.  Nothing in the peripheral tool that shows what it is or a way to change it at least not in the transfer configuration for SAI.

0 Kudos
165 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

You can use NVIC_SetPriority() and NVIC_GetPriority(). These functions are in CMSIS core_cm4.h.

Regards,

Jing

165 Views
randylee
Contributor IV

OK, took a bit but...

SAI is already set at priority 0 (same as SPI).  In order to get this to work correctly, I had to lower the priority of the SPI (bump priority by 1)  [ARM priority is lower numbers, higher priority]

So, that now appears to run correctly.  Thanx.

0 Kudos