Is it possible to transfer from SPI to SAI using DMA?

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

Is it possible to transfer from SPI to SAI using DMA?

Jump to solution
1,178 Views
javiercardona
Contributor III

Hello,

 

Our KL27-based design has a codec connected via SAI (I2S) and a flash memory connected via SPI.

We are able to transfer audio buffers from/to the codec to/from flash using DMA transfers to/from SRAM.

We are now attempting to configure DMA to do direct transfer from I2S to SPI so we can record audio to flash with minimal CPU intervention.

 

Has anyone attempted this before?  Just knowing that it is possible would be very helpful.  Example code would be grand

 

Best,

 

Javier

 

Manuel Rodriguez Adrian Sanchez Cano

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
911 Views
javiercardona
Contributor III

I solved the bus error problem by setting the Destination Size in the DMA DCR register to 8-bits when writing to SPI.

This solves the dma bus error and the DMA transfer completes successfully.

I do not observe any data on the SPI bus, but I will create a separate question for that.

View solution in original post

0 Kudos
Reply
4 Replies
911 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Havier,

As you said that you are able to transfer data from SRAM to SPI flash via DMA, if it is the case, I think it is okay to transfer from I2S received data register to SPI data register via DMA.

The DMA itself supports to transfer data from peripheral to peripheral, but as you know that the I2S is stream data, I have two concern that the SPI itself is fast enough to transfer data so that the SPI module can keep up with the step of I2S, secondly, I am not familiar with the writting SPI flash, do you means that writing the SPI  flash is to write the data to flash RAM, the flash itself has a state machine to write data from RAM to flash?

BR

Xiangjun Rong

0 Kudos
Reply
911 Views
javiercardona
Contributor III

Hello Xiangjun,

Thanks a lot for your response.

Yes, I am capable to transfer data from/to SRAM to/from SPI as well as from/to SRAM to/from I2S using DMA.

When I try to configure the DMA channel for SPI to/from I2S (always triggered by I2S), I get a Bus Error on Source (DMA_DSR_BCR bit 29) when transferring from SPI, and a Bus Error on Destination (DMA_DSR_BCR bit 28).  Would that be what you meant by "SPI module not keeping up with step of I2S"?

Thanks!

Javier

0 Kudos
Reply
912 Views
javiercardona
Contributor III

I solved the bus error problem by setting the Destination Size in the DMA DCR register to 8-bits when writing to SPI.

This solves the dma bus error and the DMA transfer completes successfully.

I do not observe any data on the SPI bus, but I will create a separate question for that.

0 Kudos
Reply
911 Views
javiercardona
Contributor III

By the way, I should mention that the SPI Flash device that we are using is fast enough to accept data from the codec at the rate that it produces it (8 kHz).  We are able to transfer data from SRAM to flash at 12 MHz SPI rates.

Cheers,

Javier

0 Kudos
Reply