Software Serial and interrupts

I assume that the software serial process for arduino uses a pinchange interrupt on the receive line of a serial link. If that is the case, and I am operating two SW serial links into the same microprocessor, what happens if one interrupt is downloading data and the other serial link initiates an interrupt simultaneously?

Thanks in advance for any insights.

I am operating two SW serial links into the same microprocessor, what happens if one interrupt is downloading data and the other serial link initiates an interrupt simultaneously?

Have you actually tried using 2 SoftwareSerial instances at the same time ? It doesn't work because they both share the same buffer.

See softwareSerial

Hmm, all the PCINTs are same priority level for interrupts, so the first doesn't get interfered with? Maybe not:

The complete list of vectors is shown in ”Interrupts” on page 57. The list also determines the priority levels of the different interrupts. The lower the address the higher is the priority level. RESET has the highest priority, and next is INT0 – the External Interrupt Request 0. The Interrupt Vectors can be moved to the start of the Boot Flash section by setting the IVSEL bit in the MCU Control Register (MCUCR). Refer to ”Interrupts” on page 57 for more information. The Reset Vector can also be moved to the start of the Boot Flash section by programming the BOOTRST Fuse, see ”Boot Loader Support – Read-While-Write Self-Programming” on page

263.

4 0x003 PCINT0 Pin Change Interrupt Request 0

5 0x004 PCINT1 Pin Change Interrupt Request 1

6 0x005 PCINT2 Pin Change Interrupt Request 2

So I guess put your more important software serial on PCINT1 pins vs PCINT2 or 3.

Or, review the software serial code, see if it messes with interrupts so tranfers don't end up with timing that could be jerked around.

The SoftwareSerial that I am familiar with allows multiple instances but only ONE may be listening (receiving or waiting to receive) at a time. The programmer (user) decides which instance is listening at any moment.

It is important to visit the link provided by UKHeliBob. For example, it says:

"If using multiple software serial ports, only one can receive data at a time."

If you are using some other software serial library, please provide a link and read the documentation.

IMHO the wisest and simplest thing is to assume you can only use one instance of SoftwareSerial.

...R

You are certainly welcome to your opinion. However, I have had three Arduinos (two Unos and one Deumilanove) communicating (and could have had 4096 if I had enough hardware) using hardware serial for debug and using two instances each of SoftwareSerial for the communications. Of course, only one instance at a time was actively listening.

Each Arduino uses two instances of SoftwareSerial to communicate with its neighbors on the "left" and the "right". The Arduinos on the ends have two instance of SoftwareSerial but only make use of one each.

The software on each Arduino is identical. Each Arduino recognizes whether it is on the "left" end, the "right" end, the middle, or is alone, and acts accordingly.

One instance of SoftwareSerial would have been simpler and perhaps wiser, but would not have gotten the job done.

I realize that listen() is necessary when multiple SW serial links are implemented. But if only one could be used, there would be no need for a Listen() procedure.

I have spare pins on the nanos involved, so I'm going to implement an old-fashioned type of serial (remember DB9 connectors) with a DTR and RTS line for each serial link.

vaj4088: and using two instances each of SoftwareSerial for the communications

The strictly organized system that you describe does not sound like the sort of thing the OP is trying to implement.

...R