Pages: [1]   Go Down
Author Topic: SPI Issue  (Read 584 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 2
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have A 7" touchscreen SPI and it works perfect.

I also use the same due after reprogramming and rewire it  to write data i read from the SD card of my ethernet shield to  my SPI flash chip. winbond W25Q128FV
That works also perfect

When i load my code for the touchscreen and  test it. it works fine.
Disconnect the due from the power connect the ethernet shield also and start it up again. the screen isnt working anymore.
I have no idea which info i need to add right now. So i update it if you can tell me what you wanna know

Tried it the otherway around.

loaded the default SD example list files.
if the display is attacht i receive  Initializing SD card...initialization failed! at the SD.Begin
i connected the CS pin from the display to pin 32.
added the lines '

the display is connected with miso mosi sclk ss resetpin (LCD reset) 3,3v and gnd

I noticed the issue occure when the clock is connected.
If the SLCK line of the screen is disconnected the SD card stays reachable.


Code:
#include <SPI.h>
#include <SD.h>
File root;
void setup()
{
  Serial.begin(115200);
  while (!Serial) {
  }
pinMode(32,OUTPUT);
digitalWrite(32,HIGH);
SPI.begin(32);
SPI.begin(4);

  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  root = SD.open("/");

  printDirectory(root, 0);

  Serial.println("done!");
}

void loop()
{
}

void printDirectory(File dir, int numTabs) {
   while(true) {
     File entry =  dir.openNextFile();
     if (! entry) {
       // no more files
       break;
     }
     for (uint8_t i=0; i<numTabs; i++) {
       Serial.print('\t');
     }
     Serial.print(entry.name());
     if (entry.isDirectory()) {
       Serial.println("/");
       printDirectory(entry, numTabs+1);
     } else {
       // files have sizes, directories do not
       Serial.print("\t\t");
       Serial.println(entry.size(), DEC);
     }
     entry.close();
   }
}





Keep receiving
Code:
Initializing SD card...initialization failed!

Johan



« Last Edit: April 21, 2014, 09:02:40 am by jl-p » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm still pretty new at Arduino programming, And this may not have anything to do with your problem. But I noticed one thing in your program. You set up pin 32 As an output along with pin 10 Before you used it. But I see no such declaration for pin 4. Was this just an oversight in your description of the program, or have you forgotten to declare that pen function. 

Joe.
Logged

Offline Offline
Jr. Member
**
Karma: 2
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i checked the SD library the first thing it does when the you call begin is the pinmode command.
So therefor i didn't do it my self.


Johan
Logged

Offline Offline
Jr. Member
**
Karma: 2
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Still busy with the issue changed the following things but still failed to initialize SD card if the Touchscreen is connected.

or if i connect the clock line but not miso mosi it works
 although. communicating with the SD card.

Code:
#include <SPI.h>
#include <SD.h>

File root;
void setup() {
  Serial.begin(115200);
  pinMode(32,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(10,OUTPUT);
  digitalWrite(10,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(32,HIGH);

  SPI.begin(4);
  SPI.setClockDivider(4, 21);
  SPI.begin(10);
  SPI.setClockDivider(10, 84);
  SPI.begin(32);
  SPI.setClockDivider(32, 1);

  digitalWrite(10,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(32,HIGH);
 
  if (!SD.begin(4)) {
    Serial.println("SD initialization failed!");
    return;
  }
  else
  Serial.println("SD initialization done.");
}
void loop(){}
« Last Edit: April 21, 2014, 03:02:26 pm by jl-p » Logged

Offline Offline
Jr. Member
**
Karma: 2
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Found the issue.
My USB port couldn't give enough current for the tft and the sd card
Logged

Pages: [1]   Go Up
Jump to: