anguel

High-speed SDHC = LDD_SDHC_ERR_TIMEOUT

Discussion created by anguel on Jun 26, 2013
Latest reply on Jul 1, 2013 by anguel

Hi!

 

I am referring to the TWR-K70 SDHC processor expert demo project found in C:\Freescale\CW MCU v10.4\MCU\CodeWarrior_Examples\Processor_Expert\Kinetis\TWR-K70FN1M\SDHC. I have also adapted the project to my Kwikstik (K40). The demo project writes and then reads fine at 25 MHz on Kwikstik (K40) and at 15 MHz on TWR-K70, these MHz values are dictated by the main clocks of the boards.

 

My SD card is reported as high speed so I tried to go high speed, i.e. to 50 MHz on Kwikstik and 30 MHz on TWR-K70 by using the SDHC_SelectBusClock() method as described in the SDHC LDD component help. This method seems to setup the device to high speed without errors. But then I get “ERROR Command or data timeout” (LDD_SDHC_ERR_TIMEOUT) which is returned by the SDHC_GetError() method called in the SD_Wait() method which is called right after SDHC_TransferBlocks() which is called by SD_TransferBlock() with WRITE parameter called by SD_WriteBlockPart().

 

The error code is set in the following code in SDHC.c:

  /* Map host error flags to component error codes */

  if ((Flags & (SDHC_PDD_COMMAND_TIMEOUT_ERROR_INT | SDHC_PDD_DATA_TIMEOUT_ERROR_INT)) ||

      ((Flags & SDHC_PDD_AUTO_CMD12_ERROR_INT) && (AutoCMD12ErrorFlags & SDHC_PDD_AUTO_CMD12_TIMEOUT_ERROR))) {

    Error = LDD_SDHC_ERR_TIMEOUT;

 

The SDHC_IRQSTAT bits that get set when the error occurs are bit 16 = CTOE (Command Timeout Error) and bit 0 = CC (Command Complete). According to the Kinetis K40 guide and some guessing this may identify a CMD line conflict which I expect to be caused by the higher bus speed.

 

I also found out that if I run the writing part of the demo in a loop at 30 MHz on TWR-K70 the error does not occur each time, but in most cases it does. If I run the demo at 50 MHz on the Kwikstik the error always occurs. The strange thing is that although this error occurs, the test data (I vary this inside my loop) can be successfully written to and then read from the SD card as far as I can see.

 

The only hint I found was that the code comments in the SDHC LDD help say that FAST slew rate should be set on all SDHC pins. It turns out that fast slew rate seems to be the default setting for Kinetis, I also set it through the Init_GPIO component. Unfortunately, this did not help at all.

 

Has someone achieved speeds higher than 25 MHz with Kinetis MCUs? I don't know where to look for the cause of the timeout error. Any hints are welcome!

 

Regards,

Anguel

Outcomes