SoftwareSerial isn't working on ATMEGA 1284

Hi,

I’m using an ATMEGA 1284 with the mighty - Bootloader.
In my project it’s necesary to use SoftwareSerial, so I uploaded a simple sketch from the examples:

The interesting part:

if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());

On the Arduino UNO the everything works fine, but on the 1284 it is not possible to read anything over the Software Serial. PINs and everything else is correct and sending data via SoftwareSerial is also no problem.

Any ideas ?

What pin are you using for the RX? This is from the Software Serial reference:

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, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).

http://arduino.cc/en/Reference/SoftwareSerial

Wrong chip Tim - that is Mega1280/2560, not 1284P.

UnitedOne - checkout the updates for the 1284P here: http://forum.arduino.cc/index.php?topic=235521

Hey CrossRoads,

thanks for your help. Is there any repository where the newest version of the bootloader is hosted ?

Thanks

Core with a nearly up-to-date Optiboot bootloader... https://github.com/JChristensen/mighty-1284p

Optiboot announcements... http://forum.arduino.cc/index.php?topic=64105.0

The bleeding edge for Optiboot... https://code.google.com/p/optiboot/source/browse/

Unless you are using the "standard" bootloader for the m1284 (whatever that is). In which case I can't help.

I've tested the ATMEGA1284 with the newest bootloader from

https://github.com/JChristensen/mighty-1284p

Same result: Transmitting via SoftwareSerial ist possibile, receiving does not work.

Any ideas ?

It's not a bootloader problem. It would be a problem with the software serial library. Where did the library come from?

Same result: Transmitting via SoftwareSerial ist possibile, receiving does not work.

Any ideas ?

Which pins on the 1284 support pin change interrupts? SoftwareSerial relies on pin change interrupts, so if the pin you are using to receive data does not support pin change interrupts, you can't receive data.

All pins on the 1284P support PCINT. PCINT0 to PCINT31.

UnitedOne - Did you ever get SoftwareSerial working with the ATMega 1284? I've been working on upgrading a 328 based board to a 1284 based one, but can't get the code relying on SoftwareSerial working. In my case I'm using the current Arduino 1.6.5 SoftwareSerial library.

Has anyone managed this, I know it's an old topic, but the problem still seems to be there.

I haven't tried to get the SoftwareSerial working on the ATMega1284, I instead redesigned my boards to make use of the second UART on the 1284 rather than trying to use the software variant.

Yeah, I’m pretty sure it’s a bad definition in pins_arduino.h for the PCMSK macro. It should be this:

 #define digitalPinToPCMSK(p)    (((p) <= 7) ? (&PCMSK1) : (((p) <= 15) ? (&PCMSK3) : (((p) <= 23) ? (&PCMSK2) : (((p) <= 31) ? (&PCMSK0) : ((uint8_t *)0)))))

Look in your

~~ ~~    <Arduino-install-dir>/hardware/Arduino/avr/variants/xxx/pins_arduino.h~~ ~~

** **     Documents/Arduino/hardware/MightyCore/avr/variants/standard/pins_arduino.h** **

Jack Christensen has a github here with the good stuff.

Cheers,
/dev

/dev:

    <Arduino-install-dir>/hardware/Arduino/avr/variants/xxx/pins_arduino.h

where “xxx” is something like “Mighty” or “Moteino”.

I’m not aware of any ATmega1284/P hardware package that instructs the user to install into the Arduino IDE installation folder. Even the ancient maniacbug version that hasn’t been edited for four years has instructions for the correct installation into the sketchbook folder. Installing into the IDE folder is a bad idea because then you will need to do the installation all over again every time you update the IDE. Merging the installation into the Arduino AVR Boards core is an even worse idea.

dave_sausages which hardware package are you using? Post a link to where you downloaded it from.

Are you actually using an ATmega1284 or a ATmega1284P

MightyCore has a version of SoftwareSerial included: https://github.com/MCUdude/MightyCore/tree/master/avr/libraries/SoftwareSerial I haven’t looked at what modifications were made.

I’m not aware of any ATmega1284/P hardware package that instructs the user to install into the Arduino IDE installation folder.

Sorry, fixed above. The directory is

** **     Documents/Arduino/hardware/MightyCore/avr/variants/standard/pins_arduino.h** **

However, that MCUdude github repo still has the incorrect PCMSK macro:

#define digitalPinToPCICRbit(p) (((p) <= 7) ? 1 : (((p) <= 15) ? 3 : (((p) <= 23) ? 2 : 0)))
#define digitalPinToPCMSK(p)    (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))

There are no significant differences in SoftwareSerial.

Cheers,
/dev

/dev: However, that MCUdude github repo still has the incorrect PCMSK macro:

I've reported the issue at https://github.com/MCUdude/MightyCore/issues/34. Thanks!

However, that MCUdude github repo still has the incorrect PCMSK macro:

The macro is now fixed!