2.8 tft touchshield not reading MicroSD

by JQ21 on Fri Mar 29, 2013 8:27 pm

Hi,

I'm trying to get the 2.8" tft touchshield to read a microSD card that I bought form a electronics shop (commonly used for datalogging). But when I run the "cardInfo" sketch on my Arduino Mega 2560, it doesn't recognize it. I've downloaded the most recent library and changed the #define MEGA_SOFT_SPI to "1" and still it doesn't recognize the card. I've also tried to get the Tiger bmp to work, but its not working either. Please help, thanks.

-JQ
JQ21
 
Posts: 4
Joined: Mon Jan 28, 2013 3:30 pm

Re: 2.8 tft touchshield not reading MicroSD

by adafruit_support_mike on Fri Mar 29, 2013 11:11 pm

There's enough wiggle room in the SD card specs that compatability problems do exist. There's also an unpleasantly large percentage of dud cards and fakes, depending on where you go for your supply.

Just to check one obvious possibility, have you connected the card to some other device (your computer or a camera) and gotten it to work?
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9037
Joined: Thu Feb 11, 2010 1:51 pm

Re: 2.8 tft touchshield not reading MicroSD

by JQ21 on Sun Mar 31, 2013 7:52 pm

Yes, I've connected the microSD to my computer and am able to copy an image onto the card.

-JQ
JQ21
 
Posts: 4
Joined: Mon Jan 28, 2013 3:30 pm

Re: 2.8 tft touchshield not reading MicroSD

by adafruit_support_mike on Mon Apr 01, 2013 12:44 pm

Okay, at least we know the card works. I'm not up to date on the compatibility between this shield and the Mega though, so let me pass the question over to Phil, who seems to have done the most recent update to the library.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9037
Joined: Thu Feb 11, 2010 1:51 pm

Re: 2.8 tft touchshield not reading MicroSD

by pburgess on Mon Apr 01, 2013 1:48 pm

Strangeness.

First, are you using a recent version of the Arduino IDE? (1.0 or later)

Next, make sure you're only using the stock SD library included in the Arduino distribution, and not the Adafruit one on Github. Multiple instances may cause confusion as to which one is actually in use (e.g. MEGA_SOFT_SPI may be #defined in one but not the other). So if you have one in your sketchbook/libraries folder, remove it for the time being. Restart the IDE. Make sure the correct board type is selected from the 'Tools->Board' menu.

In the canonical SD library (the one included with the Arduino IDE), #define MEGA_SOFT_SPI 1 in Sd2Card.h, line 42 or so:
Code: Select all | TOGGLE FULL SIZE
#define MEGA_SOFT_SPI 1


In Adafruit_TFTLCD.h, make sure the USE_ADAFRUIT_SHIELD_PINOUT line is enabled (line 18 or so):
Code: Select all | TOGGLE FULL SIZE
#define USE_ADAFRUIT_SHIELD_PINOUT


In the example sketches, SD_CS (card select) should be pin 5. Ignore all the other comments about pin 10, pin 53, etc. Should be five. Period.
Code: Select all | TOGGLE FULL SIZE
#define SD_CS 5


This is where it gets weird...

Something in the SD library is not quite right, and I haven't been able to pin it down. But there's a workaround...

#include the Adafruit_GFX and Adafruit_TFTLCD libraries, and declare an Adafruit_TFT object, even if you don't plan to use it. This sets something up in the pin states that the SD library alone seems to be overlooking. Or something. A minimal example:
Code: Select all | TOGGLE FULL SIZE
#include <SD.h>
#include <Adafruit_GFX.h>
#include <Adafruit_TFTLCD.h>

#define SD_CS 5
Adafruit_TFTLCD tft;

void setup() {
  Serial.begin(9600);
  Serial.print("Initializing SD card...");
  if (!SD.begin(SD_CS)) Serial.println("failed!");
  else                  Serial.println("OK!");
}

void loop() { }


I don't like "voodoo" fixes, but it's all I can offer at the moment.

If you still don't get an "OK" out of the above code, then the card format is just a little strange (such that the computer can see it but the SD library can't) -- this happens when different OSes take liberties with the SD specification, but I digress. If you have a digital camera, try popping the card in there and reformatting. If that's still not it, try popping it in a different digital camera and formatting. Or if the card came formatted from the shop, try reformatting it on your computer.
User avatar
pburgess
 
Posts: 2515
Joined: Sun Oct 26, 2008 1:29 am

Re: 2.8 tft touchshield not reading MicroSD

by JQ21 on Tue Apr 02, 2013 12:51 pm

Thank you so very much Pburgess, you're awesome!!! You saved me.

-JQ
JQ21
 
Posts: 4
Joined: Mon Jan 28, 2013 3:30 pm



cron