Offline
Newbie
Karma: 0
Posts: 14
|
 |
« on: February 12, 2013, 09:03:25 am » |
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
Brattain Member
Karma: 316
Posts: 35590
Seattle, WA USA
|
 |
« Reply #1 on: February 12, 2013, 09:19:08 am » |
can anybody help me regarding this issue Help you do what? Change a couple of pin numbers? Surely you can manage that.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #2 on: February 12, 2013, 09:33:34 am » |
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
Brattain Member
Karma: 316
Posts: 35590
Seattle, WA USA
|
 |
« Reply #3 on: February 12, 2013, 09:51:55 am » |
SPI on the Mega is not on pins 10 to 13. It is on pins 50 to 53. 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
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #4 on: February 12, 2013, 10:58:47 am » |
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
Brattain Member
Karma: 316
Posts: 35590
Seattle, WA USA
|
 |
« Reply #5 on: February 12, 2013, 11:06:38 am » |
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
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #6 on: February 13, 2013, 04:35:59 am » |
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
Jr. Member
Karma: 0
Posts: 50
|
 |
« Reply #7 on: February 17, 2013, 10:15:11 pm » |
You need to follow Pauls suggestions.
He gave you everything you needed.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #8 on: February 26, 2013, 04:55:57 pm » |
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: #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
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #9 on: February 28, 2013, 12:16:06 pm » |
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
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #10 on: March 07, 2013, 06:41:57 am » |
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
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #11 on: April 23, 2013, 06:39:52 pm » |
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
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #12 on: April 23, 2013, 06:55:31 pm » |
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  The pin mapping is here: http://arduino.cc/en/uploads/Hacking/PinMap2560_.pngAnd the following change to the library code fixed everthing: //#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
|
|
|
|
|
|