Configure DMA with SPI master

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

Configure DMA with SPI master

6,553 Views
mikaelelharrar
Contributor III

Hi ,

I don't succeed to configure correctly my SPI + DMA on kinetis 64.

The SPI should works as master.

I configured 2 DMA channels (Rx and Tx).

DMA Tx channel is triggered by an external GPIO.

Minor loop is 12 bytes and major loop 32, so the Rx buffer size is 32*12 bytes.

 

The trigger transfer to DMA Tx channel seems to work, but I dont get anything on the Rx buffer.

Two possibilities I think:

   - The DMA Tx channel is correctly triggered but don't send anything on the SPI Tx wire.

   - The DMA Rx channel of the SPI Rx channel is not correctly configured.

 

I attached here my code.

 

Note that I'm using the "fsl_edma" driver and not "fsl_dspi_edma" driver because this later does'nt manage the minor and major loop like I need.

 

Thank you for your help.

 

Thanks

Original Attachment has been moved to: ads131.c.zip

0 Kudos
Reply
12 Replies

4,218 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

For K64 SPI0 module supports both TX & RX to trigger DMA, customer can use SPI0 TX to trigger the DMA.

pastedImage_1.png

Could you provide the SPI0, DMAMUX, eDMA modules registers value during code execution?

Thanks.


Have a great day,
Ma Hui

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

0 Kudos
Reply

4,218 Views
mikaelelharrar
Contributor III

follow

DMAMUX_registers.PNG

SPI0_registers.PNG

Please help.

Thanks

0 Kudos
Reply

4,218 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I checked the SPI register SPI0_RSER, which doesn't enable SPI trigger DMA request with [RFDF_RE] & [RFDF_DIRS] bits.

And in your SPI transmit data(SPI0_PUSHR) without any PCS signal was asserted.

I would recommend customer to refer MCUXpresso SDK for K64 [DSPI]->[edma_transfer] as an example:

The demo default path is :

..\SDK_2.2_FRDM-K64F\boards\frdmk64f\driver_examples\dspi\edma_transfer


Have a great day,
Ma Hui

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

0 Kudos
Reply

4,218 Views
mikaelelharrar
Contributor III

It is exactly what I explained you above.

I don't want to trigger the DMA Tx with SPI but with PORTD pin.

And I already checked the examples in MCUXpresso but they are not good for me because minor and major loop are not configurable.

Please see this ticket I opened yesterday to better understand my issue:

https://community.nxp.com/thread/456970 

Thanks

0 Kudos
Reply

4,218 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

I mentioned is the SPI RX to trigger the DMA transfer, not SPI TX.

I checked the SPI register SPI0_RSER, which doesn't enable SPI RX trigger DMA request with [RFDF_RE] & [RFDF_DIRS] bits.


Have a great day,
Ma Hui

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

0 Kudos
Reply

4,218 Views
mikaelelharrar
Contributor III

OK sorry, I will check that.

But anyway, I checked now with a scope the SPI signals, and I don't see the Tx signal and CLK signal at all.

So it seems to be an issue in Tx transfer at the moment.

Have an idea ?

0 Kudos
Reply

4,218 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

I would recommend to refer below documents(software included) about SPI + DMA application:

[Kinetis] DMA-SPI examples for L2K and K60 

https://community.nxp.com/docs/DOC-100304 

Wish it helps.


Have a great day,
Ma Hui

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

0 Kudos
Reply

4,218 Views
mikaelelharrar
Contributor III

The first link is broken.

0 Kudos
Reply

4,218 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Please try the link below:

[Kinetis] DMA-SPI examples for L2K and K60 

I also attached that K60 SPI DMA project here for your reference.

Thank you for the attention.

best regards,

Ma Hui

0 Kudos
Reply

4,218 Views
mikaelelharrar
Contributor III

Hi Hui_Ma,

Please found the copy screen of the register values.

Thanks

DMA_registers_1.PNG

DMA_registers_2.PNG

0 Kudos
Reply

4,218 Views
mikaelelharrar
Contributor III

Hi Ma,

I will send you the registers values.

But could you check please the Tx address and Rx address in functions "_configure_tx_transfer" and "_configure_rx_transfer" ? It is true ?

Thanks

Mikael

0 Kudos
Reply

4,218 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Mikael,

I checked the Tx address and Rx address in functions "_configure_tx_transfer" and "_configure_rx_transfer"  are correct.


Have a great day,
Ma Hui

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

0 Kudos
Reply