Serial Communication working with UNO but not MEGA

Hi everyone,

I have recently transferred my project from a UNO to a MEGA board as I needed two serial ports to buffer as the same time. On the UNO I was using the software serial library to communicate with a RS232 shield. Upon transferring this over to the Mega and consequentially the RX TX pins over to Serial1, I can not seem to get the MEGA to read data.

Regards to hardware, I have the shield placed on the mega exactly how it would on the UNO. Only exception is that the RX TX pins on the shield are bent out and instead connected to the TX1 and RX1 (with a TX-->TX RX-->RX config).

This code works perfectly on my UNO but I get nothing on the mega, any help would be appreciated.

EDIT:
I am currently sending data through to my computers com port using a Pyserial library in Python. I am using a RS232 - USB adapter to connect from the USB to the RS232 shield.

test1uno.ino (1.08 KB)

test1MEGA.ino (1.02 KB)

Software serial is a very bad bodge. On the mega just use one of the other hardware serials.

Mark

holmes4:
Software serial is a very bad bodge. On the mega just use one of the other hardware serials.

Mark

Hi Mark Thanks for your reply... I probably wasn't clear enough. When I changed from the uno to the mega, I modified my code to replace the software serial library and just use the Serail1 and Serial2 pins on the Mega.

The uno was reading the data perfectly with the software serial library, but when I changed over to the mega is not reviecing anything.

I wouldn't write either program like that but I don't immediately see any problem with the Mega version. However there are a lot of small changes between the two.

What happens if you try the Mega version on your Uno with no changes other than changing Serial1 to PortOne.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

I modified my code to replace the software serial library and just use the Serail1 and Serial2 pins on the Mega.

I can see no reference to Serial2 in your test code for the Mega