The SD card question of KSDK_1.3.0 in the K64

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

The SD card question of KSDK_1.3.0 in the K64

467 Views
小勇邹
Contributor II

The library KSDK_1.3.0\lib\ksdk_platform_lib\iar\K64F12 is used in my application.

 

My source code is written accordding to the example.Please re

C:\Freescale\KSDK_1.3.0\examples\twrk64f120m\driver_examples\sdhc_sdcard\iar.

 

Because the micro SD card is used in my product. The hardware is a little different from the twrk64120m.

 

The hardware in my product.

136600_136600.pngpastedImage_0.png

 

The hardware in the twrk64120m.

136604_136604.pngpastedImage_1.png

 

The micro SD HC Kingston 32GB(the type:SDC 10/32GB 31497-005.A00LF)  is used in my product.

 

I try to access the SD card in the source code.

When I debug in the source code,

The error happens in the function

“SDCARD_DRV_SwitchHighspeed(card)——>

SDCARD_DRV_Switch(card,kSdSwitchSet, 0, 1, response);”

 

The function “SDCARD_DRV_Switch” is always failed.

 

But the other micro SD HC card 4GB(the type:4/4GB) works normally in my source code.

 

Can you tell me what is the reason??

Original Attachment has been moved to: The-SD-source-code.zip

Labels (1)
0 Kudos
1 Reply

227 Views
isaacavila
NXP Employee
NXP Employee

Hello Robin,

During SD Card initialization, Driver sends commands using a default speed, after this initialization, Host can change this speed (if this capability is supported on SD) and communication should work the same, in this case, it seems there is a problem at the moment you are changing this speed.

In SDCARD_DRV_SwitchHighspeed function (located at fsl_sdhc_card.c file), first you check if this instruction is supported:

    err = SDCARD_DRV_Switch(card, kSdSwitchCheck, 0, 1, response);

    if (err)

    {

        return err;

    }

    if ((!(swap_be32(response[3]) & 0x10000)) ||

        ((swap_be32(response[4]) & 0x0f000000) == 0x0F000000))

    {

        return kStatus_SDHC_CardNotSupport;

    }

If program passes this point, it seems that SD card does support this command (modify the transfer speed). In the second part of this function, this "set speed command" is sent and it can fail due no response is received or response returns an error on setting this command.

So you should see if error is caused due no response is received (SDCARD_DRV_Switch returns a kStatus_SDHC_RequestFailed) or response does not have the 0x01000000 bit set.

Please, check which error is received.

About your hardware and the one in TWR-K64, example does enable internal pull-up resistors for every pin:

void configure_sdhc_pins(uint32_t instance)

{

  /* Affects PORTE_PCR3 register */

  PORT_HAL_SetMuxMode(PORTE,3u,kPortMuxAlt4);

  PORT_HAL_SetPullMode(PORTE,3u,kPortPullUp);

  PORT_HAL_SetPullCmd(PORTE,3u,true);

  PORT_HAL_SetDriveStrengthMode(PORTE,3u,kPortHighDriveStrength);

  /* Affects PORTE_PCR1 register */

  PORT_HAL_SetMuxMode(PORTE,1u,kPortMuxAlt4);

  PORT_HAL_SetPullMode(PORTE,1u,kPortPullUp);

  PORT_HAL_SetPullCmd(PORTE,1u,true);

  PORT_HAL_SetDriveStrengthMode(PORTE,1u,kPortHighDriveStrength);

  /* Affects PORTE_PCR0 register */

  PORT_HAL_SetMuxMode(PORTE,0u,kPortMuxAlt4);

  PORT_HAL_SetPullMode(PORTE,0u,kPortPullUp);

  PORT_HAL_SetPullCmd(PORTE,0u,true);

  PORT_HAL_SetDriveStrengthMode(PORTE,0u,kPortHighDriveStrength);

  /* Affects PORTE_PCR5 register */

  PORT_HAL_SetMuxMode(PORTE,5u,kPortMuxAlt4);

  PORT_HAL_SetPullMode(PORTE,5u,kPortPullUp);

  PORT_HAL_SetPullCmd(PORTE,5u,true);

  PORT_HAL_SetDriveStrengthMode(PORTE,5u,kPortHighDriveStrength);

  /* Affects PORTE_PCR4 register */

  PORT_HAL_SetMuxMode(PORTE,4u,kPortMuxAlt4);

  PORT_HAL_SetPullMode(PORTE,4u,kPortPullUp);

  PORT_HAL_SetPullCmd(PORTE,4u,true);

  PORT_HAL_SetDriveStrengthMode(PORTE,4u,kPortHighDriveStrength);

  /* Affects PORTE_PCR2 register */

  PORT_HAL_SetMuxMode(PORTE,2u,kPortMuxAlt4);

  PORT_HAL_SetPullMode(PORTE,2u,kPortPullUp);

  PORT_HAL_SetPullCmd(PORTE,2u,true);

  PORT_HAL_SetDriveStrengthMode(PORTE,2u,kPortHighDriveStrength);

}

So you have two pull-up resistors (one internal and other external), so please, disable this internal pull-ups to discard this can be causing the failure.

I hope this can help you!

Best Regards,

Isaac Avila

0 Kudos