Pages: [1]   Go Down
Author Topic: EhernetShield + SD -> slow webserver  (Read 1069 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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 smiley-sad
Have you any idea?

Thanks!

Andrea
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50098
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, this is the right code:
Code:
//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);
}
Logged

Pages: [1]   Go Up
Jump to: