AVR and FATFS Multiple block read

431 views Asked by At

I am using atmega1284p and I need to read data from sd card and send audio decoder chip I can do it for low bitrates,higher bitrates MCU struggle to send data on time. Respect to my research to achieve the high bitrates, files can be read muliple block and after reading first block there is no delay.I allocated my multi block buffer but dont know how to read blocks in multiple way with ELM Chans FATFS library .Can F_read do this, or any other suggestion.

1

There are 1 answers

0
JettJ On

You have to tell f_read() that you want to read more than a block size worth of bytes.

sect = clst2sect(fs, fp->clust);    /* Get current sector */
if (sect == 0) ABORT(fs, FR_INT_ERR);
sect += csect;
cc = btr / SS(fs);                  /* When remaining bytes >= sector size, */
if (cc > 0) {                       /* Read maximum contiguous sectors directly */
    if (csect + cc > fs->csize) {   /* Clip at cluster boundary */
        cc = fs->csize - csect;
    }
    if (disk_read(fs->pdrv, rbuff, sect, cc) != RES_OK) ABORT(fs, FR_DISK_ERR);
                
        ...

    }

This says that if f_read() is given an amount of bytes to read [btr] that is more than the Sector Size of the filesystem [SS(fs)], then do a multiblock read of cc blocks staring at block sect.

Note: A sector on a disk is analogous to a block on an SD card.