<?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 Re: sdhc_drv_init() fail? in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416600#M23710</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was pulled away from this project for a while, but I'm back on it now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since my original post, I have attended FTF 2015, switched from KDS 2.0 to KDS 3.0, and switched from KSDK 1.1 to KSDK 1.2.&amp;nbsp; I built a new project hoping the bug was fixed, but it's still there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My original post implied that the problem only appeared when the board was first "powered up."&amp;nbsp; I have done a lot more investigating since, and I don't believe that's a true statement.&amp;nbsp; I do believe the problem presents itself when the code is launched with the OpenSDA debugger.&amp;nbsp; Every time I launch the program with the debugger, the SD card driver fails to initialize.&amp;nbsp; It returns an error code 3, which fsl_sdhc_driver.h enumerates as kStatus_SDHC_SetCardToIdle&amp;nbsp; /*!&amp;lt; Failed to set card to idle */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I then hit the reset button, it works.&amp;nbsp; If I power cycle the board, it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only way I can get it to work with the debugger is to shutdown the SDHC driver, reinitialize it and then reinitialize the SDCARD driver (as shown in the original post).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Audi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 Aug 2015 19:31:15 GMT</pubDate>
    <dc:creator>audi_mcavoy</dc:creator>
    <dc:date>2015-08-04T19:31:15Z</dc:date>
    <item>
      <title>sdhc_drv_init() fail?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416592#M23702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My 2GB Transcan microSD card does not initialize correctly when my FRD-K64F is powered up.&amp;nbsp; Only after pressing the reset button is the card accessible.&amp;nbsp; Well, almost "only."&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using KDS, I have created a simple app based on the FRDM-K64F with PE and KSDK support.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using PE, I added &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;a debug console (debug_console), a memory card (fsl_sdcard) and a GPIO pin (fsl_gpio) to my project.&amp;nbsp; The memory card is setup for 4-bit access, and the GPIO pin is setup as a card detect input.&amp;nbsp; Everything is configured from the FRDM-K64F schematic.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On power up, the blocksize member in my sdhc_card_t structure is "0" (in fact, all members appear to be zeroed), and the card is not accessible.&amp;nbsp; Pressing the reset button then initializes the card structure, and everything works as expected.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also found that shutting down the SDHC driver, then reinitializing the SDHC and the SDCARD drivers "fixes" the problem.&amp;nbsp; Like this. . .&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;if (0 == memoryCard1_state.blockSize) { #if 0 &amp;nbsp; SDCARD_DRV_Shutdown(&amp;amp;memoryCard1_state); #endif&amp;nbsp; &amp;nbsp; SDHC_DRV_Shutdown(FSL_FSL_SDHC1);&amp;nbsp; &amp;nbsp; if (kStatus_SDHC_NoError != SDHC_DRV_Init(FSL_FSL_SDHC1, &amp;amp;fsl_sdhc1_host, &amp;amp;fsl_sdhc1_InitConfig0)) { &amp;nbsp;&amp;nbsp;&amp;nbsp; printf("SDHC_DRV_Init() error\r\n"); &amp;nbsp;&amp;nbsp;&amp;nbsp; return false; &amp;nbsp; }&amp;nbsp; &amp;nbsp; if (kStatus_SDHC_NoError != SDCARD_DRV_Init(&amp;amp;fsl_sdhc1_host, &amp;amp;memoryCard1_state)) { &amp;nbsp;&amp;nbsp;&amp;nbsp; printf("SDCARD_DRV_Init() error\r\n"); &amp;nbsp;&amp;nbsp;&amp;nbsp; return false; &amp;nbsp; }&amp;nbsp; &amp;nbsp; if (0 == memoryCard1_state.blockSize) return false; } return true;&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;Notice that calling SDCARD_DRV_Shutdown() hung the processor.&amp;nbsp; On the other hand, not calling SDHC_DRV_Shutdown() followed by SDHC_DRV_Init() was not sufficient to restore SD card access.&amp;nbsp; Also, calling &lt;SPAN style="font-size: 13.3333330154419px;"&gt;SDHC_DRV_Init() without first calling &lt;SPAN style="font-size: 13.3333330154419px;"&gt;SDHC_DRV_Shutdown() was problematic.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached my project.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any suggestions?&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-337601" rel="nofollow noopener noreferrer" target="_blank"&gt;sdcard_test.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 16:14:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416592#M23702</guid>
      <dc:creator>audi_mcavoy</dc:creator>
      <dc:date>2015-04-16T16:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: sdhc_drv_init() fail?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416593#M23703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I moved your thread to the correct place.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vicente&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2015 19:41:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416593#M23703</guid>
      <dc:creator>vicentegomez</dc:creator>
      <dc:date>2015-05-04T19:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: sdhc_drv_init() fail?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416594#M23704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Audi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I recommend you test the SD demo under KSDK (...\KSDK_1.1.0\demos\sdhc_sdcard) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 01:56:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416594#M23704</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2015-05-05T01:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: sdhc_drv_init() fail?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416595#M23705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep.&amp;nbsp; Did that first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Most of my (SD) code was copy/paste from there.&lt;/P&gt;&lt;P&gt;- am&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 18:35:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416595#M23705</guid>
      <dc:creator>audi_mcavoy</dc:creator>
      <dc:date>2015-05-05T18:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: sdhc_drv_init() fail?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416596#M23706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See whether you get the same behaviour with a FRDM-K64F binary from: &lt;A href="http://www.utasker.com/kinetis/FRDM-K64F.html" title="http://www.utasker.com/kinetis/FRDM-K64F.html"&gt;µTasker Kinetis FRDM-K64F support&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kinetis: &lt;A href="http://www.utasker.com/kinetis.html" title="http://www.utasker.com/kinetis.html"&gt;µTasker Kinetis support&lt;/A&gt;&lt;/P&gt;&lt;P&gt;K64: &lt;A href="http://www.utasker.com/kinetis/FRDM-K64F.html" title="http://www.utasker.com/kinetis/FRDM-K64F.html"&gt;µTasker Kinetis FRDM-K64F support&lt;/A&gt; / &lt;A href="http://www.utasker.com/kinetis/TWR-K64F120M.html" title="http://www.utasker.com/kinetis/TWR-K64F120M.html"&gt;µTasker Kinetis TWR-K64F120M support&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;For the complete "out-of-the-box" Kinetis experience and faster time to market &lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 21:51:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416596#M23706</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2015-05-05T21:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: sdhc_drv_init() fail?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416597#M23707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Audi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have test your project on my side , and it can work well , the screenshot below is the information on hyperterminal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/49878i2EB74D70632BCC2C/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does i misunderstand your question ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 09:38:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416597#M23707</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2015-05-06T09:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: sdhc_drv_init() fail?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416598#M23708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you solved?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found out that some SDCards need some time to "wakeup" when first powered, so in my project I wait 1 second before trying to initialize the SDHC driver, and it always work.&lt;/P&gt;&lt;P&gt;If I don't wait, depending on the sdcard sometime it work, sometime I have the same behaviour as you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Giacomo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 14:19:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416598#M23708</guid>
      <dc:creator>giacomopetrini</dc:creator>
      <dc:date>2015-05-06T14:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: sdhc_drv_init() fail?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416599#M23709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Giacomo, I have not found a solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have also noticed that some SD cards need a few seconds to "wake up."&amp;nbsp; I did try putting in some different delays in different locations; but, nothing made a difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the suggestion though.&lt;/P&gt;&lt;P&gt;- Audi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 19:11:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416599#M23709</guid>
      <dc:creator>audi_mcavoy</dc:creator>
      <dc:date>2015-08-04T19:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: sdhc_drv_init() fail?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416600#M23710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was pulled away from this project for a while, but I'm back on it now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since my original post, I have attended FTF 2015, switched from KDS 2.0 to KDS 3.0, and switched from KSDK 1.1 to KSDK 1.2.&amp;nbsp; I built a new project hoping the bug was fixed, but it's still there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My original post implied that the problem only appeared when the board was first "powered up."&amp;nbsp; I have done a lot more investigating since, and I don't believe that's a true statement.&amp;nbsp; I do believe the problem presents itself when the code is launched with the OpenSDA debugger.&amp;nbsp; Every time I launch the program with the debugger, the SD card driver fails to initialize.&amp;nbsp; It returns an error code 3, which fsl_sdhc_driver.h enumerates as kStatus_SDHC_SetCardToIdle&amp;nbsp; /*!&amp;lt; Failed to set card to idle */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I then hit the reset button, it works.&amp;nbsp; If I power cycle the board, it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only way I can get it to work with the debugger is to shutdown the SDHC driver, reinitialize it and then reinitialize the SDCARD driver (as shown in the original post).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Audi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 19:31:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416600#M23710</guid>
      <dc:creator>audi_mcavoy</dc:creator>
      <dc:date>2015-08-04T19:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: sdhc_drv_init() fail?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416601#M23711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alice,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you get it to work from KDS with the OpenSDA debugger?&amp;nbsp; Or did you drag/drop onto the mbed drive?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 19:34:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416601#M23711</guid>
      <dc:creator>audi_mcavoy</dc:creator>
      <dc:date>2015-08-04T19:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: sdhc_drv_init() fail?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416602#M23712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In case this is relevant:&lt;/P&gt;&lt;P&gt;I faced several problems with SD cards and power consumption of them on the FRDM-K64F board: some SD-cards drain several hundreds of milli-Amps when inserted or powered up. And the 5V to 3.3V DC-DC converter was not able to power all the devices on the board (K20, K64F plus the SD card).&lt;/P&gt;&lt;P&gt;So is this problem only happening if you have the SD card inserted at power-up time?&lt;/P&gt;&lt;P&gt;Our solution was to use industrial grade SD cards which had a much better (lower) power-up current consumption.&lt;/P&gt;&lt;P&gt;Or you might backup the 3.3V on the header with some more milli-amps. You might be able to measure a power drop on the 3.3V too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this might be useful,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 19:53:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/sdhc-drv-init-fail/m-p/416602#M23712</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2015-08-04T19:53:35Z</dc:date>
    </item>
  </channel>
</rss>

