DSPI DMA slave on K64

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

DSPI DMA slave on K64

Jump to solution
908 Views
alexfeinman
Contributor III

This is on FRDM-K64 board.

I needed to implement sort of SPI passthrough, so I've used SPI0 for master reads from a peripheral and SPI1 in slave mode to provide data to the external host. For performance reasons I need DMA on both SPI0 and SPI1. However what I found out is that when I call DSPI_DRV_EdmaSlaveTransfer (blocking or non-blocking) and provide say 160 bytes to be transferred, what comes over the wire is 1st byte, followed by the 2nd byte repeated through the rest of the packet. E.g.

0, 1, 2, 3, 4....

will come across as

0, 1, 1, 1, 1, 1...

 

During the same transfer the data comes across just fine in the other direction. So to summarize - on SPI1/2 in DMA slave mode MISO fails but MOSI works.

 

This happens only in DMA mode and only on SPI1 and SPI2. Of course SPI1 and 2 are special on K64 in the sense that they use shared DMA channel for tx/rx. Is there any fix or workaround for this? The issue can be easily replicated by taking DSPI DMA slave sample from the SDK and modifying it to use SPI1 instead of the SPI0

Labels (1)
1 Solution
494 Views
EarlOrlando
Senior Contributor II

Hello again Alex,

Attached you will find a workaround to this issue.

Replace the file fsl_dspi_edma_slave_driver.c which is located at C:\Freescale\KSDK_1.3.0\platform\drivers\src\dspi with the attached version, and then rebuild the platform library (C:\Freescale\KSDK_1.3.0\lib\ksdk_platform_lib\kds\K64F12).

There was a step out of order when configuring the eDMA TX channel that caused the issue. You can locate the changes by searching for the "FIX" comments in the file.

Best regards,

Earl.

/* If this post answers your question please click the Correct Answer button. */

View solution in original post

2 Replies
494 Views
EarlOrlando
Senior Contributor II

Hello Alex,

I recreated the scenario and I got the same issue, by debugging I saw that the DMA TCDs are fulfilled Ok so I don't know where the problem is. If I found this as an issue I will report it to the development team. In the meantime, I will be working to solve the problem or to find a workaround.

If you have any discovering on this please don't hesitate on share it.

Best regards,

Earl Ramírez.

495 Views
EarlOrlando
Senior Contributor II

Hello again Alex,

Attached you will find a workaround to this issue.

Replace the file fsl_dspi_edma_slave_driver.c which is located at C:\Freescale\KSDK_1.3.0\platform\drivers\src\dspi with the attached version, and then rebuild the platform library (C:\Freescale\KSDK_1.3.0\lib\ksdk_platform_lib\kds\K64F12).

There was a step out of order when configuring the eDMA TX channel that caused the issue. You can locate the changes by searching for the "FIX" comments in the file.

Best regards,

Earl.

/* If this post answers your question please click the Correct Answer button. */