Hi there,
I need some advice. I am trying to use a SD card on a MicroZed board. The board is loaded with a bare bones Zynq processor system all configured as per the board support package defaults. I have booted linux on this board from that card before so know it is electrically all OK. I am now just working on a basic SD card read and write using the Xilinx driver, no file system at this stage. The code I am using is:
XSdPs_Config * sd0Cfg = XSdPs_LookupConfig(XPAR_PS7_SD_0_DEVICE_ID);//XPAR_PS7_SD_0_BASEADDR
int err = XSdPs_CfgInitialize(&sd0Inst, sd0Cfg, sd0Cfg->BaseAddress);
if(err == XST_SUCCESS)
{
err = XSdPs_SdCardInitialize(&sd0Inst);
if(err == XST_SUCCESS)
{
err = XSdPs_ReadPolled(&sd0Inst, 1, 1, buf);
}
}
The problem I have is that XSdPs_SdCardInitialize fails UNLESS I step through it where it passes. The problem happens somewhere in this code of XSdPs_SdCardInitialize:
/*
* Send ACMD41 while card is still busy with power up
*/
while ((RespOCR & XSDPS_RESPOCR_READY) == 0) {
Status = XSdPs_CmdTransfer(InstancePtr, CMD55, 0, 0);
if (Status != XST_SUCCESS) {
Status = XST_FAILURE;
goto RETURN_PATH;
}
/*
* 0x40300000 - Host High Capacity support & 3.3V window
*/
Status = XSdPs_CmdTransfer(InstancePtr, ACMD41,
(XSDPS_ACMD41_HCS | XSDPS_ACMD41_3V3), 0);
if (Status != XST_SUCCESS) {
Status = XST_FAILURE;
goto RETURN_PATH;
}
/*
* Response with card capacity
*/
RespOCR = XSdPs_ReadReg(InstancePtr->Config.BaseAddress,
XSDPS_RESP0_OFFSET);
}
If I allow the processor to run to the first line of this code, then single step through it, then run again it succeeds! It seems the only way it can fail is if one of the calls to XSdPs_CmdTransfer fails. Not sure why they fail at full speed but OK on single stepping.
I have also tried changing the clock frequency to 25MHz and changing the pins slew rate to fast. With the clock frequency the SD Init function seems to pass most times but the SD read function still fails every time.
Any advice would be greatly appreciated. I will add any other information required if you ask.
Thanks