Mega 2560 TFT screen SD problem

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
ProEV
 
Posts: 7
Joined: Sun Feb 12, 2012 4:29 pm

Mega 2560 TFT screen SD problem

Post by ProEV »

Hi,

I can't get past initializing my mini SD card. I am using a MEGA 2560, Ardinio 1.0 and the adafruit 2.8 TFT touch shield with built in mini SD.

I have done as below:

in libraries\SD\examples\CardInfo\Cardinfo.pde
CODE: SELECT ALL
// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 10;   

and in libraries\SD\utility\Sd2Card.h
CODE: SELECT ALL
/**
* Define MEGA_SOFT_SPI non-zero to use software SPI on Mega Arduinos.
* Pins used are SS 10, MOSI 11, MISO 12, and SCK 13.
*
* MEGA_SOFT_SPI allows an unmodified Adafruit GPS Shield to be used
* on Mega Arduinos.  Software SPI works well with GPS Shield V1.1
* but many SD cards will fail with GPS Shield V1.0.
*/
#define MEGA_SOFT_SPI 1

I then ran Cardinfo with a Mega 2560 and the TFT touch shield.

Initialization failed. I tried a 4 gig card from Centron and a 2 gig SanDisk formatted to Fat32 and FAT. Neither formatted either way worked

Suggestions?

Thanks

Cliff

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Mega 2560 TFT screen SD problem

Post by adafruit »

please try it with a classic Arduino UNO first

ProEV
 
Posts: 7
Joined: Sun Feb 12, 2012 4:29 pm

Re: Mega 2560 TFT screen SD problem

Post by ProEV »

I dug out an UNO and changed
#define MEGA_SOFT_SPI 1 back to 0
The CardInfo sketch read the card when I stuck it in.

I then closed everything down and changed
#define MEGA_SOFT_SPI 0 back to 1 to see if that made a difference.
I re uploaded CardInfo and the card did not initialize.

I closed everything down and changed
#define MEGA_SOFT_SPI 1 back to 0
Re upload CardInfo and, to my surprise, the mini SD would not initialize.

I quick formatted the card on a windows computer. No change
I formatted the card on a windows computer. No change

Ideas?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Mega 2560 TFT screen SD problem

Post by adafruit »

did you try the BMP drawing example at any point?

ProEV
 
Posts: 7
Joined: Sun Feb 12, 2012 4:29 pm

Re: Mega 2560 TFT screen SD problem

Post by ProEV »

No. I have not tried the BMP example.

It is possible that I might have had const int chipSelect = 4; rather than 10 in the CardInfo sketch the first time with the UNO when it worked but now I have tried it both ways and had no luck

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Mega 2560 TFT screen SD problem

Post by adafruit »

you should try the BMP example and see if it works

ProEV
 
Posts: 7
Joined: Sun Feb 12, 2012 4:29 pm

Re: Mega 2560 TFT screen SD problem

Post by ProEV »

The tiger BMP works with the UNO.

The serial says Initializing SD Card...SD OK!

Why does this work and not the other?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Mega 2560 TFT screen SD problem

Post by adafruit »

the pins are shared by the TFT, check the sketch for details on how to use the SD card while the TFT is also connected

ProEV
 
Posts: 7
Joined: Sun Feb 12, 2012 4:29 pm

Re: Mega 2560 TFT screen SD problem

Post by ProEV »

Thanks,

That helped. The key is to enable and disable the SPI depending on whether I want to display or write to SD.

I now have my Mega 2560 reading an analog pin, displaying the reading and writing it to the mini SD card.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”