Using SparkFun microSD card adaptor with Teensy 3.2

Status
Not open for further replies.
Hello
I have just purchased a SparkFun " level shifting microSD breakout" (DEV-13743) and some Teensy 3.2's and have not had any luck seeing the card from various demos. I am sure the problems are due to my lack of understanding of Arduino Library management.

I have installed Arduino 1.6.8 and the beta teensydunio which should work with that. I am running under Linux Mint 17. Various other sketches work.

I have wired the breakout as per the drawing in the SparkFun site (see below) and use CS on pin 8.

I am testing the Examples -> SD -> CardInfo sketch and it builds and loads and runs but reports ....

Initializing SD card...initialization failed. Things to check:
* is a card inserted?
* is your wiring correct?
* did you change the chipSelect pin to match your shield or module?

I have checked those.

I am confused about how to know which SD.h (and others) are being used. There is one in the .../hardware/teensy... and one in /home/dave/Desktop/arduino-1.6.8/libraries/SD/src. I am also unsure how to force one or the other to be used.

I have done some searching on the forum and found a recommendation to "install the SDFat library". I downloaded the zip file from https://github.com/greiman/SdFat and extracted the SDFat folder and placed it in the Arduino libraries folder. I then loaded the sketch SDInfo. I fixed SD_CHIP_SELECT 8. It builds and gives the following output
SdFat version: 20150324

Assuming the SD is the only SPI device.
Edit DISABLE_CHIP_SELECT to disable another device.

Assuming the SD chip select pin is: 8
Edit SD_CHIP_SELECT to change the SD chip select pin.

type any character to start

cardBegin failed
SD errorCode: 0X1
SD errorData: 0X0

I have the board wired as follows
board teensy
Vcc Vin (There is 5 V on the breakout)
CS 8
DI 11
SCLK 13
DO 12
CD 9
GND GND

I can read and write the (new) microSD card by plugging it into the SD/microSD adapter and into my laptop reader.

Any suggestions?

Dave Heffler
 
Software setup seemed right - if you can find and run example blink then you are ready to move on.

For the PJRC adapter these directions would apply - https://forum.pjrc.com/threads/16758-Teensy-3-MicroSD-guide BTW: I found this forum link using a BING search - search engines are great for finding such links - actually in this case I knew PJRC had a card that I searched for - and then saw that Teensy 3 page linked from there . . .

The wiring interface should end up the same. Teensy is 3.3V - not sure if the 5V SparkFun board is 5V only or has level shifters to work as needed.
 
Last edited:
I've linked the schematic below. Looks to me like the Vin pin of the board runs into a 3V regulator. Not being familiar with that regulator, I'm not sure if it would function properly with a 3V3 input (I'm guessing not). It does have a level shifter to do SD 3V3 <-> Vin shifting, which should be fine with a 3V3 input (there's no need for the buffer in this case, but it should still work).

I would try connecting the Vin of the Teensy to the Vin of the breakout. If you haven't cut the trace on the back, Vin on the Teensy is ~5V from the USB line. EDIT: Or use the VUSB pin. For some reason I thought VUSB was only a tiny pad on the back... Use VUSB -> Vcc, rest of the pins as stated.

https://www.sparkfun.com/products/13743

View attachment Shifting_microSD_v10.pdf
 
Last edited:
I've linked the schematic below. Looks to me like the Vin pin of the board runs into a 3V regulator. Not being familiar with that regulator, I'm not sure if it would function properly with a 3V3 input (I'm guessing not). It does have a level shifter to do SD 3V3 <-> Vin shifting, which should be fine with a 3V3 input (there's no need for the buffer in this case, but it should still work).

I would try connecting the Vin of the Teensy to the Vin of the breakout. If you haven't cut the trace on the back, Vin on the Teensy is ~5V from the USB line. EDIT: Or use the VUSB pin. For some reason I thought VUSB was only a tiny pad on the back... Use VUSB -> Vcc, rest of the pins as stated.

https://www.sparkfun.com/products/13743

View attachment 6732

I am way too noob to actually understand what you said but i can confirm the following:

  • connecting the VUSB pin on Teensy 3.2 to Sparkfun's MicroSD breakout's VCC WORKS, as in, actually detects the card type, fat volume format etc.
  • connecting the Vin pin on Teensy 3.2 to Sparkfun's MicroSD breakout's VCC DOESN'T WORK, as in, card.init() fails)

All other pins are connected as in previous posts.

What i don't understand is the following: If i use Teensy 3.2's pin 13 for SCK (and connect it to the breakout's SCK), can i still use the on-board led? (when not having the micro-SD breakout connected, using the LED_BUILTIN constant, i can control the on board led).
 
  • connecting the VUSB pin on Teensy 3.2 to Sparkfun's MicroSD breakout's VCC WORKS, as in, actually detects the card type, fat volume format etc.
  • connecting the Vin pin on Teensy 3.2 to Sparkfun's MicroSD breakout's VCC DOESN'T WORK, as in, card.init() fails)

All other pins are connected as in previous posts.

What i don't understand is the following: If i use Teensy 3.2's pin 13 for SCK (and connect it to the breakout's SCK), can i still use the on-board led? (when not having the micro-SD breakout connected, using the LED_BUILTIN constant, i can control the on board led).

It sounds like you may have cut the trace on the back connecting Vin and VUSB, because they are connected as shipped from PJRC. If you have a multimeter, check the voltage on each of those pins when the board is powered, that may help sort that out.

As for the LED, if you want to use SPI and the LED, you will probably need to use the alternate SPI pins (check the card that should have come with your board - the alternate pins are in grey and can be set per this link). The SD library may or may not work with the alternate pins, I've never tried and honestly it will probably be simpler and better to just put an LED on a different pin and use the normal SPI pins for SPI.
 
Another option might be the device pulls more current than the T3 can supply at 3.3v I could not find any reference to the current requirements at 3.3 or 5.v, but hooking up to 5v as described above would bypass the 3.3v T3 regulator. The T3 3.2 is spec'd to supply 250 mA max.
 
Ok, let me get back with some more details. Please disregard the post i said that connecting Sparkfun's microSD's VCC to Teensy 3.2's 3.3V pin doesn't work. It does. I had some problems regarding either the breadboard i used or the jumper cables that i used to connect the devices.

Devices used:

* Genuino Uno
* Teensy 3.2
* Sparkfun Level Shifting microSD Breakout
- supports both 5V and 3V with level shifting
- should support SPI_FULL_SPEED
* SparkFun microSD Transflash Breakout
- no level shifting (will simply return the provided current 3V/5V on it's pins)
* 32Gb Samsung micro SD SDHC memory card

These are the results:

1. The Level Shifting breakout detects the card, however, it doesn't seem to be able to read the fat filesystem (i suspect it has something to do with the 32G card size?). Please note that the error is strictly related to the filesystem, cuz it said that wiring is ok (I'm using the SD/CardInfo sketch).
2. The Transflash Breakout detects the card (the same Samsung 32G above), understands the fat filesystem and does a proper / directory listing on the card.

Both breakouts are connected to Teensy's 3.3V, not the VUSB pin.
 
Wait, you mention the Genuino Uno there, are you having problems with the level shifting breakout on the Uno?

As for the Teensy, since you have the Transflash breakout is there a reason you're trying to use the level shifting breakout? The level shifting board just adds a bi-directional buffer chip to shift the voltage between devices that need different logic level. The Uno for example running at 5v presents and expects 5v, but the SD card needs to work at 3.3v and can be damaged by 5v. When you use the level shifting breakout you have on a 3.3v system you end up running the SD card with a little lower voltage yet - Sparkfun says 250mV drop, so 3v now, unless your 3.3v line wasn't up to snuff. Additionally the level shifting chip can add some delay and could cause a timing problem.

You mention card detect works. Well it turns out card detect is just some switch contacts built into the microSD holder. So it should work unless you have a physical wiring problem.

Detecting the card type, if it's making it that far, probably is happening at lower speed and with fewer transactions. Once you start reading the filesystem there is more data and requests going back and forth. The breakout has nothing to do with the file system, but could be introducing timing problems.

1. The Level Shifting breakout detects the card, however, it doesn't seem to be able to read the fat filesystem (i suspect it has something to do with the 32G card size?). Please note that the error is strictly related to the filesystem, cuz it said that wiring is ok (I'm using the SD/CardInfo sketch).
2. The Transflash Breakout detects the card (the same Samsung 32G above), understands the fat filesystem and does a proper / directory listing on the card.
 
Ok, let's just consider the following:

  • Level Shifter Breakout + Genuino Uno (connected to 5V)
  • Level Shifter Breakout + Teensy 3.2 (connected to 3.3V, not VUSB)

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

Card type: SDHC
Could not find FAT16/FAT32 partition.
Make sure you've formatted the card

Note: It's not that stable either, if you disconnect and re-connect the usb serial a number of times, like 5 ... 2 or 3 out of 5 will result in an error:
  • either with "...initialization failed. Things to check: ..."
  • shows card type as SD2 (although normally it says SDHC...)

I don't remember if i ever got it working to show the file list, because i wasn't sure how it was formatted (the card) at that time, and thought that going as far as detecting the card type (SDHC) would suffice (from the SPI point of view).

  • Transflash Breakout + Genuino Uno
  • Transflash Breakout + Teensy 3.2

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

Card type: SDHC

Volume type is FAT32

Volume size (bytes): 1927184384
Volume size (Kbytes): 1882016
Volume size (Mbytes): 1837

Files found on the card (name, date and size in bytes): 
...

Both tests used the same Samsung 32Gb SDHC microSD card, formatted with SD Formatter as FAT32.

Anyways, i guess i'll be using the Transflash Breakout and continue happily with my project :)
 
Last edited:
Status
Not open for further replies.
Back
Top