• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino MEGA i karta SD
#1
Witam,

Mam problem z inicjacją karty SD na Arduino MEGA.

Napisałem krótki programik do sprawdzania inicjacji karty SD.
Na Arduino UNO z shieldem TFT 2.4 + SD, jest wszystko OK.
Pojawia się taki komunikat:

SD CARD TEST:
INITIALIZE...
OK!


Natomiat na Arduino MEGA z tym samym shieldem mam taki komunikat:

SD CARD TEST:
INITIALIZE...
Failed!


Możecie mi podpowiedzieć dlaczego nie działa na Arduino MEGA?

Poniżej kod:
Kod:
//----------------------------------------------------------------------
//          SD TEST - Sprawdzenie obsługi karty micro SD.
//----------------------------------------------------------------------

//-------------------------- Wyświetlacz TFT ---------------------------
#include <SPFD5408_Adafruit_TFTLCD.h>
#include <SD.h>

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

#define SD_CS 10

#define BLACK   tft.color565(0,0,0)
#define RED     tft.color565(255,0,0)
#define GREEN   tft.color565(0,255,0)
#define BLUE    tft.color565(0,0,255)
#define YELLOW  tft.color565(255,255,0)
#define ORANGE  tft.color565(255,153,51)
#define WHITE   tft.color565(255,255,255)

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

//-------------------------- Ustawienia programu -------------------------
void setup(void)
{
 Serial.begin(9600);

 tft.reset();
 tft.begin(0x9341); // SDFP5408
 tft.setRotation(3);
 tft.fillScreen(BLACK);

 tft.setTextColor(WHITE);
 tft.setTextSize(3);
 tft.setCursor(30, 30);
 tft.println("SD CARD TEST:");

 tft.setCursor(30, 60);
 tft.println("INITIALIZE...");

 tft.setCursor(30, 90);
 if (!SD.begin(SD_CS))
 {
   tft.println("Failed!");
   return;
 }
 tft.println("OK!");
}

//------------------------- Pętla główna programu -------------------------
void loop(void)
{
}
Jeżeli pomogłem, to poproszę o punkt reputacji Big Grin
 
Odpowiedź
#2
Myślę że problem jest z pinem SD_CS.
Pomoc techniczna (https://www.arduino.cc/en/Reference/SD) podpowiada:
Cytat:The communication between the microcontroller and the SD card uses SPI, which takes place on digital pins 11, 12, and 13 (on most Arduino boards) or 50, 51, and 52 (Arduino Mega). Additionally, another pin must be used to select the SD card. This can be the hardware SS pin - pin 10 (on most Arduino boards) or pin 53 (on the Mega) - or another pin specified in the call to SD.begin(). Note that even if you don't use the hardware SS pin, it must be left as an output or the SD library won't work.
Pomagam za darmo więc szanuj mój czas.
Wklejaj tekst a nie jego zdjęcie.
Nie pisz następnego postu jak nie odpowiedziałeś na poprzedni.
Jak mądrze zadawać pytania
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości