<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic SPI SD card interface via fsl_sdcard component in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-SD-card-interface-via-fsl-sdcard-component/m-p/443862#M26145</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to do a basic read/write on an SD card interfaced to my KL46Z256VLL4 eval board via SPI. I'm using the fsl_sdcard and the fsl_spi components to read/write from/to the SD card.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the SDSPI_DRV_Init and SDSPI_DRV_Write functions of the fsl_sdcard component to attempt to write data to the SD card:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;&amp;nbsp; SDSPI_DRV_Init(&amp;amp;memoryCard1_spi_state, &amp;amp;memoryCard1_state); &amp;nbsp; SDSPI_DRV_WriteBlocks(&amp;amp;memoryCard1_spi_state, &amp;amp;memoryCard1_state, "test", 0, 1); &amp;nbsp; debug_getchar();&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, nothing seems to happen. Upon closer inspection with a logic analyzer, I noticed there's no activity at all on the SPI pins. I then dig into the component files and see the lower level SPI functions (spiSendWord, spiExchange, etc.) are not implemented within "spi_dspi_layer.c". Am I responsible for implementing that portion of the SPI interface?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Excerpt of spi_dspi_layer.c:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;/**&amp;nbsp;&amp;nbsp; * Function sets required speed of SPIx/DSPI&amp;nbsp; */ uint32_t SetSpiFrequency(sdspi_spi_t *spi, uint32_t frequency) { &amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t calculatedBaudRate = 0x00; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /* User Code: Calling of the SPI/DSPI method that provides setting of SPI/DSPI transfer speed */ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (calculatedBaudRate == 0x00) &amp;nbsp;&amp;nbsp;&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0x01; &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; return 0x00; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&amp;nbsp;&amp;nbsp; * Function performs transmission of the input data buffer via SPIx/DSPI&amp;nbsp; */ uint32_t spiExchange(sdspi_spi_t *spi, const uint8_t *in, uint8_t *out, uint32_t size) { &amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t result = 0x00; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /* User Code: Calling of the SPI/DSPI method that provides blocking transfer over SPI/DSPI */ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return result; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&amp;nbsp;&amp;nbsp; * Function performs transmission of the input byte&amp;nbsp; */ uint8_t spiSendWord(sdspi_spi_t *spi, uint8_t word) { &amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t result = 0x00; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /* User Code: Calling of the SPI/DSPI method that provides blocking transfer of 1B over SPI/DSPI */ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return result; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="36580_36580.png"&gt;&lt;IMG alt="36580_36580.png" src="https://community.nxp.com/t5/image/serverpage/image-id/120385i90AC5D87991F6BEF/image-size/large?v=v2&amp;amp;px=999" title="36580_36580.png" /&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_5.png"&gt;&lt;IMG alt="pastedImage_5.png" src="https://community.nxp.com/t5/image/serverpage/image-id/23156iDF7A1F7EBEA1A26A/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_5.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-337619" rel="noopener noreferrer" target="_blank"&gt;SDRawWrite.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2020 13:21:51 GMT</pubDate>
    <dc:creator>fnaeem</dc:creator>
    <dc:date>2020-11-02T13:21:51Z</dc:date>
    <item>
      <title>SPI SD card interface via fsl_sdcard component</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-SD-card-interface-via-fsl-sdcard-component/m-p/443862#M26145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to do a basic read/write on an SD card interfaced to my KL46Z256VLL4 eval board via SPI. I'm using the fsl_sdcard and the fsl_spi components to read/write from/to the SD card.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the SDSPI_DRV_Init and SDSPI_DRV_Write functions of the fsl_sdcard component to attempt to write data to the SD card:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;&amp;nbsp; SDSPI_DRV_Init(&amp;amp;memoryCard1_spi_state, &amp;amp;memoryCard1_state); &amp;nbsp; SDSPI_DRV_WriteBlocks(&amp;amp;memoryCard1_spi_state, &amp;amp;memoryCard1_state, "test", 0, 1); &amp;nbsp; debug_getchar();&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, nothing seems to happen. Upon closer inspection with a logic analyzer, I noticed there's no activity at all on the SPI pins. I then dig into the component files and see the lower level SPI functions (spiSendWord, spiExchange, etc.) are not implemented within "spi_dspi_layer.c". Am I responsible for implementing that portion of the SPI interface?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Excerpt of spi_dspi_layer.c:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;/**&amp;nbsp;&amp;nbsp; * Function sets required speed of SPIx/DSPI&amp;nbsp; */ uint32_t SetSpiFrequency(sdspi_spi_t *spi, uint32_t frequency) { &amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t calculatedBaudRate = 0x00; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /* User Code: Calling of the SPI/DSPI method that provides setting of SPI/DSPI transfer speed */ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (calculatedBaudRate == 0x00) &amp;nbsp;&amp;nbsp;&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0x01; &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; return 0x00; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&amp;nbsp;&amp;nbsp; * Function performs transmission of the input data buffer via SPIx/DSPI&amp;nbsp; */ uint32_t spiExchange(sdspi_spi_t *spi, const uint8_t *in, uint8_t *out, uint32_t size) { &amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t result = 0x00; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /* User Code: Calling of the SPI/DSPI method that provides blocking transfer over SPI/DSPI */ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return result; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&amp;nbsp;&amp;nbsp; * Function performs transmission of the input byte&amp;nbsp; */ uint8_t spiSendWord(sdspi_spi_t *spi, uint8_t word) { &amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t result = 0x00; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /* User Code: Calling of the SPI/DSPI method that provides blocking transfer of 1B over SPI/DSPI */ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return result; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="36580_36580.png"&gt;&lt;IMG alt="36580_36580.png" src="https://community.nxp.com/t5/image/serverpage/image-id/120385i90AC5D87991F6BEF/image-size/large?v=v2&amp;amp;px=999" title="36580_36580.png" /&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_5.png"&gt;&lt;IMG alt="pastedImage_5.png" src="https://community.nxp.com/t5/image/serverpage/image-id/23156iDF7A1F7EBEA1A26A/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_5.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-337619" rel="noopener noreferrer" target="_blank"&gt;SDRawWrite.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:21:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-SD-card-interface-via-fsl-sdcard-component/m-p/443862#M26145</guid>
      <dc:creator>fnaeem</dc:creator>
      <dc:date>2020-11-02T13:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: SPI SD card interface via fsl_sdcard component</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-SD-card-interface-via-fsl-sdcard-component/m-p/443863#M26146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Farhan Naeem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, you need to add the SPI driver methods, but you can use the configuration and methods of the inherited &lt;STRONG&gt;fsl_spi&lt;/STRONG&gt;​ compoment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The next files in KSDK installation might serve you as reference on how to implement those calls:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C:\Freescale\KSDK_1.2.0\middleware\filesystem\fatfs\fsl_sd_disk\src\&lt;STRONG&gt;fsl_sdspi_disk.c&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;C:\Freescale\KSDK_1.2.0\platform\composite\inc\&lt;STRONG&gt;fsl_sdcard_spi.h&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;C:\Freescale\KSDK_1.2.0\platform\composite\src\sdcard\&lt;STRONG&gt;fsl_sdcard_spi.c&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Jorge Gonzalez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2015 21:35:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-SD-card-interface-via-fsl-sdcard-component/m-p/443863#M26146</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2015-06-25T21:35:03Z</dc:date>
    </item>
  </channel>
</rss>

