Hi Everyone,
I have been struggling with this issue for a week now. I am using the Kinetis K60 evaluation board.
I am able to successfully implement multi-block read using the SDHC controller. The multi-block write fails. I am attaching the piece of code below. The code uses MQX ESDHC driver directly. MFS is not used.
The code is written according to reference manual section "52.6.3.1.1 Normal Write". After issuing CMD25 and writing one block of data, the SD Card status has to be polled. The code fails(hangs monitoring IRQSTAT[CC] to set) when attempting to obtain the SD Card status using SEND_STATUS (CMD13).
Please help,
Thanks,
Harish
/*
* Initialization and identification code
* Setup SD Card in 4 bit mode and set BLOCK_LEN = 512
*/
/* Send CMD25 for multi-block write */
command.COMMAND = ESDHC_CMD25;
command.TYPE = ESDHC_TYPE_NORMAL;
command.ARGUMENT = sector;
command.READ = FALSE;
command.BLOCKS = BLOCK_COUNT;
error_code = ioctl (esdhc_fd, IO_IOCTL_ESDHC_SEND_COMMAND, &command);
if (ESDHC_OK != error_code) { printf("\nioctl send command failed %d", error_code); _task_block (); }
/* Write one block of data */
error_code = fwrite(data_ptr, 1, BLOCK_SIZE, esdhc_fd);
/* Check SD Card status to see if it is ready to receive more data */
command.COMMAND = ESDHC_CMD13;
command.TYPE = ESDHC_TYPE_NORMAL;
command.ARGUMENT = rca;
command.READ = FALSE;
command.BLOCKS = 0;
error_code = ioctl (esdhc_fd, IO_IOCTL_ESDHC_SEND_COMMAND, &command); // HANGS HERE
if (ESDHC_OK != error_code) { printf("ioctl failed with 0x%0x\n", error_code); _task_block (); }