Using SoftwareSerial with ATMega2560 chip

Hello,

I am trying to program an ATMega2560 chip on a designed PCB. I'm with a group designing this product and I am responsible for writing the code that will be used on the PCB. Since the ATMega chip is on a different board on the ArduinoMega2560, how would I go about using specific pins?

For example, if I wanted to use pins number 35 and 36 (pin names PL0 and PL1 respectivley) as TX and RX pins with the SoftwareSerial library, would the following command correctly define the referenced chip pins as a transmitter receiver pair?

SoftwareSerial UltrasonicSerial (35,36);

The MEGA2560 has 4 hardware serial ports. Can you not ask your designers to break out the specific pins associated with the hardware serial ports.

You will make your life a lot easier if you use the hardware ports - unless, of course, you already have used them up?

I think you are correct...here is some more information from an example I found! Hope this helps.

 "The circuit:
 * RX is digital pin 10 (connect to TX of other device)
 * TX is digital pin 11 (connect to RX of other device)

 Note:
 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

 Not all pins on the Leonardo and Micro support change interrupts,
 so only the following can be used for RX:
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

 created back in the mists of time
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Harts example "

 This example code is in the public domain.


#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

Then it's up to you to map the controller pins to the Arduino pin numbers. With the standard mapping the UARTs connect to D14..21.

Its always worth reading the documentation for the SoftwareSerial library if you want to know its limits and capabilities.

Using SoftwareSerial on a Mega2560 is a dumb thing to do.
The board designer should have known about the four hardware serial ports.
Leo..

So if they got it wrong, you just put the design right back to them to do it right! :+1:

No point completely wasting your time pushing the proverbial uphill!