Hi,
I recently picked up a Teensy 3.6. I've been having a lot of fun playing with the thing
As part of the project I'm doing, I have a (possibly) unique use-case where I need an SD card more for buffer than for anything else - I need to be able to buffer for relatively long periods of time, then burst through a higher-rate connection (e.g. Ethernet) for a relatively brief time. Thus, I don't need a file system on the card - it's not there for anyone else to read, it's just there to be a buffer.
With this in mind, I took a look at KinetisSDHC.c (and glanced through the corresponding sample code it was based on). I wrapped the above into my own little library that lets me do raw I/O, since the interface (thus far) has been incredibly simple. I also wrote some very simple micro-benchmark code to read / write to a few blocks of my SD card, something like (one can substitute WriteBlock for ReadBlock when testing in the other direction):
What I found (with a 64 GB class 10) is that I was seeing read rates of about 4200 blocks / second, and write rates of around 1100 blocks / second. Given that each block is 512B, that works out to roughly 21.5 Mbps read and 5.6 Mbps write.
I was hoping to see higher numbers, so I went back to revisit the code a bit. I started poking through the KinetisSDHC.c code, and saw a call to SDHC_SetClock(SDHC_SYSCTL_25MHZ). I replaced that with: SDHC_SetClock(SDHC_SYSCTL_50MHZ), since I was reasonably certain the card I'm using can support it ... but this did not yield a noticeable change in the rates I observed.
My other thought is that the latency involved is somehow killing my transfer rates, but I haven't found a good example of a transfer that operates on more than one block at a time. I'll note that I'm also still studying what's in the ReadBlock / WriteBlock methods to understand how they work.
Technically, 20 / 5 should work just fine for what I need, but ... I'd still like to understand what I'm doing wrong, since it seems like others have reported much higher speeds with a real filesystem. Along these lines, I have ordered another SD card to see if that affects my results, but ... I figured I'd post this here while I wait for the shipping just to see if someone could tell me if the logic I was using above was incorrect and / or is somehow dumb.
In any event, thanks in advance for any thoughts / assistance / etc!
I recently picked up a Teensy 3.6. I've been having a lot of fun playing with the thing
As part of the project I'm doing, I have a (possibly) unique use-case where I need an SD card more for buffer than for anything else - I need to be able to buffer for relatively long periods of time, then burst through a higher-rate connection (e.g. Ethernet) for a relatively brief time. Thus, I don't need a file system on the card - it's not there for anyone else to read, it's just there to be a buffer.
With this in mind, I took a look at KinetisSDHC.c (and glanced through the corresponding sample code it was based on). I wrapped the above into my own little library that lets me do raw I/O, since the interface (thus far) has been incredibly simple. I also wrote some very simple micro-benchmark code to read / write to a few blocks of my SD card, something like (one can substitute WriteBlock for ReadBlock when testing in the other direction):
Code:
uint32_t start = micros();
for(int i = 0; i < NUM_TEST_BLOCKS; ++i) {
SDHC_ReadBlock(rbuf, TEST_BLOCK_OFFSET + i);
}
uint32_t end = start - micros();
What I found (with a 64 GB class 10) is that I was seeing read rates of about 4200 blocks / second, and write rates of around 1100 blocks / second. Given that each block is 512B, that works out to roughly 21.5 Mbps read and 5.6 Mbps write.
I was hoping to see higher numbers, so I went back to revisit the code a bit. I started poking through the KinetisSDHC.c code, and saw a call to SDHC_SetClock(SDHC_SYSCTL_25MHZ). I replaced that with: SDHC_SetClock(SDHC_SYSCTL_50MHZ), since I was reasonably certain the card I'm using can support it ... but this did not yield a noticeable change in the rates I observed.
My other thought is that the latency involved is somehow killing my transfer rates, but I haven't found a good example of a transfer that operates on more than one block at a time. I'll note that I'm also still studying what's in the ReadBlock / WriteBlock methods to understand how they work.
Technically, 20 / 5 should work just fine for what I need, but ... I'd still like to understand what I'm doing wrong, since it seems like others have reported much higher speeds with a real filesystem. Along these lines, I have ordered another SD card to see if that affects my results, but ... I figured I'd post this here while I wait for the shipping just to see if someone could tell me if the logic I was using above was incorrect and / or is somehow dumb.
In any event, thanks in advance for any thoughts / assistance / etc!