Go Down

Topic: EhernetShield + SD -> slow webserver (Read 1 time) previous topic - next topic

a.periz

Hi!
I'm trying to use both the webduino library and the sd library and when I init the sd, the webserver becomes very slow.
This is the code:
Code: [Select]
pinMode(53, OUTPUT);
pinMode(4, OUTPUT);
digitalWrite(53, HIGH); //turn off wz5100
SD.begin(4);
digitalWrite(4, HIGH); //turn off sd
Ethernet.begin(mac, ip, router, subnet);


and then I start the webserver...

I think this is because the sd makes slower the spi speed, but I don't know how to fix it :(
Have you any idea?

Thanks!

Andrea

PaulS

Code: [Select]
digitalWrite(53, HIGH); //turn off wz5100
SD.begin(4);
digitalWrite(4, HIGH); //turn off sd
Ethernet.begin(mac, ip, router, subnet);

Where exactly do you turn the wz5100 back on?

a.periz

Sorry, this is the right code:
Code: [Select]
//SPI devices PINs
#define CAN_CS    9
#define CAN_INT   6
#define LAN_CS    53
#define SD_CS    4

//Macros to manage SPI
#define CAN_OFF  digitalWrite(CAN_CS, HIGH)
#define LAN_OFF  digitalWrite(LAN_CS, HIGH)
#define SD_OFF  digitalWrite(SD_CS, HIGH)
#define CAN_ON  digitalWrite(CAN_CS, LOW)
#define LAN_ON  digitalWrite(LAN_CS, LOW)
#define SD_ON  digitalWrite(SD_CS, LOW)

#define WEB_PREFIX  ""
#define WEB_PORT  80
WebServer webserver(WEB_PREFIX, WEB_PORT);

void setup()
{     
    pinMode(LAN_CS, OUTPUT);
    pinMode(SD_CS, OUTPUT);
    pinMode(CAN_CS, OUTPUT);
     
    //Init SD
    SDInit();
   
    //Init LAN Module
    LANInit();

    //Init WebServer
    WSInit();
}

void LANEnable()
{
      CAN_OFF;
      SD_OFF;
      LAN_ON;
}

//###  Ethernet
void LANInit()
{
    LANEnable();
 
    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xE9, 0xA4, 0xE1 };
    byte ip[] = { 10, 0, 1, 177 };
    byte gateway[] = { 10, 0, 1, 1 };
    byte subnet[] = { 255, 255, 255, 0 };
   
    Ethernet.begin(mac, ip, gateway, subnet);
}

//###  SD
void SDEnable()
{
      LAN_OFF;
      CAN_OFF;
      SD_ON;
}

void SDInit()
{
     SDEnable();
     SD.begin(SD_CS);
}

void WSInit()
{   
     LANEnable();
     
     webserver.begin();
     webserver.setDefaultCommand(&homePage);
     webserver.setFailureCommand(&failureCmd);
}


Go Up