SDIO cmd53 without response arrived

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SDIO cmd53 without response arrived

3,477 Views
chaoxu
Contributor I

Hi, Friends. I am working on a project about wifi module rtl8189es. Its interface is sdio specification 2.0. I use NXP KSDK2.0 as reference to write the drive code of rtl8189es. The MCU is MK60DN512ZVLQ10, and the MDK version is V5.17.

   The initialization code of rtl8189es in the main.c file will be shown below. 

 

/* Initialize sdhc pins */
rtl8189es_pin_init();
/* Initialize SDHC Host Configuration. */
sdhcConfig->cardDetectDat3 = false;
sdhcConfig->endianMode = kSDHC_EndianModeLittle;
sdhcConfig->dmaMode = kSDHC_DmaModeAdma2;
sdhcConfig->readWatermarkLevel = 0x10U;
sdhcConfig->writeWatermarkLevel = 0x10U; /* 5 params at total */
SDHC_Init(BOARD_SDHC_BASEADDR, sdhcConfig);
/* Save host information. */
card->host.base = BOARD_SDHC_BASEADDR;
card->host.sourceClock_Hz = GetClock(kCoreClock);
card->host.transfer = SDHC_TransferFunction;
ret = rtl8189es_init(card);

 

   Function SDHC_Init(...) can be seen in sdio.c file, which refers to KSDK 2.0 LIB. And rtl8189es_init(...) is the setup code of rtl8189es. These two functions both works normally. But I have encountered a problem about CMD53. This command is used to read and write multiple I/O registers. My implementation of CMD53 Read is shown below.

 

status_t host_sdio_cmd53_rw(sd_card_t *card, int write, unsigned fn,
                     unsigned addr, int incr_addr, uint32_t *buf, unsigned blocks, unsigned blksz)
{
      assert(card);

      sdhc_transfer_t content = {0};
      sdhc_command_t command = {0};
      sdhc_data_t data = {0};

      command.index = kSDMMC_IoRwExtended;
      command.argument = write ? 0x80000000 : 0x00000000;        --> read 0  /  write 1
      command.argument |= fn << 28;                                                --> function num
      command.argument |= incr_addr ? 0x04000000 : 0x00000000; /* OP code */
      command.argument |= addr << 9;                                              --> register addr
      if(blocks == 1U)
            command.argument |= blksz;                                                --> bytes stream
      else
            command.argument |= 0x08000000 | blocks;                       --> multi-block
      command.responseType = kSDHC_ResponseTypeR5;

      
      data.blockSize = blksz;
      data.blockCount = blocks;
      data.rxData = buf;
      data.txData = NULL;

      content.command = &command;
      content.data = &data;
      if (kStatus_Success != card->host.transfer(card->host.base, &content))         --> call  SDHC_TransferFunction
      {
            LIB_TRACE("cmd53 error\r\n");
            return kStatus_SDMMC_TransferFailed;
      }
      LIB_TRACE("CMD53 resp0 = %x\r\n", command.response[0U]);

      return kStatus_Success;
}

 

When I call the function   "host_sdio_cmd53_rw(card, 0, 0, 0, 1, buffer, 1, 16);",  it will stop at the code which labelled in the red box. Its calling sequence is 

      host_sdio_cmd53_rw --> SDHC_TransferFunction --> SDHC_TransferBlocking -->  SDHC_SetAdmaTableConfig --> 

SDHC_StartTransfer --> SDHC_SendCommandBlocking(IRQSTAT[CC] Command Complete) --> SDHC_TransferDataBlocking --> SDHC_TransferByAdma2Blocking(Transfer not complete)

 

It means that the SDHC host can't receive the data, and the register IRQSTAT[TC] always be zero. In the end the Timeout Error occurs and the transfer is terminated. 

169807_169807.png3.png

the bit 1 of register IRQSTAT as shown below.

169823_169823.png4.png

I have complete the CMD17、24、18、25  for SD memory card , and CMD 52 for SDIO card. However, I fail to complete the CMD53 function. I am trapped in this question for more than 20 days and I need your help. Thx.

Original Attachment has been moved to: sdio.c.zip

Original Attachment has been moved to: sdio_specification.h.zip

Original Attachment has been moved to: sdio.h.zip

Original Attachment has been moved to: rtl8189es.h.zip

Original Attachment has been moved to: rtl8189es.c.zip

Original Attachment has been moved to: main.c.zip

Labels (1)
0 Kudos
0 Replies