SPI Master Transfer Timing Issue using fsl_spi (KSDK 1.2, KDS 3.0, FRDM-KL25Z)

cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Master Transfer Timing Issue using fsl_spi (KSDK 1.2, KDS 3.0, FRDM-KL25Z)

416 Views
michaellyons
NXP Employee
NXP Employee

Hello,

I'm trying to initialize an SD Card in SPI mode using the fsl_spi module but I am having an issue with how fast I can complete multiple, single-byte transfers.  Below is my test code to see the delay between individual single byte transfers.  Spi clock is 250khz.

 

while(1)    SPI_DRV_MasterTransferBlocking(FSL_SPICOM1, &spiCom1_MasterConfig0, NULL, NULL ,1, 10);

 

When I look at the output on my logic analyzer I see a 156 us delay between consecutive transfers even though I am just repeating the same instruction.  See analyzer snapshot below.

50857_50857.pngpastedImage_0.png

I believe this long delay between transfers might be causing issue in my SD card initialization as I have tested the same hardware with different code on another setup and I have no issue with the SD hardware itself.

 

My questions is: is this how the fsl_spi module is supposed to operate or is there a way to implement consecutive single-byte transfers quicker?

 

Thanks,

Michael

Labels (1)
0 Kudos
2 Replies

185 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Michael,

Is it possible to share your project for a review? Thanks! BTW, why did you set send buffer and receive buffer both NULL? didn't you mean to send or receive some data?


Have a great day,
Kan

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

0 Kudos

185 Views
michaellyons
NXP Employee
NXP Employee

Hi Kan,

I'm not sure how to share my project but if it helps to know there isn't anything else going on.  All I did was loop the transfer function to test the speed which is why both pointers are NULL.  If you don't care what you receive or send you can make both pointers NULL and changing that did not affect the loop speed.  I was able to initialize my SD card after upping the SPI clock to 375khz which reduced the time between transfers to about 60 us.  I just find it odd that I can't initialize with the slower speed even though I have verified it is indeed possible to initialize an SD card at 250khz using a different system.  I also can't explain why changing SPI clock from 250khz->375khz changed the delay in the loop from 150 us -> 60 us.  Not sure if that is a bug or what, if I have more time I will compare my results to a bare metal setup but I would rather keep working with ksdk.

Thanks,

Michael

0 Kudos