I'm interfacing a Nano with a Deek-Robot ENC28J60 Ethernet Nano shield and a MCP2515 CAN bus module.
They share the SPI (pins 11,12,13). The ethernet uses pin 10 for CS while the can module uses pin 9.
If I wire them separately on the breadboard everything is hunky-dory. If I try to mount the nano on the shield it breaks the SPI connection to the can bus.
When I have them seperate, the ethernet shield has pins 11:13 wired through the can module so I know my jumpers between the ethernet and CAN are ok.
Other things I've checked:
-VCC doesn't change when moving the nano.
-There is continuity through the ethernet headers to the pins underneath.
-Used pin 8 for the CAN CS, same results.
I can't find any documentation for the Ethernet shield and don't have access to a scope to see what's happening on the pins when I move the nano.
The only thing I can think of is that the ethernet shield is doing something wonky to the SPI signals if they come through the top headers. Anyone have experience with this or it is a case of "You get what you pay for"?
Post a picture of that setup so we get an impression of how that looks like.
If you didn't connect something very special the hooked version should be electrically identical to the breadboard version, given you did the wiring correctly. So my guess is that the breadboard version is wired differently.
In this case a thousand words may be worth the picture.
My sketch has the CAN CS as 8. Using ETHER_28J60 library with the ethernet CS as 10.
Nano
CAN
Ethernet
D8
CS
D8
D10
-
D10
D11
S1
D11
D12
S0
D12
D13
SCK
D13
5v
VCC
5v
3.3v
-
3.3v*
gnd
gnd
gnd
No connection
*works fine without this, added it to make everything electrically consistent.
At this point it's purely academic. I'm going to have to bump up to a stm32 as the ATmega328 doesn't have enough ram to run an ethernet stack and aggregate the can data
Just tried mounting the nano on the shield and it seemed like "CAN_MSGAVAIL == CAN.checkReceive()" is always true as I was seeing a bunch of trash data from the buffer every pass through the loop. Once again, everything is kosher when the nano isn't mounted on the shield.