Arduino mega 2560 + Ethernet shield R3 + Digital Led strip = problem?!

I have a simple setup:

Digital led strip: WS2801
Arduino: Arduino mega 2560
Ethernet shield: Arduino Ethernet shield R3
Power supply: 5V, 60W, 0~5A

Everything should work together fine.

My problem:

  • Ethernet shield works good, I can receive and send data, no problem!
  • Digital led strip works good with FastSPI library, no problem!
  • The problem happens when i try to use FastSPI library and Ethernet library together.

I have led strip clock and data cable connected to port 51 and 52 on my arduino mega. 51 (MOSI), 52 (SCK)

I have read posts where they say there are problems with arduino mega and ethernet shield because you should connect ethernet shield to the SPI ports?
for example this site: Arduino Ethernet Shield MEGA hack « MCUKITS

This might be old versions of Ethernet shields?

I haven’t tried this because Ethernet shield works well when I am not calling FastSPI library to control my ledstrip.

When i run simple code like this just to test:

long packetSize = Udp.parsePacket();
if(Udp.available() && packetSize > 0) {
Serial.println(“got package!”);
Udp.read(packetBuffer,250);
memset(leds, 0, NUM_LEDS * 3);

for(i = 0 ; i < NUM_LEDS; i++ ) {
leds*.r = 0;*
_ leds*.g = 0;_
_ leds.b = 255;
}
noInterrupts(); // not sure what these does even, have tried with or without*
* FastSPI_LED.show();*
* delay(10);
interrupts(); // not sure what these does even, have tried with or without*
* }[/quote]
I get printed out to my Serial monitor usually something like this:
> got package!
> got p*
It works like one time then it CUTS the next printout and crashes. If i either leave FastSPI_Led.Show() out or the Ethernet parsePacket/read it will work.
Questions:
- Does this combination work? it should right??!
- How should I connect it to get it to work?
- I cannot connect both led strip AND ethernet card to ports 51 (MOSI), 52 (SCK) ?? Or can I?
- ANY suggestions would help me!_

Post all your code.

These things are normally caused by buffer over runs, but as you have not posted all the code its hard to know whether thats the issue in this case

Hi,

Thank you for your reply!

Here is a test code I have been running: http://pastebin.com/Th4TNPiD

If i could get this to work I would get everything to work!

Thank you so much in advance!

I cant see anything obvious wrong with the code.

Perhaps its just ran out of ram

I'd run one of those ram monitoring functions to check

Also does

packetBuffer need to be 250 I guess so, but perhaps this is just an arbitrary value

strange its not 256

It could be 256 yes, but I guess it doesn't matter in this case.

But as I said, Ethernet works and FastSPI library too when they are run separately. When I combine them both it starts to crash. I am not skilled with the hardware part, the code is the easier for me. I don't know if these parts work together or if i do need to re-wire the ethernet shield to SPI?? Could this be the case? or should these both work together?

Very confused!

Does anyone have any suggestions or knowledge about this?

Maybe you have done similar projects? Let me know!

If someone would have time I can make sure after a lot of testing and printing out that in the code it is this that crashes:

[u]FastSPI_LED.show();[/u]

First time it runs [u]fine[/u]!!

Second time = [u]Crash[/u]!!

Is there anything I can do to fix this?

Please someone with good knowledge about this, help me. I have been stuck with this problem for several days now! :/

Did you determine whether you we’re running out of ram or not?

Yeah, I tried it. This is the result:

Code: http://pastebin.com/i9qCZtPi

Result: