This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

mmc-f2837x.c driver issue

Other Parts Discussed in Thread: CONTROLSUITE

I found this solution elsewhere, but because of a different problem. In the aforementioned driver is the following function:

static
BOOL xmit_datablock (
    const BYTE *buff,    /* 512 byte data block to be transmitted */
    BYTE token            /* Data/Stop token */
)
{
    BYTE resp, wc;


    if (wait_ready() != 0xFF) return FALSE;

    xmit_spi(token);                    /* Xmit data token */
    if (token != 0xFD)      /* Is data token */
    {
        wc = 0;
        do                              /* Xmit the 512 byte data block to MMC */
        {
            xmit_spi(*buff++);
            xmit_spi(*buff++);
        }
        while (--wc);
        xmit_spi(0xFF);                    /* CRC (Dummy) */
        xmit_spi(0xFF);
        resp = rcvr_spi();                /* Reveive data response */
        if ((resp & 0x1F) != 0x05)        /* If not accepted, return with error */
            return FALSE;
    }

    return TRUE;
}

However, there's an issue that prevented me from writing ANY data to an SD card. Specifically, declaring "wc" as a BYTE and initializing it to 0. The author assumed it would decrement to 256, then 255, etc. Each iteration would send 2 datablocks, for a total of 512.

BUT:

BYTE is an unsigned char and thus 16 bits -- it decrements to 65536, and thus attempts to send 131072 bytes. Changing this to initialize to 256 allowed me to write happily to my SD card. If you're having issues writing to an SD card, change this.