PDA

View Full Version : Teensy 3 MicroSD guide



ZTiK.nl
01-22-2013, 10:40 AM
Hello everybody,

I had some problems connecting/using the MicroSD adapter from PJRC with my Teensy 3.0 so I decided to make a small guide about it.
First off, I am new to all this, so any corrections/tips/criticism is welcome :)


The very first thing to do is solder the 3V pads on the bottom of the MicroSD adapter.
This is because Teensy 3 = 3.3v, while other/older Teensy's are 5v.
The MicroSD adapter can work at both voltages, all that is required is to connect 2 pads together to set it to 3.3v:
175

Here is my attempt (my first soldering ever!):
176


After this has been done, you can start connecting the adapter to the Teensy.
At this point I ran into some trouble until I found a post by pixelk (http://forum.pjrc.com/members/8-pixelk) explaining it quite well, thanks pixelk !

Connections on the MicroSD adapter:
177
+5V goes to 3.3V (100 mA max)
Ground goes to GND
MOSI goes to pin 11, DOUT
MISO goes to pin 12, DIN
SCLK goes to pin 13, SCK
SS goes to pin 10, CS

MicroSD wired up to Teensy:
178
+5V goes to 3.3V (red wire)
Ground goes to GND (black wire)
MOSI goes to pin 11 (blue wire)
MISO goes to pin 12 (green wire)
SCLK goes to pin 13 (white wire)
SS goes to pin 10 (yellow wire)

Additional warning, with thanks to LarryP (http://forum.pjrc.com/members/45-LarryP):
When you connect the MicroSD adapter to the Teensy, take into account which direction the MicroSD card holder is facing!
Take another look at the image above to make sure :)

Once you have done this, you should be able to run the cardinfo example.
Dont forget to set your Teensy to Serial and to set the ChipSelect variable in cardinfo example to 10 instead of 4.


Initializing SD card...Wiring is correct and a card is present.

Card type: SDHC

Volume type is FAT32

Volume size (bytes): 3519021056
Volume size (Kbytes): 3436544
Volume size (Mbytes): 3356

Files found on the card (name, date and size in bytes):
BENCH.DAT 2000-01-01 01:00:00 5000000


To test all this I bought a spanking new MicroSD card, but I kept getting errors during initializing SD card.
After a lot of checking code and rechecking my connections, I 'obtained' a MicroSD card from my mothers HTC mobile phone, and suddenly the cardinfo example started working automagically.

In case you run into trouble during init phase, try another card, it seems not all are created equal.
For what it is worth, the first MicroSD I used was a 2GB non-HC by Icidu, the one that did work was a Kingston SDHC 8gb.

Additional tip with thanks to linuxgeek (http://forum.pjrc.com/members/24500-linuxgeek):
If you are able to read but not write (or experience any similar issues), try to format the SD card using the SdFat SdFormatter example.

This should be enough for this firstpost, in the next one I'll post a few benchmarks and how I improved read/write speed with a factor 10x !

ZTiK.nl
01-22-2013, 11:04 AM
One of the things I was eager to try was a benchmark tool for MicroSD i read about on a few forums.
It is included in the SdFat library two times, the first is benchSD.ino and this uses default libraries, the second is bench.ino which makes use of the new SdFat library itself.

Download the SdFat file here (http://code.google.com/p/beta-lib/downloads/list), and extract the SdFat folder to your \arduino-1.0.x\libraries

(re)start your Teensyduino and load the benchSD.ino.
Since the first example takes a while, it is wise to shrink the size of the testfile to 0.2 (200KB)
Upload the example and start the Serial Monitor

benchSD.ino

Type any character to start
File size 0.20MB
Buffer size 100 bytes
Starting write test. Please wait up to a minute
Write 12.68 KB/sec
Maximum latency: 147815 usec, Minimum Latency: 17 usec, Avg Latency: 7830 usec

Starting read test. Please wait up to a minute
Read 14.35 KB/sec
Maximum latency: 69960 usec, Minimum Latency: 18 usec, Avg Latency: 6965 usec

Done

Type any character to start
-----------------------------------------------
Type any character to start
File size 0.20MB
Buffer size 500 bytes
Starting write test. Please wait up to a minute
Write 12.65 KB/sec
Maximum latency: 147922 usec, Minimum Latency: 59 usec, Avg Latency: 39236 usec

Starting read test. Please wait up to a minute
Read 14.37 KB/sec
Maximum latency: 69947 usec, Minimum Latency: 68 usec, Avg Latency: 34802 usec

Done

Type any character to start
-----------------------------------------------
Type any character to start
File size 0.20MB
Buffer size 1000 bytes
Starting write test. Please wait up to a minute
Write 12.68 KB/sec
Maximum latency: 207257 usec, Minimum Latency: 37806 usec, Avg Latency: 78297 usec

Starting read test. Please wait up to a minute
Read 14.38 KB/sec
Maximum latency: 105011 usec, Minimum Latency: 35003 usec, Avg Latency: 69536 usec

Done

Type any character to start
read 14KB/s, write 12KB/s, with a 200KB testfile and buffersize 100/500/100

Now lets make use of the new and improved SdFat library

bench.ino:



Type any character to start
Free RAM: 10691
Type is FAT32
File size 5MB
Buffer size 100 bytes
Starting write test. Please wait up to a minute
Write 147.78 KB/sec
Maximum latency: 174475 usec, Minimum Latency: 10 usec, Avg Latency: 675 usec

Starting read test. Please wait up to a minute
Read 517.01 KB/sec
Maximum latency: 1834 usec, Minimum Latency: 9 usec, Avg Latency: 191 usec

Done

Type any character to start
-----------------------------------------------

Type any character to start
Free RAM: 10291
Type is FAT32
File size 5MB
Buffer size 500 bytes
Starting write test. Please wait up to a minute
Write 150.13 KB/sec
Maximum latency: 161796 usec, Minimum Latency: 19 usec, Avg Latency: 3328 usec

Starting read test. Please wait up to a minute
Read 534.76 KB/sec
Maximum latency: 1820 usec, Minimum Latency: 19 usec, Avg Latency: 933 usec

Done

Type any character to start
-----------------------------------------------

Type any character to start
Free RAM: 9791
Type is FAT32
File size 5MB
Buffer size 1000 bytes
Starting write test. Please wait up to a minute
Write 150.74 KB/sec
Maximum latency: 323792 usec, Minimum Latency: 1841 usec, Avg Latency: 6630 usec

Starting read test. Please wait up to a minute
Read 542.77 KB/sec
Maximum latency: 2872 usec, Minimum Latency: 794 usec, Avg Latency: 1840 usec

Done

Type any character to start

read 150 KB/s, write 530 KB/s, with a 5MB testfile and buffersize 100/500/100

Extra info: I ran these tests at 48MHz CPU speed

ZTiK.nl
01-22-2013, 03:39 PM
same test as before (bench.ino), but at 96MHz:

Type any character to start
Free RAM: 8791
Type is FAT32
File size 5MB
Buffer size 2000 bytes
Starting write test. Please wait up to a minute
Write 261.78 KB/sec
Maximum latency: 614550 usec, Minimum Latency: 2225 usec, Avg Latency: 7611 usec

Starting read test. Please wait up to a minute
Read 875.96 KB/sec
Maximum latency: 3996 usec, Minimum Latency: 1202 usec, Avg Latency: 2282 usec

Done

Type any character to start
------------------------------------------------------
Type any character to start
Free RAM: 6695
Type is FAT32
File size 5MB
Buffer size 4096 bytes
Starting write test. Please wait up to a minute
Write 762.34 KB/sec
Maximum latency: 881809 usec, Minimum Latency: 3088 usec, Avg Latency: 5364 usec

Starting read test. Please wait up to a minute
Read 1720.77 KB/sec
Maximum latency: 3370 usec, Minimum Latency: 2178 usec, Avg Latency: 2378 usec

Done

Type any character to start

I am definately happy with these results :)

ZTiK.nl
01-22-2013, 04:11 PM
The maximum I can get out of it, also, the speed is quite stable


Type any character to start
Free RAM: 551
Type is FAT32
File size 5MB
Buffer size 10240 bytes
Starting write test. Please wait up to a minute
Write 1070.05 KB/sec
Maximum latency: 808693 usec, Minimum Latency: 5349 usec, Avg Latency: 9398 usec

Starting read test. Please wait up to a minute
Read 2069.20 KB/sec
Maximum latency: 6355 usec, Minimum Latency: 4556 usec, Avg Latency: 4949 usec

Done

Type any character to start
------------------------------------------------------
Type any character to start
Free RAM: 551
Type is FAT32
File size 25MB
Buffer size 10240 bytes
Starting write test. Please wait up to a minute
Write 1311.09 KB/sec
Maximum latency: 915084 usec, Minimum Latency: 5350 usec, Avg Latency: 7805 usec

Starting read test. Please wait up to a minute
Read 2036.65 KB/sec
Maximum latency: 6852 usec, Minimum Latency: 4543 usec, Avg Latency: 5026 usec

Done

Type any character to start
------------------------------------------------------
Type any character to start
Free RAM: 551
Type is FAT32
File size 250MB
Buffer size 10240 bytes
Starting write test. Please wait up to a minute
Write 1392.32 KB/sec
Maximum latency: 74300 usec, Minimum Latency: 5345 usec, Avg Latency: 7353 usec

Starting read test. Please wait up to a minute
Read 1999.34 KB/sec
Maximum latency: 6922 usec, Minimum Latency: 4539 usec, Avg Latency: 5120 usec

Done

Type any character to start

Wozzy
01-22-2013, 07:15 PM
ZTiK.nl

First, Thanks again for the SD card tutorial. I was able to use it to get mine up and running quickly.
It probably would have worked the first time for me...
but it took me a while to realize that the power bus strips in my breadboard were not continuous over the full length.

As for the SDfat library,
That's pretty impressive... over 2GBytes / second read speed. <Correction: over 2MBytes / second read speed.
I'm definitely going to try out this library.
What is the difference, between the different cases that you ran? Is it just the buffer size?

Thanks,
Bob W.

ZTiK.nl
01-22-2013, 08:55 PM
No problem at all, sorry for the inconvenience of it suddenly disappearing :x
I wasn't aware that there were breadboards where the power lines are not continuous, learned something new as well...

A small correction concerning the read speed, its +/- 2MB/s, not GB/s !
Hope you still find it impressive :)

The differences in my testcases:
-The very first test was benchSD.ino which uses default arduino libraries
200KB testfile, buffersizes 100/500/1000, Teensy @ 48MHz (12/14 KB/s)

-The second test was bench.ino which uses the new SdFat libraries
5MB testfile, buffersizes 100/500/1000, Teensy @ 48MHz (150/530 KB/s)

-The third test was also bench.ino
5MB testfile, buffersizes 2000/4096, Teensy @ 48MHz (200+/870+ KB/s)

-The fourth/last test was also bench.ino
5/25/250MB testfile, buffersize 10240, Teensy @ 96MHz (1350/2000 KB/s)

Wozzy
01-22-2013, 09:18 PM
Oh yes... I'm not sure what I was thinking....2MB/Sec is still plenty fast for my application.

Thanks for the additional information... I'll give it a try later tonight

ZTiK.nl
01-22-2013, 09:30 PM
No problem at all :)
I've seen other people post benchmarks a little higher than the 2MB/s I was able to get, but I think that was due to HQ SDcards, mine are simple 'non-industrial grade' from the local electronics-store.
link to other benchmarks (http://arduino.cc/forum/index.php?topic=128335.0)

PaulStoffregen
01-24-2013, 11:50 PM
Thanks for writing this! I've added a link on the SD Adaptor page. :)

ZTiK.nl
01-25-2013, 03:27 AM
Simply paying back for all the things I've been given ;)

I should be thanking you for giving us such a wonderful product and support most people can only dream of!

LarryP
01-29-2013, 09:14 PM
@ZTiK.nl,

Thank you for taking the time and effort to put together your Teensy 3 MicroSD guide!
Having that really helped me get my SD_Card working with a Teensy3. Should you ever find yourself in the Boston area, I owe you beer.

A caution to people wiring up one of PJRC's microSD adaptors for the first time:
before applying power, double check the orientation of the adaptor, particularly with respect to which end of the adaptor the card slides into. I mistakenly assumed (without thinking about it enough) that the soldered connections to the card's socket must be opposite the side that the card slides into -- and wired it up wrong, coming closer than I'd like to damaging it.

@Paul,
If you revise the SD Adaptor pin diagram, you might add an arrow showing which side the card goes into.

Thanks again ZTiK.nl !

ZTiK.nl
01-29-2013, 09:56 PM
@LarryP: Free beer, woohoo!
Like I said before, nothing worth mentioning, it was just gathering information that was already available.

I've quoted your cautionary text in the initial post, so that others should be able to read it during the connecting, not afterwards!

@BambooSam: I'm sorry, but I am not able to answer your question personally.
By looking at the pinout diagram I would think you are right, and are referring to usable pins, only I cannot explain why the SPI description on these ports appears 'greyed out' on the pinout diag (http://www.pjrc.com/teensy/pinout.html)

On the other hand, it should be easy for me to test it, just switch a few wires and see if the example still runs, to be continued...

ZTiK.nl
01-29-2013, 10:32 PM
I tried to connect the MicroSD using the pins you supplied (while using the fast library, not the default slow one), but cannot get it working myself:

I have changed line 12 in SoftSPI.h to:

template<uint8_t MisoPin = 8, uint8_t MosiPin = 7, uint8_t SckPin = 14, uint8_t Mode = 0>
along with the CS pin in the example itself, but I keep receiving the following error:


Type any character to start
Free RAM: 551
Can't access SD card. Do not reformat.
No card, wrong chip select pin, or SPI problem?
SD errorCode: 0X1,0X0

edit:
Just noticed you also found thread Reassigning a pin (SPI SCK) (http://forum.pjrc.com/threads/431-Reassigning-a-pin-(SPI-SCK)), if/when you get a solution, please post it/PM me, then I will add it to the first post.

BambooSam
01-29-2013, 11:28 PM
Will do :)

ZTiK.nl
01-30-2013, 12:32 AM
Something I read that could be considered useful:

When a device's Slave Select pin is low, it communicates with the master. When it's high, it ignores the master. This allows you to have multiple SPI devices sharing the same MISO, MOSI, and CLK lines.
quote from arduino.cc SPI reference (http://arduino.cc/en/Reference/SPI)

This makes me believe that switching during runtime is not the way forward, but to keep them connected to the same pins and let the SS (Slave Select) decide which device is currently being read/written.
Again, I have a very limited understanding of these matters, so I could be mistaken here...

BambooSam
01-30-2013, 05:37 PM
Yeah that would be the best way to go about it, but my issue is that the led strips ONLY use Mosi and SCK, it doesn't use a select pin - (fastSPI).

Even easier: I am still new to electronics but is there an ic that can be used to switch the data line and stream it? and use a digital pin to toggle the sd and lpd8806?

(I am going to move this issue into another thread)

ZTiK.nl
02-11-2013, 06:30 PM
There is another update to the SdFat library (http://code.google.com/p/beta-lib/downloads/list)

Russ
02-12-2013, 12:56 AM
Thanks for writing this up. Came in very handy and got me right up and running.

ZTiK.nl
02-12-2013, 01:08 AM
More than welcome, glad I did something useful for a change ;)

turtle9er
02-19-2013, 01:44 AM
I have recently purchased this card and on reading about data logging it keeps saying that the SD card needs a lot of current while working. Can I hook this up and just use the usb power without any issues. I also have 2 optical slotted encoders hooked up to the teensy 3 that use 10mA each, which I am getting the power from the Vin pin. If it is an issue, how would I supply enough current to reduce this issue. Thanks in advance.

ZTiK.nl
02-19-2013, 08:48 AM
Good question!

As much as I want to tell you, I simply do not know :(

I wouldn't expect the MicroSD to use 80mA while active though, sounds like quite a lot.
The multimeter I ordered still has not arrived because another item in my order is currently out of stock, so I have no way to actually test usage during idletime/heavy use at the moment.



Since I started my project I have been using a separate 3.3v+5v usb powersupply for all my modules with the exception of my speaker & MicroSD.
-The speaker uses a digital pin along with GND and the MicroSD adapter is the only thing connected on the 3.3v out pin.
-Then I have my TFT/GPS/Microphone/Humidity&Temp. sensor all powered by the 3.3v external power supply.

256
The powersupply is connected to the right-side (top in image) powerstrips with 5v, and with jumpers running from below the led all the way to the left-side powerstrip with 3.3v.
(So far I have no devices on the 5v yet, but this will change soon I hope)


I do hope someone is able to answer this question because I would like to know as well, and I don't know when I will be able to check myself :x

jsfetzik
02-19-2013, 06:13 PM
Off the top of my head I think the SD card spec says it should be 0.5mA in standby and 45mA max during 50MHz read or write. At 25MHz current draw is about half that. I have heard real world numbers of as high as 80mA during a read/write. Low quality cards probably.

So how much the current draw over time really is depends on how how much time you spend doing each type of operation. So if you are continually reading/writing you use a lot of current. If you do a write once per minute you are probably good for a long time.

turtle9er
02-19-2013, 08:12 PM
For my application I will be writing around 90-120 samples per minute for up to 3 hours continuous. So I will guess it will working pretty hard. This is my first teensy and well new to most of this, so I am wondering if I will need some sort of external power. If I do, do I cut that pad off and then just feed my new 5v supply into Vin and ground-ground?

jsfetzik
02-20-2013, 08:48 PM
If you are running for only 3 hours you should be able to power things without a problem. A set of plain old generic AA batteries fresh from the package should provide 400mAh or more. So even if your circuit draws 100mA on average you can run for 4+ hours. With better batteries such as good quality NiMH batteries you can get 1000 to 3000 mAh.

maujabur
02-23-2013, 03:51 PM
Hi!
Just out of curiosity:
Since Teensy 3 is 3.3V native, would it be possible to connect the microSD slot directly to its pins, without the 74cx125?
If so, is there any downside to it?

Thanks!

Maujabur

PaulStoffregen
02-23-2013, 05:27 PM
Since Teensy 3 is 3.3V native, would it be possible to connect the microSD slot directly to its pins, without the 74cx125?


Yes



If so, is there any downside to it?


Only the difficulty of soldering to those tiny pins on the SD card socket.

maujabur
02-24-2013, 01:08 AM
@PaulStoffregen

Thanks! you're right, it's easier to have the adapter, and it's more versatile. Having a little buffer won't do any harm. it was just a technical speculation.

MJ

linuxgeek
03-06-2013, 05:26 PM
I just hooked this up but am failing to get the benchmark code to work.

I hooked up micro SD adapter board the same way and was able to the cardInfo sketch both from the original and SDFat running and it tells me info about the card and list the files, etc.

But when I run the benchmark or any sketch that writes to a file, the LED lights up and it seems to never get past the write function.

For instance, in benchSD it never gets past this code. I even lowered the filesize to just the size of the buffer so it would have to do it only once:

if (file.write(buf, sizeof(buf)) != sizeof(buf)) {
error("write failed");
}

Any ideas on what would prevent a write? I have a 32GB micro SD card class 10 SDHC formatted in FAT32.

linuxgeek
03-06-2013, 05:44 PM
Ok, I just needed to format the card with the teensy. Did you do anything to get better benchmarks?

Here's my benchmark @ 96MHz (which was not very different than 48MHz)
Free RAM: 12343
Type is FAT32
File size 5MB
Buffer size 100 bytes
Starting write test. Please wait up to a minute
Write 472.01 KB/sec
Maximum latency: 14606 usec, Minimum Latency: 9 usec, Avg Latency: 210 usec

Starting read test. Please wait up to a minute
Read 1079.21 KB/sec
Maximum latency: 1030 usec, Minimum Latency: 8 usec, Avg Latency: 91 usec

ZTiK.nl
03-06-2013, 06:06 PM
I just needed to format the card with the teensy
Wasn't aware that it is possible to read correctly but fail on write, but I'll add the format tip to the first-post in case anyone else experiences the same, thnx!
Did you format using SD or SdFat ? (I assume SdFat...)


Did you do anything to get better benchmarks?

Just one more thing as far as I can see: increase the buffer size

Maximum I am able to use in the bench example is 10240
Any higher and the read will get corrupted.

Post #6 (http://forum.pjrc.com/threads/16758-Teensy-3-MicroSD-guide?p=19999&viewfull=1#post19999) in this topic shows a list of a few benchmarks under different conditions, the last one shows the max buffer use.

Using such a high buffer might not be wise outside the benchmark util though, not sure what the implications are of max buffer usage.

P.S. I have been having stable but different benchmark speeds using different brand MicroSD cards, Kingston and Sandisks seem to have max speed

linuxgeek
03-06-2013, 06:15 PM
Oh yeah, so here's my benchmark for buff size 10240 for 5MB and 25MB. Pretty good stuff. Mine is:
Samsung 32GB Micro SDHC class 10. I know it's overkill, but I'm just borrowing it from my tablet for now.
http://www.amazon.com/Samsung-microSDHC-Memory-Adapter-number/dp/B005TUQV0E/

Free RAM: 2203
Type is FAT32
File size 5MB
Buffer size 10240 bytes
Starting write test. Please wait up to a minute
Write 1510.62 KB/sec
Maximum latency: 16336 usec, Minimum Latency: 4450 usec, Avg Latency: 6750 usec

Starting read test. Please wait up to a minute
Read 2389.82 KB/sec
Maximum latency: 4993 usec, Minimum Latency: 4147 usec, Avg Latency: 4284 usec


Free RAM: 2203
Type is FAT32
File size 25MB
Buffer size 10240 bytes
Starting write test. Please wait up to a minute
Write 1545.43 KB/sec
Maximum latency: 25048 usec, Minimum Latency: 4485 usec, Avg Latency: 6619 usec

Starting read test. Please wait up to a minute
Read 2385.33 KB/sec
Maximum latency: 5142 usec, Minimum Latency: 4145 usec, Avg Latency: 4291 usec

ZTiK.nl
03-06-2013, 06:24 PM
Wow, thats very nice indeed
I haven't been able to reach the 2MB yet, 1999.34 KB/sec... just 1 KB/s or 49 KB/s short depending on how you count :x

Also, I don't think there is such thing as overkill when it concerns storage space ;)

(added the format advise to the firstpost)

linuxgeek
03-06-2013, 06:48 PM
Oh, and i did use the SdFat formatting.

And do you know if the latency is the time from the call to the return of writing a single buffer? I assume that's the case.

In my case, I think I'll probably set a fairly small buffer so that it's completely written before 1msec, to not interfere with other processing.

But, when transferring the file to the computer, I'll make the buffer as large as possible to read and send to PC. I'll try and contribute a sketch in the future that makes it easy to configure the teensy to capture signals and send it to the PC when it's done.

ZTiK.nl
03-06-2013, 07:37 PM
And do you know if the latency is the time from the call to the return of writing a single buffer?

If I understand the code below correct, that is correct.

// do write test
uint32_t n = FILE_SIZE/sizeof(buf);
maxLatency = 0;
minLatency = 9999999;
totalLatency = 0;
uint32_t t = millis();
for (uint32_t i = 0; i < n; i++) {
uint32_t m = micros();
if (file.write(buf, sizeof(buf)) != sizeof(buf)) {
error("write failed");
}
m = micros() - m;
if (maxLatency < m) maxLatency = m;
if (minLatency > m) minLatency = m;
totalLatency += m;
}

The filesize is divided by the buffersize, then each write operation is timed by 'uint32_t m = micros();'
At the end of each write operation the start time is subtracted from the end time and added to the totalLatency (time for all write operations together)

After running the entire benchmark, the maxLatency and minLatency only contain a single write operation, the highest and lowest value during the entire benchmark.

Edit: The same goes for read operations, code is the same concerning how latency is calculated

And code contributions are always welcome ofcourse (but not mandatory) :)

Roger Parkinson
04-01-2013, 11:05 PM
This worked just fine for me, so it must be a really good guide :)
I did one thing different, I ignored the 3.3v thing and just hooked up the +5V on the MicroSD adapter to the Teensy3 Vin and this was okay.
They only reason I did it this way is 'cos I'm lazy.

ZTiK.nl
04-01-2013, 11:38 PM
Thats great to hear, kept it as simple as possible so that even somebody like myself could understand it :p

Wasn't sure if I'd blow up either the Teensy pin or the MicroSD if I didnt bridge the 3V pads, and well, had to learn how to solder anyway...

djsz
04-08-2013, 10:49 AM
I'm glad to see the updates to the SDFat library--I'll have to try them out. Any news on when the SD USB mode for Teensy 3.0 might be coming?

ZTiK.nl
04-08-2013, 11:32 PM
So far, I haven't experienced any issues with (the latest) SdFat beta, so I would definately advise to give it a go :)

I think, but I'm not sure if 'SD USB mode' depends on 'USB host mode'
From what I understood from the Kickstarter page (http://www.kickstarter.com/projects/paulstoffregen/teensy-30-32-bit-arm-cortex-m4-usable-in-arduino-a?ref=live):

The USB port on Teensy 3.0 is capable of USB host mode. A Micro-AB connector allows future use of USB host mode. Initially, Teensy 3.0 will ship with only USB device support. USB host support, integrated in the Arduino(R)** environment with easy-to-use objects, is planned as a software-only upgrade in 2013. Programming a project using USB host mode will require a second Teensy 3.0 and a board-to-board link using the I2C pins (2 wires and ground), to provide a path for the Arduino IDE to upload code.

From posts on this forum I understood that Paul has it on his to-do list, but there are still some other things with a higher priority.

P.S. feel free to correct me if I made an incorrect assumption here ;)

djsz
04-09-2013, 11:49 AM
Ah--sorry that I wasn't specific. I'm wondering about the Mass Storage USB mode emulation that mounts the SD card as a removable storage when the Teensy is connected to a host computer. It's selectable from the Teensyduino "USB Mode" menu, and Teensy 2.0 has it. Comparable to Joystick, Keyboard, and soft Serial modes.

Space
06-18-2013, 02:54 PM
Hi,
I was able to wire up the Teensy 3.0 with microSD adaptor. But I could not follow your instruction regarding the code, "cardinfo example".

I am reading data from MPU9150 (acc,gyro and mag, 9 DOF sensor) and I would like to save it to a microSD card using the micro SD adaptor.

Please help. I am a newbie. I need simpler instructions with regards to the code.

Space
06-19-2013, 04:46 PM
Hi Paul,

I want to read the output from MPU9150 (Acc, Gyro and Mag) using a Teensy 3.0 (PJRC product - http://www.pjrc.com/store/teensy3.html) to a micro SD card on a SD adaptor (PJRC product - http://www.pjrc.com/teensy/sd_adaptor.html). I am able to read the data from the MPU9150 and display it on the serial monitor on my computer. I want to save the data on a micro SD card. I went to the following post http://forum.pjrc.com/threads/16758-Teensy-3-MicroSD-guide
I have followed all the instructions to connect the SD adaptor to the Teensy 3.0. But I could not follow how to get the script to save data from MPU9150 through the Teensy 3.0 to the Micro SD card in the SD adaptor (Teensy product). I tried attaching a photograph to convey my idea. But it seems the system does not allow me to do that.
Please help.

turtle9er
06-19-2013, 08:42 PM
Maybe post all of your code? Have you tried to just save to the card with simple code?

PaulStoffregen
06-19-2013, 10:10 PM
I tried attaching a photograph to convey my idea. But it seems the system does not allow me to do that.

The forum imposes a file size limit, so a high res photo directly from your digital camera is probably too large. Just open the file with your favorite image program (eg, Photoshop, Gimp, etc) and reduce the size to something like 1024 or 800 pixels. Save as JPEG format. Usually setting "quality" to 75% usually results in a smaller file with minimal loss of detail.

I'd also agree with turtle9er, you must post a small but complete sample program if you want us to help much. Take a look at this thread (http://forum.pjrc.com/threads/23830-Teensy-Having-Problems-with-this-code) to see how important sample code is for resolving problems!

cmason
06-27-2013, 12:23 AM
Random question: if I only have one SD card slot on the SPI bus, do I need to use a pin for Chip Select or can I simply ground it?

flipflop
07-11-2013, 01:58 AM
sdadaptor in the protoboard with and without boards: 662 663

and the benchmarck with Sandisk Extreme Pro (http://www.sandisk.com/products/memory-cards/microsd/extremepro-uhs-i/?capacity=16GB):


================================================== ===================
Free RAM: 8103
Type is FAT32
File size 5MB
Buffer size 512 bytes

Write 363.75 KB/sec
Maximum latency: 75200 usec, Minimum Latency: 1130 usec, Avg Latency: 1405 usec

Read 1224.51 KB/sec
Maximum latency: 1422 usec, Minimum Latency: 399 usec, Avg Latency: 416 usec
------------------------------------------------------------------------------------------------------------------------------
Free RAM: 8103
Type is FAT32
File size 10MB
Buffer size 512 bytes

Write 362.52 KB/sec
Maximum latency: 54664 usec, Minimum Latency: 1113 usec, Avg Latency: 1410 usec

Read 1216.83 KB/sec
Maximum latency: 1398 usec, Minimum Latency: 401 usec, Avg Latency: 419 usec
================================================== ===================
Free RAM: 8103
Type is FAT32
File size 5MB
Buffer size 1024 bytes

Write 436.30 KB/sec
Maximum latency: 18524 usec, Minimum Latency: 1471 usec, Avg Latency: 2344 usec

Read 1395.64 KB/sec
Maximum latency: 1731 usec, Minimum Latency: 661 usec, Avg Latency: 732 usec
------------------------------------------------------------------------------------------------------------------------------
Free RAM: 8103
Type is FAT32
File size 10MB
Buffer size 1024 bytes

Write 437.88 KB/sec
Maximum latency: 19906 usec, Minimum Latency: 1472 usec, Avg Latency: 2336 usec

Read 1397.34 KB/sec
Maximum latency: 1731 usec, Minimum Latency: 637 usec, Avg Latency: 731 usec
================================================== ===================
Free RAM: 8103
Type is FAT32
File size 5MB
Buffer size 2048 bytes

Write 1021.07 KB/sec
Maximum latency: 18108 usec, Minimum Latency: 1719 usec, Avg Latency: 2001 usec

Read 1834.56 KB/sec
Maximum latency: 2103 usec, Minimum Latency: 1049 usec, Avg Latency: 1114 usec
------------------------------------------------------------------------------------------------------------------------------
Free RAM: 8103
Type is FAT32
File size 10MB
Buffer size 2048 bytes

Write 1026.52 KB/sec
Maximum latency: 18149 usec, Minimum Latency: 1689 usec, Avg Latency: 1992 usec

Read 1840.30 KB/sec
Maximum latency: 2097 usec, Minimum Latency: 1030 usec, Avg Latency: 1111 usec
================================================== ===================
Free RAM: 4007
Type is FAT32
File size 5MB
Buffer size 4096 bytes

Write 1577.37 KB/sec
Maximum latency: 19210 usec, Minimum Latency: 2166 usec, Avg Latency: 2590 usec

Read 2164.19 KB/sec
Maximum latency: 2901 usec, Minimum Latency: 1851 usec, Avg Latency: 1890 usec
------------------------------------------------------------------------------------------------------------------------------
Free RAM: 4007
Type is FAT32
File size 10MB
Buffer size 4096 bytes

Write 1598.71 KB/sec
Maximum latency: 33052 usec, Minimum Latency: 2157 usec, Avg Latency: 2558 usec

Read 2167.43 KB/sec
Maximum latency: 2873 usec, Minimum Latency: 1821 usec, Avg Latency: 1888 usec
================================================== ===================
Free RAM: -89
Type is FAT32
File size 5MB
Buffer size 8192 bytes

Write 2036.32 KB/sec
Maximum latency: 42498 usec, Minimum Latency: 3757 usec, Avg Latency: 4015 usec

Read 2351.59 KB/sec
Maximum latency: 4444 usec, Minimum Latency: 3440 usec, Avg Latency: 3482 usec
------------------------------------------------------------------------------------------------------------------------------
Free RAM: -89
Type is FAT32
File size 10MB
Buffer size 8192 bytes

Write 2076.51 KB/sec
Maximum latency: 17011 usec, Minimum Latency: 3721 usec, Avg Latency: 3940 usec

Read 2352.14 KB/sec
Maximum latency: 4480 usec, Minimum Latency: 3405 usec, Avg Latency: 3481 usec
================================================== ===================

Does anyone know why "Free RAM: -89" in the last test?

regards!

Enje
08-01-2013, 10:19 PM
It was time for me to add a SD card as well to my project, but I ran into a strange issue when using 'bench' from 'SdFatBeta20130621'.

I assume it must have something to do with UHS, which is a shame really, since it is the smallest mSD card I have, and I really had no other use for it any more, besides for this project.
Maybe it is me who is strange, but that Transcend is normally considered to be the slowest card in my possession.

Samsung UHS-1 card:


http://www.samsung.com/uk/consumer/memory-cards-hdd-odd/memory-cards-accessories/micro-sdhc-pro/MB-MG8GB/EU
that I formated using SDformatter from the sdfat lib.

//
// 96 MHz, 100 buffer
Use a freshly formatted SD for best performance.
Type any character to start
Free RAM: 8103
Type is FAT32
File size 10MB
Buffer size 100 bytes
Starting write test. Please wait up to a minute
Write 197.55 KB/sec
Maximum latency: 110787 usec, Minimum Latency: 8 usec, Avg Latency: 505 usec

Starting read test. Please wait up to a minute
Read 748.56 KB/sec
Maximum latency: 4006 usec, Minimum Latency: 8 usec, Avg Latency: 132 usec

//
// 96 MHz, 1022 buffer
Use a freshly formatted SD for best performance.
Type any character to start
Free RAM: 8095
Type is FAT32
File size 10MB
Buffer size 1022 bytes
Starting write test. Please wait up to a minute
Write 199.08 KB/sec
Maximum latency: 25521 usec, Minimum Latency: 1519 usec, Avg Latency: 5131 usec

Starting read test. Please wait up to a minute
Read 790.70 KB/sec
Maximum latency: 4466 usec, Minimum Latency: 624 usec, Avg Latency: 1291 usec

//
// 96 MHz, 1024 buffer
Use a freshly formatted SD for best performance.
Type any character to start
Free RAM: 8103
Type is FAT32
File size 10MB
Buffer size 1024 bytes
Starting write test. Please wait up to a minute
Write 366.42 KB/sec
Maximum latency: 15439 usec, Minimum Latency: 801 usec, Avg Latency: 2792 usec

Starting read test. Please wait up to a minute
error: read failed
SD errorCode: 0X3,0X1

//48 MHz does show similar results.


Transcend Class 10 card:


http://www.bestcovery.com/transcend-ts16gusdhc10-16-gb-microsd-high-capacity-microsdhc <--- this one I believe it is
that I formated using SDformatter from the sdfat lib.

//
// 96 MHz, 100 buffer
Use a freshly formatted SD for best performance.
Type any character to start
Free RAM: 8103
Type is FAT32
File size 10MB
Buffer size 100 bytes
Starting write test. Please wait up to a minute
Write 337.28 KB/sec
Maximum latency: 191464 usec, Minimum Latency: 8 usec, Avg Latency: 295 usec

Starting read test. Please wait up to a minute
Read 996.71 KB/sec
Maximum latency: 2241 usec, Minimum Latency: 8 usec, Avg Latency: 99 usec

//
// 96 MHz, 1022 buffer
Use a freshly formatted SD for best performance.
Type any character to start
Free RAM: 8095
Type is FAT32
File size 10MB
Buffer size 1022 bytes
Starting write test. Please wait up to a minute
Write 370.74 KB/sec
Maximum latency: 378981 usec, Minimum Latency: 1061 usec, Avg Latency: 2754 usec

Starting read test. Please wait up to a minute
Read 1053.00 KB/sec
Maximum latency: 3580 usec, Minimum Latency: 506 usec, Avg Latency: 969 usec

//
//96 MHz, 2048 buffer
Use a freshly formatted SD for best performance.
Type any character to start
Free RAM: 8103
Type is FAT32
File size 10MB
Buffer size 2048 bytes
Starting write test. Please wait up to a minute
Write 671.34 KB/sec
Maximum latency: 566246 usec, Minimum Latency: 1708 usec, Avg Latency: 3048 usec

Starting read test. Please wait up to a minute
Read 1794.39 KB/sec
Maximum latency: 3758 usec, Minimum Latency: 1077 usec, Avg Latency: 1140 usec

//
// 96 MHz, 4096 buffer
Use a freshly formatted SD for best performance.
Type any character to start
Free RAM: 4007
Type is FAT32
File size 25MB
Buffer size 4096 bytes
Starting write test. Please wait up to a minute
Write 1134.62 KB/sec
Maximum latency: 564823 usec, Minimum Latency: 2293 usec, Avg Latency: 3608 usec

Starting read test. Please wait up to a minute
Read 2091.52 KB/sec
Maximum latency: 3569 usec, Minimum Latency: 1934 usec, Avg Latency: 1957 usec

//
// 96 MHz, 6144 buffer
Use a freshly formatted SD for best performance.
Type any character to start
Free RAM: 4007
Type is FAT32
File size 25MB
Buffer size 6144 bytes
Starting write test. Please wait up to a minute
Write 1158.42 KB/sec
Maximum latency: 566788 usec, Minimum Latency: 3422 usec, Avg Latency: 5301 usec

Starting read test. Please wait up to a minute
Read 2211.80 KB/sec
Maximum latency: 4473 usec, Minimum Latency: 2666 usec, Avg Latency: 2776 usec

//
// 96 MHz, 8192 buffer
Use a freshly formatted SD for best performance.
Type any character to start
Free RAM: -89
Type is FAT32
File size 25MB
Buffer size 8192 bytes
Starting write test. Please wait up to a minute
Write 1573.72 KB/sec
Maximum latency: 19035 usec, Minimum Latency: 4467 usec, Avg Latency: 5202 usec

Starting read test. Please wait up to a minute
Read 2306.76 KB/sec
Maximum latency: 6149 usec, Minimum Latency: 3529 usec, Avg Latency: 3550 usec

//
// 96 MHz, 10240 buffer
Use a freshly formatted SD for best performance.
Type any character to start
Free RAM: -89
Type is FAT32
File size 25MB
Buffer size 10240 bytes
Starting write test. Please wait up to a minute
Write 1454.43 KB/sec
Maximum latency: 23946 usec, Minimum Latency: 5330 usec, Avg Latency: 7037 usec

Starting read test. Please wait up to a minute
Read 2325.41 KB/sec
Maximum latency: 6096 usec, Minimum Latency: 4255 usec, Avg Latency: 4401 usec


I am using 'Arduino 1.0.5', with 'Teensy Loader 1.15'.

Ben
08-19-2013, 08:42 PM
Hi everyone,

I made a micro SD adaptor that can be soldered directly to the T3, or you can use stackable headers (like the arduino shields use). Since the T3 is 3.3 Volt native, there is no need for a level shifter / buffer.
When soldered directly to the T3 the adaptor covers the reset button in the T3, that's why I added another reset button to the adaptor (and desoldered the original one on the T3).
There is also room on the PCB for a decoupling cap to stabilize the 3.3 Volts right at the sd card and also room for an LED that lights up when the card is being accessed (precisely: when the chip select is pulled low). I have not yet populated these parts of the board, only the microSD-slot itself, but I wanted to share this with you anyway.
Here are some pictures:

833

834

835

836

837

Ben

Dave X
02-14-2014, 07:49 PM
I took the PJRC SD adaptor and put a 7-pin right-angle header on it with the two extra pins extending beyond MISO, I then connected the +5V to the pin adjacent to MISO and the pad next to the 'V' in '3V' to the other pin. I can use the same adapter with both 5V and 3V systems without unsoldering the pads. For a Teensy2.0 and Teensy++ 2.0, you can plug it into a breadboard jumper-free and supply power and ground through the adjacent output pins.

For the Teensy 3, putting a 3.3V pin next to GND could minimize the jumpers--configure pin 9 for CS, and jumper pin 10 across to pin 13, then pinMode(8,OUTPUT);pinMode(7,OUTPUT);digitalWrite(7 ,HIGH) to turn the SD card on.

It might be nice to add the MISO/MOSI/SCKL/SC/GND and +5V/SW to the silkscreens for this part. And if you moved SW one hole middle-wards and connected CK to the corner pin, it could piggyback on the Teensy 3.x.

pawelsky
04-25-2014, 06:53 PM
Here is a Teensy 3.x uSD shield I've made for one of my projects. It fits nicely underneath the Teensy board.

1881 1882

(second picture shows it installed together with a CAN bus shield that I've made as well)

keeb
06-13-2014, 09:10 PM
After realizing that the Teensy3.x can talk directly to SD/microSD cards without all that level shifting business, I figured I could make an adapter pretty easily. I'm posting this here as a reference for others who might happen to be as cheap as I am. This worked with the two different cards I had readily available using both the standard arduino SD library and the SDfat library. If anybody sees any problems or has some way to make this better, fire away. P.S. I've not tested this with Teensy3.1 yet, but I see no reason why it would make any difference whatsoever between the two revisions.

Only pins 1,2,3,4,5, & 7 are used

2216



Female stackable headers 0.1" spacing fit with no modification. It's a little bit of a close fit, but if you are careful with the soldering, you can keep the plastic melting carnage to a minimum. I didn't bother soldering anything to pins 8 and 9

2217


This is how I made my connections:
Adapter ---> Teensy3.x
1 CS ---> Pin 10 (CS)
2 DataIn ---> Pin 11 (DOUT)
3 Vss (GND) ---> GND
4 Vdd (3.3v) ---> 3.3v
5 SCLK ---> Pin 13 (SCK)
7 DataOut ---> Pin 12 (DIN)

2218

linuxgeek
06-14-2014, 01:47 AM
That's pretty cool!

So you are using the SD adapter portion as a slot for exchanging the microSD card.

keeb
06-14-2014, 03:37 AM
Thanks. Yep, it can be used any way one would use any of the many SD breakout boards available (as long as it is used with 3.3v signals).

dlchambers
07-04-2014, 12:22 PM
Paul, could you kindly provide the mfr (Hirose?) and part # for the SD connector on the board?
(board: http://www.pjrc.com/teensy/sd_adaptor.html)
It kinda looks like this: http://www.digikey.com/product-detail/en/DM3D-SF/HR1941CT-ND/1786515

keeb
07-04-2014, 01:00 PM
I can't verify this, but in a separate thread it was said to be the Hirose DM3D-SF (the same one you've linked to).

stim
10-13-2014, 09:58 AM
If you use a 2-row pin header cut to size...

2778

...and slightly bend the top pins inwards....

2777

...you have a super-simple breadboard friendly SD adaptor that allows easy card insertion/removal.

foniars
10-15-2014, 08:40 AM
I am using the cardinfo program but I get this error:

Sd2Card.cpp:77:2: error: #error "MK20DX128 bus frequency must be 48 or 24 MHz"

What do I need to change here to get rid of it?

sumotoy
04-05-2015, 02:43 PM
If you use a 2-row pin header cut to size...

2778

...and slightly bend the top pins inwards....

2777

...you have a super-simple breadboard friendly SD adaptor that allows easy card insertion/removal.


I will like to thanks for this! It's the best SD holder I've tried and actually the only one that really works!

Mike_58
04-05-2015, 03:37 PM
Hello Paul,
Adafruit 2.8" TLT & microSD pins to Teensy 3.1 - see sketch bellow;
- is 3,3V needed ? and where to connect RST to Teensy
4016
Thanks,
mike

KurtE
04-05-2015, 05:37 PM
Paul, can answer better than I can!

The Reset Pin on the T3.1 is on the bottom of the board, with a small pad, that you can solder a wire to and then connect it to the Reset circuit. However warning, that pad is fragile and I have had the wire I soldered on the T3.1 pull the pad off on a couple of occasions. Alternatively there are spring loaded pins (pongo ?) that you can get that solder into the board and use spring pressure pushing up to make contact. I have not personally tried them yet. Not sure how much clearance these need on the top and bottom of the board to work.

Good Luck.

PaulStoffregen
04-05-2015, 11:43 PM
On Arduino, the reset button has something of a dual personality. It can be used to put the Arduino into programming mode, or to reboot the board to your application, after a delay when the programming mode gives up.

On Teensy, the programming mode doesn't time out. So you really need to decide what the purpose of the RST signal really is. Or you could design a jumper or switch onto your board, if you can't decide, or wish to change your mind later.

Mike_58
04-06-2015, 04:04 AM
Hello,
I don't think my question was clear enough and therefore the answers are kind of confusing..
Let me put the question this way:
1) On Arduino Touch Shield 2.8" touch screen shield there is a microSD card socket installed and connected to the same pins (Pin 11, 12, 13) as the TFT (correct ??).

In addition to this pins (11,12,13) ->> which TFT pins I need to wire-up to Teensy3.1 to get the SD card running?

2) After studying the schematics from TFT 2.8" Touch ShielD I see that my above PCB wire up to Teensy3.1 is completly wrong becouse ICSP /SPI on TFT 2.8" I do not need to use because I have pins (Pin 11, 12, 13) already ready to use for SD but I need some additional
--->> which ones would be needed to connect in addition to Teensy3.1??

Thanks,
Mike

PaulStoffregen
04-07-2015, 09:09 PM
Mike, which display are you using? I see "Adafruit 2.8" TLT & microSD" in msg #58 and "Arduino Touch Shield 2.8" touch screen shield" in msg #61. You mentioned the schematic too.

Can you please post a link to the exact product you really have, and a direct link to its schematic. I can take a look and try to give you some specific advice. Direct links to the correct technical info would really help me to try to help you.

AJMatt
04-07-2015, 10:58 PM
First, thanks Ztik for making the guide.

Now my problem. I'm trying to use a microSD card (Samsung 16GB Evo SDHC) to record data from an MPU9250 from Invensense via Teensy 3.1. I've got everything wired up correctly, as far as I can tell and I've done about 10 times now, and I'm using the CardInfo example from Arduino. However, as I watch the serial monitor, it keeps saying that it can't find the microSD card. I've tried another card as well, no dice. I've contemplated using some of the clever ideas here in this thread utilizing microSD to SD adapters but the one that I have I need to read the data on my laptop from the microSD. Is there a way to tell if the Teensy adapter is faulty?

Thanks

Mike_58
04-08-2015, 01:50 AM
Hello Paul,
I am using 2.8TFT Touch Shield Arduino Resistive Touch ID: 1651 with micro SD.
I have made a PinOut as per EagleCad from your web and MIRRORED the 2.8 as it is installed on my carrier PC board for Teensy3.1
4030 4031

Pls refer as well to;
https://forum.pjrc.com/threads/25718-Adafruit-2-8-quot-TFT-Touch-Shield-for-Arduino-for-Teensy-3-1?p=69925#post69925 see #36& #37

Here the overall picture in real life;
4032

I hope this will work now - I will need some support with the code for microSD and data-logging!!

Thanks,
Mike

rafaelmizrahi
05-14-2015, 05:10 PM
I connected the microUSB adapter hack (@keeb member) to OctoWS2811 + Teensy 3.1
Uploaded the program VideoSDcard.ino using arduino 1.6.4

The serial monitor prints "Could not access SD card"
Do I need to cut the pins like suggested at
https://github.com/PaulStoffregen/OctoWS2811/blob/master/examples/VideoSDcard/hardware.jpg

PS. I ordered "WIZ820io & Micro SD Card Adaptor" but my project is in a rush and I cannot wait weeks for it to arrive.

rafaelmizrahi
05-15-2015, 02:52 PM
OK. it works.
I connected the microUSB adapter hack to OctoWS2811 + Teensy 3.1 + VideoSDcard.ino

Wiring:
* The SD CS leg goes to OctoWS811 pin 4 (and not to 10, as the original example, which is good too, but for teensy only)
* Followed the instructions at
https://github.com/PaulStoffregen/OctoWS2811/blob/master/examples/VideoSDcard/hardware.jpg
by
disconnecting teensy pin 3 and pin 4 from octows2811, and
attaching teensy pin 3 to octows2811 pin 4 and
octows8211 pin 4 to SD CS.

I had another problem with the program which used to hang on memcpy.
I am using width 145 and height 24.
To workaround this memory issue, I marked out the audio lines from the program, and it released some more memory, and now the program works with no issue.

tenkai
06-15-2015, 05:40 PM
I am having a problem increasing the buffer size for my microSD implementation.

When I use a 1022byte buffer, everything works fine:




Use a freshly formatted SD for best performance.

Type any character to start
Free RAM: 58235
Type is FAT32
Card size: 31.91 GB (GB = 1E9 bytes)

Manufacturer ID: 0X3
OEM ID: SD
Product: SL32G
Version: 8.0
Serial number: 0X8D4E026
Manufacturing date: 6/2014

File size 1 MB
Buffer size 1022 bytes
Starting write test, please wait.

write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
324.31,130960,1268,3144

Starting read test, please wait.

read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
1177.29,4108,424,866
1182.86,899,424,863
1182.86,900,424,863
1182.86,900,424,863
1182.86,900,423,863


but when I increase it to 1024, I get read errors (0x3, 0x7, sometimes 0x1, 0x3)




Use a freshly formatted SD for best performance.

Type any character to start
Free RAM: 58235
Type is FAT32
Card size: 31.91 GB (GB = 1E9 bytes)

Manufacturer ID: 0X3
OEM ID: SD
Product: SL32G
Version: 8.0
Serial number: 0X8D4E026
Manufacturing date: 6/2014

File size 1 MB
Buffer size 1024 bytes
Starting write test, please wait.

write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
426.92,132825,1544,2394

Starting read test, please wait.

read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
error: read failed
SD errorCode: 0X3,0X7


I am using a Sandisk Ultra 32Gb HC card. Is this a problem with my card? I only have one to test right now. I just ordered a samsung Evo to see if that helps my situation...

raymondw
06-23-2015, 10:43 AM
Hope it is oké to reuse this threat for a question.

I have a couple of Teensy 3.1 boards for a GPS logging project I started.
On my breadboard I just used a DX/Banggood microSD adapters and before that just a soldered SD adapter.
With my portable prototype I choose to use more PJRC and EU sourced parts.

And now the trouble starts...
The microSD cards I used on my breadboard didn't function in the PJRC sd-slot, after some searching I found this threat.
Is there a simple way to get my other sd-card brands to work with the PJRC adapter or am I bounded to the Sandisk cards? (confirmed working)
Or do I need to switch to the China sourced no-name sd-slot adapters?

The small increase in investment when using the PJRC is not the issue, it's the loss of flexibility as it is quite possible my final design will ship across the globe.
I can't guarantee that they will sell THAT sd-card in the country where I ship the unit to...

GremlinWrangler
06-23-2015, 11:25 AM
First up, is this the SD card socket with level converters? The Teensy3 runs at 3.3 volts natively so works fine connected directly to the SD card, where the SD adaptor boards level convert to 5V for the Teensy 1/2 and Uno.

Otherwise most likely issue with SD cards is either incorrect formatting prior to using them or trying to use cards that are too large. I think there can also be issues using the latest high speed cards that try and run an internal clock as well. So you and your customers are not restricted to Sandisk, but are restricted to older(or at least cheaper spec) and smaller cards.

See https://github.com/greiman/SdFat
and
http://www.arduino.cc/en/Reference/SDCardNotes

raymondw
06-23-2015, 11:43 AM
It is the latest available for the Teensy 3 : http://floris.cc/shop/en/teensy/992-micro-sd-card-adaptor.html

Funny thing is that the cards that don't work are "old" Sandisk Premier TF 2GB and unbranded class-4 4GB models.
Used them for XenServer in the past, so I formatted the old cards with the SdFat library to make sure/test they would function. (Formats correctly in the breadboard setup)
Bought a new Transcend class-10/HC-1 16GB card yesterday to try something else, same issue... (Formats correctly in the breadboard setup)

Card that is working is a SanDisk Ultra HC-1 16GB that I received months ago and normally use for my RPI-2

GremlinWrangler
06-23-2015, 11:56 AM
Ok, that one has a level converter on it so look like you have a couple of cards that can tolerate the out of spec voltages while the others can't. If you want you can covert that one by jumpering the level converter IC or keep it for another project and plan on using a straight card socket for your current design.

raymondw
06-23-2015, 12:07 PM
At the backside there is an 3V solder option : http://floris.cc/shop/1290-thickbox_default/micro-sd-card-adaptor.jpg
That one is closed already.

Or do I need to change something else?

stevech
06-23-2015, 04:12 PM
uSD cards I work with are fine with 3.3V for Vcc

Constantin
06-23-2015, 05:11 PM
3.3V is not the issue. However, the current source may or may not have the oomph to make it happen. Running a TFT and a SD card off a Teensy power supply is unlikely to have a happy ending.

For that reason, I always use a external voltage regulator and a series of capacitors (0.1 and 10uF) for a SD card power supply. I am also a big fan of the Yamaichi PTH micro-SD card holder. The only (AFAIK) through-hole micro-SD card holder available (PJS0008).

stevech
06-23-2015, 08:58 PM
I've seen uSD read mode power consumption of about 20-30mA and write mode 60-100mA. Sleep mode < 1mA. Indeed, uSD can be power hungry for a 100mA source with other loads too.

BJB
06-25-2015, 07:55 PM
Very true. For datalogger design did last year, gave up on the non-deterministic response to lo-pwr mode commands for the various peripheral ICs so used logic-level FETs as series power switches to turn various stuff on/off as needed. The only code-monkeying left to do was controlling lo-pwr modes for the T3.1 itself and buffering blocks of data for burst writes. Sometimes the shortest route is to just do it in hardware.

BTW, most of my uSD block writes consumed approx 155 mA peak. Those little memory cards are piggies.

Constantin
06-25-2015, 10:32 PM
BTW, most of my uSD block writes consumed approx 155 mA peak. Those little memory cards are piggies.

Wow. Thank you for measuring. I'm on the verge of adding a dedicated power supply just for the uSD! :)

The good news is that the TLV70233 (http://www.mouser.com/ds/2/405/tlv702-558090.pdf) I like to use is good for 300mA, assuming I've done my homework right. Should leave ample for the uSD, esp. in conjunction with decoupling caps at 0.1, 10, and 47uF nearby.

raymondw
06-26-2015, 08:21 PM
Busy with work last couple of day's
Seen all the mails and really appreciate the info!

Had some spare time this evening and removed the Teensy SD card reader.
Replaced it with a SD to uSD plastic adapter card which I got with a new uSD card.

No more errors in my sketch
Logged NMEA data from my GPS

SdFormatter and SdInfo are working
Formatted 2, 4, 16 and 32GB cards

For the time being I can use my proto device and I will order a new Teensy card reader.

More info/feedback in August when I return from my holiday:cool:

nhk
09-02-2015, 04:21 PM
Hi Paul,
Is there a way to use the SD adaptor or the TEENSY3_AUDIO adaptor + W25Q128FV device to increase code space? I am looking for min 2MB of code space.

Thanks in advance

Cosford
09-02-2015, 04:44 PM
That's a lot of code space; what is it for? There may be a better solution than a solitary Teensy.

nhk
09-02-2015, 04:49 PM
Hi Cosford,
I am planning to use the code space for video processing. Prefer to have video routines, some of which require local memory for processing. Perhaps, SD is not the appropriate type ... may be more DRAM? But DRAM requires too many interface pins..Still trying to figure out anoptimum way to do that (SD - slow, DRAM-fast.. etc)

Thanks

MichaelMeissner
09-02-2015, 05:06 PM
I would imagine if you are doing video processing, it is better to do it on a machine with much more memory, hardware floating point, a faster clock rate, and probably a dedicated graphics processor (GPU). A Raspberry Pi 2.0, Beagle Bone Black, or pcDunio might be easier to handle video than a Teensy. If you need real time processing, then consider doing the real time stuff in the Teensy and the video stuff on the Pi/BBB/etc. You would use some sort of communication between the two parts (serial uart, i2c, spi, etc.).

Even without the code limitations, a Teensy 3.1 can only store maybe 8 frames of 1080p video (1920 x 1080 x 3 bytes is 5-6 megabytes) in read/write memory.

Frank B
09-02-2015, 05:17 PM
Hi Paul,
Is there a way to use the SD adaptor or the TEENSY3_AUDIO adaptor + W25Q128FV device to increase code space? I am looking for min 2MB of code space.

Thanks in advance

The only way would be to copy small parts to the ram and execute there. This is not very practical...

PaulStoffregen
09-02-2015, 10:29 PM
I'm confused. The request says "increase code space", but then talks about needing "local memory for processing" video.

There seems to be a lack of info about the video data, whether it's live real-time streaming or stored on media, whether real-time or offline processing is to be done, or even what that processing might be, or what sort of format, resolution, frame rate and compression is used. Lack of such details really takes away any sort of context which could allow better understanding of this memory request.

In general, I'd agree with MichaelMeissner, that with today's technology, single-board computers like Beaglebone and Raspberry Pi are much better for most video processing. In a few years, as microcontrollers start moving to smaller than 90 nm transistors and superscaler processor cores like Cortex-M7, real-time video processing will become much more feasible.

raymondw
09-17-2015, 06:12 AM
Busy with work last couple of day's
Seen all the mails and really appreciate the info!

Had some spare time this evening and removed the Teensy SD card reader.
Replaced it with a SD to uSD plastic adapter card which I got with a new uSD card.

No more errors in my sketch
Logged NMEA data from my GPS

SdFormatter and SdInfo are working
Formatted 2, 4, 16 and 32GB cards

For the time being I can use my proto device and I will order a new Teensy card reader.

More info/feedback in August when I return from my holiday:cool:

Just to inform everybody I could not fix the Teensy SD reader issue... despite the fact I ordered a new one.
I also ordered a Sparkfun SD reader to test and it works like a charm.
So somewhere in my design there is something different with the two boards.

As this is a prototype design I will leave it as-is, my final design will have an "insert brand here" push-push slot directly on the pcb. ;)

Po Ting
12-30-2015, 01:00 AM
Hello, I'm meeting up a problem with micro SD,
with SD library from arduino, 1.6.5 , teensy loader 1.25 beta-2, and teensy 3.1

example->SD->listfile.ino
with chip select set to pin 10, (as I use 10,11,12,13 for the pins)
it seems like if I switch the setting to more than 24Mhz I got a "initialization failed!"
clock equal or lower than 24Mhz, i got my files printed out fine
and however teensy LC works properly with 48MHz clock.

Then I tried on SdFat library, with the similar file lister.

example->SD->OpenNext.ino
found that it worked properly with sd.begin(chipSelect, SPI_HALF_SPEED)
and everything went wrong with sd.begin(chipSelect, SPI_FULL_SPEED) && Clock above 24Mhz

and with the bench example (i didnt get any read speed, seems the example ino was different than the previous of this thread)
I get the results (KB/Sec,usec,usec,usec) 251.04,97473,1074,2030 on both teensy 3.1 and LC( with the clock setting as high as it could)
which were pretty close or slighty faster than other results at previous of the thread

so I have to ask: is this due to the limit speed of the microSD card(with SPI?) , or are there any faster library exist?

subitoit
01-04-2016, 10:42 AM
Oh yes... I'm not sure what I was thinking....2MB/Sec is still plenty fast for my application.

Thanks for the additional information... I'll give it a try later tonight

Po Ting
01-04-2016, 09:16 PM
Just wondering also, I've read through the post at Teensy-Quick-Reference-Code-Examples and found no library about DMA

http://www.stm32duino.com/viewtopic.php?t=20
the link above is about a SDFAT modified library with DMA, but used on stm32
not sure if it can use in teensy? and would it be faster , or not?