SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By jpsdr
#142257
I am attempting to interface a Pro Micro 3.3V with a SD card using Arduino 1.0. Since the voltage level is 3.3V I do not have a voltage level converter and have wired the SD card directly up to the SPI port with SS pin tied to the SD card CS. This setup has worked for me with other AVR processors running @ 3.3V. Before I've used the Arduino development platform (v22) and had no difficulties; however, with the Leonardo setup and Arduino 1.0, the application I created (which is basically the test read/write application) fails to initialize the card.

My question is has anyone been able to successfully initialize and read/write to a SD card with the Pro Micro series (32U4) of devices AND Arduino 1.0 using the included SD library? If so, any tips or suggestions would be appreciated.
By TCWORLD
#142277
I have had no problems with SD and a 3.3v arduino, but that is using the mega1280.

I had a look at the schematic diagram of the Pro Micro, and it seems someone decided to use the slave select pin as the RX led. I presume based on this that the bootloader has control of that pin. I am not sure how that will affect the SPI. As long as it is always set to an output, it should be ok.

What pin of the Pro Micro are you connecting you SS pin to? Make sure this pin is called in your program in the SD.begin(SS_Pin); call.
And also just to check, these are how the SPI pins appear on the board.
15 = SCK
17 = MISO
16 = MOSI

Hope that helps.
Last edited by TCWORLD on Thu Apr 05, 2012 3:54 am, edited 1 time in total.
By jpsdr
#142295
Thanks for your reply. I, too, have had no difficulties with SD & 3.3V arduinos using the 328 chips. Works flawlessly.

However, with the pro micro and the Leonardo setup, the SD card simply will not initialize when I use the SS_pin (as with all the other arduinos). I thought that the bootloader might be an issue, but I believe that it relenquishes control of that port after initial startup. Additionally, I do not call the SD.begin(SS_Pin) until after the user presses a button so it should be well beyond the timeframe that the bootloader is active (I think).

I have seen the definition of the SS pin as both pin 14 & 17 and tried both to no avail.
By TCWORLD
#142364
Try putting this into a sketch. If it prints something it will rule out something else I though might be an issue.
Code: Select all
#if defined(__AVR_ATmega32U4__)
Serial.begin(9600);
Serial.print("test");
#endif
The other thing is, where are you accessing the SS Pin from? D14 isnt broken out anywhere, unless you are using a different pin for it.

Another thing to check is where the program is failing. Is it that SD.begin() is returning false?
If so have you tried the CardInfo example sketch? That breaks down what is happening.
By jpsdr
#142398
Thanks for the ideas. I'll give it a try in a bit and report back.

As for the SS pin, I have it hooked directly up to the SS pin. My goal is to do the debugging on the Pro Micro card and ultimately migrating to a dedicated design.
By jpsdr
#142404
TCWorld,
I tried the code snippet you recommended and it worked. I received the message "test" when I ran it on the Arduino. Additionally, I used your recommendation to try out the CardInfo example. Sadly, that also returned an error that initialization had failed.
To add to the confusion, I thought I would try something radically different. I have an AVR mkII programmer and decided to try something else. I decided to try out the bootloader that is listed on Adafruit's site which is AVRdude compatible. On her site she also has an variant of the Arduino 0021 platform modified for the Teensy device (that is also a 32U4 based setup) and runs with the aforementioned bootloader. I used sdfat with reference to the same pins (SS being Chip Select) and it worked! I was able to initialize & read from the card without difficulty. In my excitement, I tried different cards and they all worked.
What this implies is that the wiring & setup I have is correct and I can only *presume* that there is an issue with the bootloader or the Arduino 1.0 platform. I would prefer to stick with the Leonardo based bootloader for it seems more robust than the other bootloader and Arduino environment I tried.
By jpsdr
#142447
Just an update. I *FINALLY* got it to work. It turns out there is a bug in the SD library in the Arduino 1.0 release. I downloaded the beta version of the most recent SDfat from http://code.google.com/p/beta-lib/downloads/list . There is a release http://code.google.com/p/beta-lib/downl ... p&can=2&q= (version 20120327...beta), that has revised handling of the SPI pins. Though, it is listed as beta, it worked just fine!
By reginr
#151505
Where is the best point to tap the SS pin?
Please see picture below.

