blown406 / arduino-pinchangeint

Automatically exported from code.google.com/p/arduino-pinchangeint
0 stars 0 forks source link

SoftwareSerial.h incompatible with PinChangeInt.h in 1.0 #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Including both SoftwareSerial and PinChangeInt libraries such as the following 
will result in compile errors while commenting out one or the other will not:

#include SoftwareSerial.h
#include PinChangeInt.h
#include Adaencoder.h

void setup()  
{

}

void loop() 
{
}

Original issue reported on code.google.com by gums...@yahoo.com on 12 Mar 2012 at 12:53

GoogleCodeExporter commented 8 years ago
SoftwareSerial uses Pin Change Interrupts, and as a result it is indeed in 
direct conflict with this library.

The only way to make them compatible would be to do something like this:

* Figure out which port(s) you want to use for Software Serial.
* Figure out which port(s) you want to use for Pin Change Interrupts.

Set up the #defines in Pin Change Interrupts so as to shut off the Software 
Serial ports:  #define NO_PORTx_PINCHANGES

Copy the SoftwareSerial library to your personal libraries folder; call it 
mySoftwareSerial or something like this.  Do a global namechange from 
SoftwareSerial to mySoftwareSerial.

Delete the appropriate ISR in mySoftwareSerial.  For example, if you knew you 
weren't going to use PORTD for SoftwareSerial, you would delete:

#if defined(PCINT2_vect)
ISR(PCINT2_vect)
{
  SoftwareSerial::handle_interrupt();
}
#endif 

and so on.

So this is a limitation, not a bug.

Original comment by m...@schwager.com on 12 Mar 2012 at 12:24

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have tried to implement this by adding ...

1)#define NO_PORTD_PINCHANGES (in my sketch)
2)and deleting:
#if defined(PCINT2_vect)
ISR(PCINT2_vect)
{
  SoftwareSerial::handle_interrupt();
}

#endif 

I did not decide to rename the SoftwareSerial library contents as i do not know 
how to do a global namechange. I need two serial ports and 5 external 
interrupts, can you please advise me on what to do?

Original comment by nirvaans...@gmail.com on 18 Mar 2014 at 12:42

GoogleCodeExporter commented 8 years ago
Yes, you have to change the name of the .h file, the .cpp file, put them in 
your directory alongside your sketch, and #include it under the new name. Then 
it should work.

Original comment by mschw...@gmail.com on 18 Mar 2014 at 12:11