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