Pages: [1]   Go Down
Author Topic: Arduino mega 2560+ GPRS shield + CAN-Bus shield problem  (Read 1931 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The SPI communication between arduino and CAN-Bus shield is from pins 10(53) ,11(51),12(50) and 13(52) , the interrupt on pin 2. The Software serial communication of GPRS shield is on pins 10 and 11(Because of not all pins on the Mega and Mega 2560 support change interrupts), because of the common pins 10 and 11 my device does not work properly can anybody help me regarding this issue....
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
can anybody help me regarding this issue
Help you do what? Change a couple of pin numbers? Surely you can manage that.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

for software serial there is a limitation: Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 (http://www.arduino.cc/en/Reference/SoftwareSerial)  and
for SPI Arduino mega as 10,11,12,13 (http://arduino.cc/en/Reference/SPI).

I tried changing the pins for Software serial to (7,8), (5,6),(3,4) also it doesnt work.......
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

SPI on the Mega is not on pins 10 to 13. It is on pins 50 to 53.

Quote
I tried changing the pins for Software serial to (7,8), (5,6),(3,4) also it doesnt work.......
Oh, well, that's obvious.......................................... (Ha, I can use more periods than you!)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Actually I connected CAN-BUS Shield (placed over Arduino Mega ) pins 12,11,13,10 to 50,51,52,53

Can you please help me how do I connect from CAN-BUS Shield(SParkfun) to pins 50,51,52,53 directly without connecting to 10,11,12,13 pins
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Can you please help me how do I connect from CAN-BUS Shield(SParkfun) to pins 50,51,52,53 directly without connecting to 10,11,12,13 pins
Take a pair of needle nose pliers and bend those 4 pins so that they don't engage the matching slots on the Mega. Solder jumper wires to the pins.

If you've read that SoftwareSerial requires pins that support pin change interrupts, and if you've determined that pins 2 through 9 do not support pin change interrupts, why would you bother trying?

Why, using a Mega with 4 hardware serial ports, do you need software serial anyway?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need to connect to connect to 16 ECUs through CAN shield and send that data using gprs shield , In order to have more memory and available more no of pins t connect to ecus I selected Arduino mega..

Can someone help me how to use Hardware serial port in GPRS shield....with a small program...
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to follow Pauls suggestions.

He gave you everything you needed.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys, bumping this one since I'm having a similar problem.

I'm trying to get the sparkfun CAN-shield to work with the Mega 2560, I've cut the pins that attaches to pin 10-13 on the Uno and instead put cables to the corresponding pin 50-53 on the Mega. I still can't get the mcp to initialize. It works when connected to the Uno in the original way.
Don't one have to change something in the code to make this work on the Mega? The only thing I've found in the code which remotely look like some SPI definitions though are:

Code:
#ifndef DEFAULTS_H
#define DEFAULTS_H

#define P_MOSI B,3
#define P_MISO B,4
#define P_SCK B,5

//#define MCP2515_CS D,3 // Rev A
#define MCP2515_CS B,2 // Rev B
#define MCP2515_INT D,2
#define LED2_HIGH B,0
#define LED2_LOW B,0

#endif // DEFAULTS_H

I have a basic knowledge in C++ but I don't know what the 'B's and 'D's above means; like in P_SCK B,5.

regards Anton, Sweden
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I believe I've solved the problem and I figured I might put it here for reference.

The issue was in the default.h -file above, I found in the datasheet for the ATMega2560, table 13-6, information about the SPI-pins and changed the definitions in the file for MOSI/MISO/SCK/CS accordingly.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you have to make some change the defaults file in the library for CAN communication...

#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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm in a similar situation, using a CAN shield with the mega ADK (which uses pin 50-53 for SPI as if it were a usb host shield). Either device works on its own, but I'm getting conflicts on the SPI bus when using both.

akarls87, what did you have to change. I assume the #define MCP2515_CS B,2 format means port B pin 2, but I'm not sure how port-pins map to arduino pin numbers. Looking at the example code in this post, it doesn't look like they're sequential.

Am I on the right track? I'll try and find those pin mappings on my own; I'm hoping changing the SS pin is enough to resolve my conflict. akarls87 or anyone else who has figured this out, please let us know what changes are needed!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And, for anybody who comes along after me- let me answer my own question. Because of course after I was finally humble enough to ask for help, I answered my own question within minutes  smiley-razz

The pin mapping is here: http://arduino.cc/en/uploads/Hacking/PinMap2560_.png

And the following change to the library code fixed everthing:

Code:
//#define MCP2515_CS B,0 // Rev B
#define MCP2515_CS C,6

Only needed to change the CS/SS pin definition. This happens to be for pin 31, a completely arbitrary choice from among my free pins.

Thanks all! Cheers!
Logged

Pages: [1]   Go Up
Jump to: