first
Dependencies: SDFileSystemDMA mbed
Refer to:
https://developer.mbed.org/users/mimi3/code/SDFileSystemDMA
Caution
If your board has SRAM less than or equal to 8KB, the 'buffer' size must be set to 512 Bytes.
NUCLEO-F411RE
About 2.5MBytes/sec
NUCLEO-L152RE
About 1MBytes/sec
Diff: main.cpp
- Revision:
- 25:1e42edbeacca
- Parent:
- 24:bea03d091636
- Child:
- 26:1a610f9aec1a
--- a/main.cpp Sat Sep 03 12:48:34 2016 +0900 +++ b/main.cpp Tue Jan 17 12:21:46 2017 +0900 @@ -61,9 +61,10 @@ SDFileSystem sd( MOSI, MISO, SCLK, CS, "sd", SPI_CLOCK_HZ); -//char buffer[512*1] __attribute__ ((aligned (4))) ; /* 512 bytes */ +/* Set buffer size */ +char buffer[512*1] __attribute__ ((aligned (4))) ; /* 512 bytes */ //char buffer[512*2] __attribute__ ((aligned (4))) ; /* 1024 bytes */ -char buffer[512*4] __attribute__ ((aligned (4))) ; /* 2048 bytes */ +//char buffer[512*4] __attribute__ ((aligned (4))) ; /* 2048 bytes */ //char buffer[512*8] __attribute__ ((aligned (4))) ; /* 4096 bytes */ //char buffer[512*16] __attribute__ ((aligned (4))) ; /* 8192 bytes */ //char buffer[512*32] __attribute__ ((aligned (4))) ; /* 16384 bytes */ @@ -73,6 +74,7 @@ #if defined(__CC_ARM) /* ARMCC */ #define TOOLCHAIN "ARM/uARM" +#define C_VERSION __ARMCC_VERSION #elif defined(__GNUC__) /* GCC */ #define TOOLCHAIN "GCC_ARM" #elif defined(__ICCARM__) /* IAR */ @@ -187,21 +189,43 @@ pc.printf("\n Error Count : %d", errorCount); } +void warning(){ + FileHandle* file = sd.open(FILE_NAME, O_RDONLY); + if (file == NULL) { + pc.printf("\n***************************************"); + pc.printf("\n*** First, you must execute [w] command"); + pc.printf("\n*** to generate test file ( %s ).",FILE_NAME); + pc.printf("\n***************************************"); + } else { + file->close(); + } +} + +time_t read_rtc(void) { + return 0; +} int main(){ int i = 1; + /* setbuf( stdout, NULL ); */ + /* + * Refer to https://developer.mbed.org/questions/69644/RTC-error-LSE-clock-initialization-faile/ + */ + attach_rtc(&read_rtc, NULL, NULL, NULL); + /**/ while(1){ - pc.printf("\n(%2d)------- SDFileSystemDMA --------------------------------",i++); + pc.printf("\n(%2d) ------ SDFileSystemDMA Test ----------------------------",i++); pc.printf("\nR/W Buffer size = %8d Bytes", sizeof(buffer) ); pc.printf("\nSystemClock = %d Hz",SystemCoreClock); - pc.printf("\nSPI(%d), Max SPI Clock = %d Hz",SPI_DEV,SystemCoreClock>>1); - pc.printf("\nCompiler: %s", TOOLCHAIN); - pc.printf("\nmbed-lib: Rev.%d", MBED_LIBRARY_VERSION); + pc.printf("\nSPI(%d), Max SPI Clock = %d Hz (Probably)",SPI_DEV,SystemCoreClock>>1); + pc.printf("\nCompiler = %s", TOOLCHAIN); + pc.printf("\nmbed-lib = Rev.%d", MBED_LIBRARY_VERSION); pc.printf("\n\nStart SD card accsess test !"); pc.printf("\n[r]: Start Read Test. At least execute [w] onece"); pc.printf("\n[w]: Start Write and Read Test"); pc.printf("\n[v]: Start Read Verify Test. At least execute [w] onece"); - pc.printf("\nWriting is very slow, wait tens of seconds."); + pc.printf("\nNote: Writing is very slow, wait tens of seconds."); + warning(); pc.printf("\n--- Select [r] or [w] or [v]---\n"); fflush(stdout); char ch = wait_key_press();