AnsweredAssumed Answered

Problems with K22 DSPI with EDMA for SD Card Access

Question asked by Myke Predko on Jan 13, 2016
Latest reply on Mar 28, 2016 by Myke Predko



I'm working on a K22F product design that accesses SD Cards using the SPI interface.  I'm using the FRDM-K22F for prototyping and will move to the MK22FN128VLH10 when I'm satisfied with the software operation. 


I'm using a basic FRDM-K22F with the following modifications:

1.  Added a Molex 1050270001 uSD Card connector to the FRDM board (this, by the way shouldn't be attempted without the proper tools, it really is a bitch to put on if you don't have a hot air rework tool). 

2.  Removed R52 & R55 to ensure any spurious interrupts from U8 don't affect DSPI operation. 


Development tools are:

- KDS 3.1

- KSDK 1.3

- PE 3.02

and I have installed the latest release of the MCUonEclipse ( for the "Wait" function. 


I have attached the current version of my software which uses the "fsl_dspi" set up (which automagically brings in "fsl_edma" as a referenced component) and I am attempting to first put the SD Card into an idle state ("CMD0") and then a test to see if the SD Card is high capacity (send a "CMD8" query).  I have enabled the "Slave" Component but I have not clicked on "Install interrupts" (which, reading below, I wonder is if that is my issue). 


With the current software, the CMD0 is sent repeatedly until the SD Card (if present) wakes up and responds.  To follow the spec properly, I need to send 74+ clock signals with !CS and SOUT high, but I can't figure out how to do that with the DSPI module setup by PE.  If you look at the attached code, you'll see that I tried to setup the DSPI IO pins as GPIOs before the DSPI operations as well as just send 0xFF's) but in both cases, the operation failed. 


The repeated CMD0 (without the initial clocks) seems to wake up the card and place it in idle state seems to be working well, BUT only the first byte is read back during the SPI transfer - the second byte has the status information, but is not being read, as is the subsequent four bytes of the transfer which are not being passed to the receive buffer.  Subsequent SPI transfers do not seem to execute (I don't see them on my 'scope). 


I'm comparing my code to the example application "dspi_edma_non_blocking_example_master_frdmk22f" and the only difference I see is that the example application has (system generated?) "fsl_dspi_edma_irq.c" and "fsl_edma_irq.c" files.  I'm also going through 13.9 of the KSDK 1.3 API Reference and while there is a reference to the two "...irq.c".  The next test, I will try to "install interrupts" to see if there is a change in operation by doing that. 


So, my questions are:

1.  Has anybody successfully gotten SD Card IO working with the K22F and it's DSPI port?  This seems to have been successful with the K64F, but I can't find any examples with the K22F - Is this why the Molex SD Card connector ISN'T attached to the FRDM-K22F? 

1.  How can I send the 74+ clock signals with !CS and SOUT high before sending the CMD0? 

2.  Why am I only getting one byte back on the EDMA read?  I suspect that lack of interrupt handlers is the issue but the process to correctly setup dspi with edma using PE doesn't seem to be documented. 


Thanx for your help!



Original Attachment has been moved to: