Boa noite amigos.
Tenho o Arduino Mega um ETHERNET enc28j e um sdcard.
Fiz a ligação do pino cs do SD no pino 4
Fiz a ligação do pino cs do ethernet no pino 53
Os pinos 50,51,52 foram usados para ambos.
50 - SCK
51 - MOSI
52 - MISO
Meu código de teste:
#include <EtherCard.h>
#include <SD.h>
#define STATIC 0
#if STATIC
static byte myip[] = { 192,10,0,20 };
static byte gwip[] = { 192,10,0,1 };
#endif
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
byte Ethernet::buffer[500];
void setup(){
Serial.begin(9600);
Serial.print("Iniciando SD");
if (!SD.begin(4)) {
Serial.println("Deu erro no sd");
return;
}
Serial.println("SD FUNCIONANDO!");
if (ether.begin(sizeof Ethernet::buffer, mymac,53) == 0) {
Serial.println( "Falha no Ethernet");
return;
}
#if STATIC
ether.staticSetup(myip, gwip);
#else
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
#endif
Serial.println( "Ethernet Funcionando.");
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
}
void loop(){}
O problema é que o ethernet não funciona. somente o sd.
Fiz o teste separadamente, primeiro o sd e funcionou tudo bem
Depois fiz o teste com somente o ethernet e também funcionou,
Porém quando eu ligo os dois juntos.... o ethernet não funciona ,somente o sd.
Como eu resolvo isso?