Many thanks in advance!
You do not have the required permissions to view the files attached to this post.
By reginr
#151519
UPDATE:

0. Soldered the CS of Micro Card SD Breakout board to Point A of picture above
1. Downloaded SDFat from link above post.
2. Installed the library to Arduino
3. Restarted Arduino IDE
4. Uploaded from Sketch Library (Under SDFat) SDInfo
5. Saw the output, my SD card was recognized. Working! :)
By reginr
#152780
UPDATE

SD Library of ARDUINO 1.0 WORKS!
Just make sure you adjust the header file

libraries/SD/utility/Sd2Card.h
Change the values of pinout with the values below.

SS_PIN 10
MISO_PIN 14
SCK_PIN 15
MOSI_PIN 16

Also please note you can Solder the SS_PIN to Pin #10 No need to solder it at the LED @ POINT A (above picture)

Hope this helps some one some time :)
By s4i1mow6
#155579
I'm in the same situation, interfacing the Arduino Pro Micro 3.3V to the SparkFun µSD breakout.

Regnir's solution above didn't work for me, but here is the slightly modified version which did.

No soldered green wires, just breadboard connections to the SD breakout as follows:
CD -> No connection
DO -> Arduino Pin 14
GND -> Ground
SCK -> Arduino Pin 15
VCC -> VCC (regulated by the Pro Micro)
DI -> Arduino Pin 16
CS -> Arduino Pin 10

That leaves you with the non-standard pin assignments of the Pro Micro to clear up. For Arduino 1.0.1 on OSX, I opened /Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/Sd2PinMap.h and made the following substation:

I replaced:
Code: Select all
	#elif defined(__AVR_ATmega32U4__)
	// Teensy 2.0
	
	// Two Wire (aka I2C) ports
	uint8_t const SDA_PIN = 6;
	uint8_t const SCL_PIN = 5;
	
	// SPI port
	uint8_t const SS_PIN = 0;
	uint8_t const MOSI_PIN = 2;
	uint8_t const MISO_PIN = 3;
	uint8_t const SCK_PIN = 1;

With the slightly modified:
Code: Select all
	#elif defined(__AVR_ATmega32U4__)
	// Teensy 2.0
	
	// Two Wire (aka I2C) ports
	uint8_t const SDA_PIN = 6;
	uint8_t const SCL_PIN = 5;
	
	// SPI port
	uint8_t const SS_PIN = 10;
	uint8_t const MOSI_PIN = 16;
	uint8_t const MISO_PIN = 14;
	uint8_t const SCK_PIN = 15;
	
	/* // Original definitions
	uint8_t const SS_PIN = 0;
	uint8_t const MOSI_PIN = 2;
	uint8_t const MISO_PIN = 3;
	uint8_t const SCK_PIN = 1;
	*/

With this I was able to open up the example CardInfo sketch, change:
Code: Select all
const int chipSelect = 4;    
to
Code: Select all
const int chipSelect = 10;    
And connect to an inserted µSD card.
By sm11963
#159244
jpsdr wrote:Just an update. I *FINALLY* got it to work. It turns out there is a bug in the SD library in the Arduino 1.0 release. I downloaded the beta version of the most recent SDfat from http://code.google.com/p/beta-lib/downloads/list . There is a release http://code.google.com/p/beta-lib/downl ... p&can=2&q= (version 20120327...beta), that has revised handling of the SPI pins. Though, it is listed as beta, it worked just fine!
Can you elaborate on how you got it work with the SDFat library? It is not working for me. I can however get the regular SD library to work using s4i1mow6's solution. I would like to use the SDfat library for performance gains though. Thanks in advance for the help!