CAN-Bus Shield and Mega 2560?

I can get the CAN shield to work on my UNO no problem but i can’t get it to work on my Mega 2560. Physically i’ve wired the SPI lines to the CAN-Bus shield at the same pin locations as the UNO, but i can’t find where to change the SPI pins in software? I’ve tried SPI.h and it’s labeled fine on pins_arduino.h but i don’t think it’s looking at the correct pins_arduin.h.

Does anyone know how to get the CAN-BUS shield code to look at the correct SPI pins?

OK, finally figured it out after following the code line by line. It was in the mcp_can_dfs.h file and wasn’t readily apparent because of the way it was worded\coded.

//#define SPICS 10 ///////////////////////Standard Arduino #define SPICS 53 ////////////////////////Arduino Mega #define MCP2515_SELECT() digitalWrite(SPICS, LOW) #define MCP2515_UNSELECT() digitalWrite(SPICS, HIGH)

As you can see above, the SPICS is worded funny, i would have made the variable SPI_CS to make it clear. A little underscore goes a long way. As you can see in the code, i changed the CS pin to 53 here.

Hi ,
Actually , the Can-Bus Shield is using D10 - D13 pin as SPI port , but they are not connect to SPI pin , so if you want to use it with mega , you need to jump D10 - D13 to SPI pin . That is also a defect of this shield i think , i will give this info to the designer .

Regards,
Deray

Yes, i’ve wired it that way, everything is working great. Thanks!! :smiley:

Does anyone know how to get the Recieve sketch to work from the Seecuduino wiki site? i can transmit no probs but when i try and recieve , as soon as i open the serial monitor it crashes the BUS

thanks to anyone who can help.

I come for Soy sauce,please ignore me~

Hi All, been trying to get the CAN Shield working with the Mega 1280

I connected the pins as described, and changed the SPICS from 10 to 53, but i get the message CAN init Fail on the serial monitor when i run the sketch.

Appart from the 5V and Gnd pins, is there anything else required to jumper over ?

Thanks all

Rich

Did you make sure your CAN bus wiring is correct? You need a 120 ohm terminating resistor at both ends of the bus. If it’s a pre-existing bus then they should already be there, but you need to make sure you set the baud rate correctly.

all you need to do :

  1. Check the Wiring and schematics,
  2. Check SPI pin.
  3. Put in 120 ohm resistor in parallel at CANH and CANL.
  4. if still not running , Check X-tal…

Good luck ,
Cheers ,

:smiley:

Hi All, i have done that, thanks, but no luck,

I shouldnt need a termination resistor as i dont have it connected to a CAN bus , just running the sketch blank

Works fine with the UNO just wont initialise on the MEGA, hmm,

Whats the x-tal nw-giri?

thanks

Rich

if still not running ,, Check X-tal.. 

sorry , I mean Crystal (X-tal),