Closed rubborto closed 9 years ago
By 'strange loop' you mean you get the same output on serial over and over again? If so it could be that there's not enaugh ram for both SD and UIPEthernet (as SD requires quite a lot and calling SD.begin() already opens the volume and reads mbr etc..) UIPEthernet requires more ram than stock ethernet too. On which model of arduino does this fail? Do you have a mega256 to try out? I have to admit I never tried UIPEthernet with an SD card but from my understanding both libraries should set their individual CS-pin to high after each call and UIPEthernet does make sure hardware-SS is correctly set to output, and both initialize SPI-speed to Cpu-clock/2, so I'd expect they should friendly coexist.
Thanks Norbert for your reply. I'm working on an Arduino Uno board. By strange loop I mean the serial continues to print "connecting...", "initializing..." and so on infinitely. The SD card is apparently initialized correctly, at least this. Any help will be welcome. Thanks again
that is a boot-loop, the arduino is constantly restarting. Most likely caused by shortage of memory that leads to corrupted (overwritten by heap) stack. If this is the case the only thing you can do to resolve this is use an arduino that has more memory (mega2560). Another possible cause is lack of current if both the enc28j60 and the sd-card are powered by the onboard 3.3V regulator.
thanks again Norbert for your support. Actually the shield is stacked on top of the arduino, so I assume it's powered correctly. I will double check if I can power it separately, but from a first look at the tech docs does not seem possible. I don't really see the point to market this kind of hw if it cannot work properly. It has given me a big headache and what a big loss of time. I should have bought the original Arduino W5100 module...
that is a boot-loop, the arduino is constantly restarting. Most likely caused by shortage of memory that leads to corrupted (overwritten by heap) stack. If this is the case the only thing you can do to resolve this is use an arduino that has more memory (mega2560). Another possible cause is lack of current if both the enc28j60 and the sd-card are powered by the onboard 3.3V regulator.
I know this is a very old and even closed thread, but I still like to weigh in, just in case someone has the same problems. memory is indeed at a premium and the UIPethernet library surely guzzles lots of it, but if that would be the problem here, there are a few things to try:
Should you really be pressed for memory, there is a way to free up about 5K of Flash: Go to your /../sketchfolder/libraries/UIPEthernet-master/utility/uipethernet-conf.h and open the uipethernet-conf.h file. in that file you will see the following section:
If you set UIP_CONF_UDP to ‘0’ you will save 5kB flash, by disabling UDP. However, if you use DHCP to connect to your router, you cannot disable UDP as the DHCP connection requires UDP. In that case you still can gain a bit of memory by reducing the UIP_UDP_CONNS. An example of using a fixed address is this:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //the IP address for the shield: byte ip[] = { 192, 168, 1, 120 };
void setup() { Ethernet.begin(mac, ip); } void loop() {}
Hi all I'm trying to build a server using an ITEAD ENC28J60 module to serve a page stored in the sd card. The shield works fine using the UIPEthernet library when serving a simple text page, but goes into chaos when trying to combine the ethernet function with the sd card reading. I'm simply getting stucked on the setup as the code goes into an infinite loop with no apparent reason. I have moved the jumper on the board as explained in the shield documentation, so CS pin for the ethernet function is now on pin 8, while sd card is on pin 9. I have changed the ENC28J60_CONTROL_CS to pin 8 on file ENC28j60network.h. When using the simplest setup code to start up the server (with no sd card initialization), the server starts up fine and responds correctly. However when including the sd.h library and the sd card initialization code, the setup code goes into a strange loop and there it remains. Any help from your experience will be very welcome!
Please see here below the first part of the code: