I am running an UNO with Ethershield and CAN bus adapter, however, CAN does not receive data.
My first step is to prove that the CAN bus read is giving me the data I need; this worked just fine.
pin 13 (SCK)
pin 12 (MISO)
pin 11 (MOSI)
pin 10 (SS/CS)
Then I added an Ethernet shield…
pin 13 (SCK)
pin 12 (MISO)
pin 11 (MOSI)
pin 10 (SS/CS)
and changed the CS/SS for the CAN bus:
pin 13 (SCK)
pin 12 (MISO)
pin 11 (MOSI)
pin 9 (SS/CS)
Ethernet works… CAN bus does not seem to read anything.
Then I started thinking… The SS pin makes a SPI device active. Using pin 10 for the Ethershield (and which I cannot change), and SS on pin 9 for the CAN bus board makes sense.
BUT, since only one can ‘talk’ on the SPI, who switches off 9 when 10 is required and the other way around? I have the suspicion that 10 is happily chatting, while 9 goes under. I thought that only one SS (either 9 or 10) can be active.
What does control these two pins?
Is this something that is being taken care off in some libraries?
I have seen this question, whether UNO + Ethershield + CAN bus can be stacked and or work together, but when code was shown, I could not see what makes one SS active and not the other.
Any hints appreciated.
(The attached source, shows how the basic CAN was developed first, and then Ethernet and MQTT where added; meaning the logic should work)
main.cpp (22.3 KB)