According to the specification, illegal commands are not responded to. The flag is set and sent with the next valid command. Therefore the illegal command may be the CMD1 sent at the end of card detection (which should be ignored by SD cards). Please, could you try the following workaround:
- Turn off SDHC code generation (rigth click on the SDHC component in the project panel, select Code generation/Don't write generated...).
- In the generated SDHC module, in the CardRegistration function, in the top level switch (DeviceDataPrv->Substate), case ..._CR_FINISH (probably the last), replace the whole switch (DeviceDataPrv->CardType) by the following code:
DeviceDataPrv->State = LDD_SDHC_VOLTAGE_VALIDATION;
DeviceDataPrv->Substate = SDHC1_VV_FINISH;
VoltageValidation(DeviceDataPrv, 0U, SDHC1_NO_RESPONSE);
- Few lines above this code, there should be the comment /* Start the registration of the next card */. Below this comment correct the following line (replace the red text by the blue text):
DeviceDataPrv->Substate = SDHC1_CR_START_FINISH;
CardRegistration(DeviceDataPrv, 0U, SDHC1_NO_RESPONSE);
If you make these changes, the last command sent before CMD7 should be CMD3. This does not affect the functionality in the case you have only one card slot connected to the SDHC bus.