AnsweredAssumed Answered

FatFs uSDCard read Problem

Question asked by LRDSMRT on Jan 4, 2016
Latest reply on Jan 11, 2016 by LRDSMRT
:) Hi my friends.

I've written a code to play a song file for long time on repeat mode. Normally this code work correctly without any problem but for a short time. After for number of repeated, the sound goes to choppy mode, but when i change the player to other song, the other song will play correctly without any problem. I dont know why this is happening but as my research in code, i find out the uSDCard (High Capacitance) has delay to respond.

SD_BOOL SD_RecvDataBlock (uint8_t *buf, uint32_t len)
    uint8_t     datatoken;
    uint32_t    i;
    /* Read data token (0xFE) */
    Timer1 = 10;   /* Data Read Timerout: 100ms */
    tokenCounter = 0;
    do {                           
        datatoken = SPIx_RecvByte ();
        if (datatoken == 0xFE)
    } while (Timer1);
    if(datatoken != 0xFE)
        return (SD_FALSE);  /* data read timeout */
    /* Read data block */
#ifdef USE_FIFO
    SPIx_RecvBlock_FIFO (buf, len);
    for (i = 0; i < len; i++) {
        buf[i] = SPIx_RecvByte ();
    /* 2 bytes CRC will be discarded. */
    SPIx_RecvByte ();
    SPIx_RecvByte ();
    return (SD_TRUE);

Normally the tokenCounter for other song is about 0x66, but for the corrupted song is more than 0xFFFF. I Confused that when i deleted the file and replaced the song again the song will play correctly but again after ... the song goes to choppy.

what was happening to the uSDCard or file...?

Thanks alot...