<?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>LPC Microcontrollersのトピックperiph_sdmmc failed with SD</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/periph-sdmmc-failed-with-SD/m-p/686894#M27677</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ran periph_sdmmc of LPCOpen v2.10 on an Embedded Artists OEM Base Board with an LPC4088 OEM Board. It worked fine with a version 2 SD card after I reversed the polarity of MCIPWR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I replaced the SD card with a version 1 SD card, all the disk operations returned a "Failed with rc=1".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I traced the problem to&amp;nbsp;sendAppOpCond() in sdmmc_17xx_40xx.c that returned a "SDC_RET_FAILED". The comment of the code said that the host repeatedly issues ACMD41 for at least 1 second (8192 tries). But the code bailed after the first sendAppCmd() call that failed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I commented out the else block of the "if (Ret == SDC_RET_OK)". During the second iteration of the while loop, the calls to&amp;nbsp;sendAppCmd() and&amp;nbsp;executeCmd() both returned&amp;nbsp;SDC_RET_OK. And the rest of the tests ran without failure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am wondering whether I did the right thing to fix the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;STATIC int32_t sendAppOpCond(LPC_SDC_T *pSDC, uint16_t rca, bool hcs, uint32_t *pOcr, bool *pCCS)
{
 int32_t Ret = SDC_RET_FAILED;
 SDC_RESP_T Response;
 uint32_t Argument;
 uint32_t RetryCnt = 0x2000; /* The host repeatedly issues ACMD41 for at least 1 second or
 until the busy bit are set to 1 */

 Argument = ACMD41_OCR(*pOcr);
 if (hcs) {
 Argument |= ACMD41_HCS;
 }

 while (RetryCnt &amp;gt; 0) {
 Ret = sendAppCmd(pSDC, rca);
 if (Ret == SDC_RET_OK) {
 Ret = executeCmd(pSDC, SD_ACMD41_SD_SEND_OP_COND, Argument, &amp;amp;Response);
 if (Ret == SDC_RET_OK) {
 if (Response.Data[0] &amp;amp; CMDRESP_R3_INIT_COMPLETE) {
 if (*pOcr == 0) {
 *pOcr = CMDRESP_R3_OCR_VAL(Response.Data[0]);
 return SDC_RET_OK;
 }
 if ((CMDRESP_R3_OCR_VAL(Response.Data[0]) &amp;amp; *pOcr) != *pOcr) {
 return SDC_RET_BAD_PARAMETERS;
 }
 *pCCS = (Response.Data[0] &amp;amp; CMDRESP_R3_HC_CCS) ? true : false;
 return SDC_RET_OK;
 }
 }
 }
// else {
// return Ret;
// }
 RetryCnt--;
 }
 return SDC_RET_FAILED;
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Jul 2017 21:32:24 GMT</pubDate>
    <dc:creator>schen</dc:creator>
    <dc:date>2017-07-06T21:32:24Z</dc:date>
    <item>
      <title>periph_sdmmc failed with SD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/periph-sdmmc-failed-with-SD/m-p/686894#M27677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ran periph_sdmmc of LPCOpen v2.10 on an Embedded Artists OEM Base Board with an LPC4088 OEM Board. It worked fine with a version 2 SD card after I reversed the polarity of MCIPWR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I replaced the SD card with a version 1 SD card, all the disk operations returned a "Failed with rc=1".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I traced the problem to&amp;nbsp;sendAppOpCond() in sdmmc_17xx_40xx.c that returned a "SDC_RET_FAILED". The comment of the code said that the host repeatedly issues ACMD41 for at least 1 second (8192 tries). But the code bailed after the first sendAppCmd() call that failed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I commented out the else block of the "if (Ret == SDC_RET_OK)". During the second iteration of the while loop, the calls to&amp;nbsp;sendAppCmd() and&amp;nbsp;executeCmd() both returned&amp;nbsp;SDC_RET_OK. And the rest of the tests ran without failure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am wondering whether I did the right thing to fix the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;STATIC int32_t sendAppOpCond(LPC_SDC_T *pSDC, uint16_t rca, bool hcs, uint32_t *pOcr, bool *pCCS)
{
 int32_t Ret = SDC_RET_FAILED;
 SDC_RESP_T Response;
 uint32_t Argument;
 uint32_t RetryCnt = 0x2000; /* The host repeatedly issues ACMD41 for at least 1 second or
 until the busy bit are set to 1 */

 Argument = ACMD41_OCR(*pOcr);
 if (hcs) {
 Argument |= ACMD41_HCS;
 }

 while (RetryCnt &amp;gt; 0) {
 Ret = sendAppCmd(pSDC, rca);
 if (Ret == SDC_RET_OK) {
 Ret = executeCmd(pSDC, SD_ACMD41_SD_SEND_OP_COND, Argument, &amp;amp;Response);
 if (Ret == SDC_RET_OK) {
 if (Response.Data[0] &amp;amp; CMDRESP_R3_INIT_COMPLETE) {
 if (*pOcr == 0) {
 *pOcr = CMDRESP_R3_OCR_VAL(Response.Data[0]);
 return SDC_RET_OK;
 }
 if ((CMDRESP_R3_OCR_VAL(Response.Data[0]) &amp;amp; *pOcr) != *pOcr) {
 return SDC_RET_BAD_PARAMETERS;
 }
 *pCCS = (Response.Data[0] &amp;amp; CMDRESP_R3_HC_CCS) ? true : false;
 return SDC_RET_OK;
 }
 }
 }
// else {
// return Ret;
// }
 RetryCnt--;
 }
 return SDC_RET_FAILED;
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jul 2017 21:32:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/periph-sdmmc-failed-with-SD/m-p/686894#M27677</guid>
      <dc:creator>schen</dc:creator>
      <dc:date>2017-07-06T21:32:24Z</dc:date>
    </item>
  </channel>
</rss>

