ISR (PORTE_PORT_vect)
{
if ( PORTE.INTFLAGS & PIN3_bm ) {
...
PORTE.INTFLAGS &= PIN3_bm ; //reset flag bit in register
}
}
ISR (PORTB_PORT_vect)
{
if ( PORTB.INTFLAGS & PIN1_bm ) {
...
PORTB.INTFLAGS &= PIN1_bm ;
}
}
ISR (PORTD_PORT_vect)
{
if ( PORTD.INTFLAGS & PIN3_bm ) {
...
PORTD.INTFLAGS &= PIN3_bm ;
}
}
It works perfectly. Now I need SoftwareSerial lib. When I include it, I get the following error:
WInterrupts.cpp.o (symbol from plugin): In function `attachInterruptParam':
(.text+0x0): multiple definition of `__vector_34'
sketch/rph_encoder.cpp.o (symbol from plugin):(.text+0x0): first defined here
WInterrupts.cpp.o (symbol from plugin): In function `attachInterruptParam':
(.text+0x0): multiple definition of `__vector_20'
sketch/rph_encoder.cpp.o (symbol from plugin):(.text+0x0): first defined here
WInterrupts.cpp.o (symbol from plugin): In function `attachInterruptParam':
(.text+0x0): multiple definition of `__vector_35'
sketch/rph_encoder.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Erreur de compilation pour la carte Arduino Nano Every
I rather guess you're using an Arduino Nano Every but that model also supports up to 4 hardware serial ports. Please specify why those cannot be used but a bad software emulation should be used.
I use SoftwareSerial basically because Critters lib uses it. I wrote my own code, but the lib generates obviously the same error.
I can try to hack SoftwareSerial, but the error message mentions WInterrupts.cpp, and I don't know how to manage vectors directly. I guess ISR on ports B, D and E are declared by WInterrupts, so I should maybe put my if code directly there...
again because the only lib available for my module is based on it and because hardware serial was not working. Now it does!! (I was using Serial instead of Serial1)
The other reason is to understand why a lib prevents the use of interrupts. I'm still interested to a solution, in case...
There's not much to that library. I'd rewrite it so that the class constructor accepts a reference to an object of the Stream class. Then you could pass it a HardwareSerial or SoftwareSerial object depending on the board in use. You could even then post a GitHub Pull request for the author to include that improvement.
MP3FLASH16P_RPH.cpp (2.7 KB) MP3FLASH16P_RPH.h (838 Bytes)
I modded the lib to use only Serial1, and added a fadeOut() method. (initiate with fadeOutStart([duration in ms]), then put fadeOut() in the main loop).