Sparkfun CAN bus shield on Mega2560 Problems


yes, there bunch of threads discussing , have tested lot of people have said, still cannot can initialize , run while using sparkfun can bus shield on arduino mega2560.  far has been done:

1) header pins connecting:
can shield pin 13 -> arduino pin 52
can shield pin 12 -> arduino pin 50
can shield pin 11 -> arduino pin 51
can shield pin 10 -> arduino pin 53

2) terminal resistor across canh/canl pins

3) using pins 3 , 5 canh/canl on rs232 connector.  link schematic sparkfun site below.

https://www.sparkfun.com/datasheets/devtools/arduino/canbus_shield-v12.pdf

4) using canbus_v3 library per link: http://skpang.googlecode.com/files/canbus_v3.zip

5) in defaults.h, changed pin mapping match mega2560:
code: [select]

#ifndef defaults_h
#define defaults_h

#define p_mosi b,2
#define p_miso b,3
#define p_sck b,1

//#define mcp2515_cs d,3 // rev a
#define mcp2515_cs b,0 // rev b
#define mcp2515_int d,2
#define led2_high b,0
#define led2_low b,0

#endif // defaults_h


6) replaced occurrences of "wprogram.h" "arduino.h", imported canbus_v3 library, , used test code:
code: [select]

#include <canbus.h>
#include <spi.h>

int led2 = 8;
int led3 = 7;

void setup() {
  delay(2000);
  serial.begin(115200);
  pinmode(led2,output);
  pinmode(led3,output);

  digitalwrite(led2, high);
  pinmode(53,output);
  digitalwrite(53,high);
  pinmode(10,input);   /* these need set inputs cuz card isn't compatible arduino mega....*/
  digitalwrite(10,high);
  pinmode(11, input);   
  digitalwrite(11, low);
  pinmode(12, input);   
  digitalwrite(12, low);
  pinmode(13, input);   
  digitalwrite(13, low);

  spi.begin();
 
 
  serial.println("trying initialize can");
  if(canbus.init(canspeed_500))  /* initialise mcp2515 can controller @ specified speed */
  {
    serial.println("can init ok");
    digitalwrite(led3, high);
  } else
  {
    serial.println("can't init can");
  } 
 
}


is there i'm missing or doing wrong?



Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Sparkfun CAN bus shield on Mega2560 Problems


arduino

Comments