Re: SD card interface high speed mode
Posted: Wed Oct 03, 2018 2:38 am
Hi, I am working with wrover dev kit and use fwrite and fread to write and read a block of data into/from a .DAT file in the SD card. I increased the buffer size to 32kB which is the cluster size of my SD card. The write speed of 6MB and read speed of 1MB was achieved. Does anyone know how I can increase the reading speed from the SD card? Thank!
Here is a part of my code:
Here is a part of my code:
Code: Select all
#define FILE_SIZE 1048576 * 2 //2MB
#define BUF_SIZE 512 * 64 //32kB
uint8_t buf[BUF_SIZE];
...
FILE* f = fopen("/sdcard/hello.DAT", "w");
uint32_t n = FILE_SIZE/sizeof(buf); //= number of clusters
for (uint32_t i = 0; i < n; i++) {
fwrite(buf, sizeof(uint8_t), sizeof(buf), f);
}
fclose(f);
f = fopen("/sdcard/hello.DAT", "r");
for (uint32_t i = 0; i < n; i++) {
fread (buf, sizeof(uint8_t), sizeof(buf), f);
}
fclose(f);