Go Down

Topic: More flexible interrupt handling in some libraries?? (Read 128 times) previous topic - next topic

PaulM47

Hi, I'm pretty new to Arduinos but have many years of industrial experience with Microchip PIC processors. I'm trying to make use of the interrupts available on the ATmega 328 chip on the UNO/Ethernet boards but keep hitting the problem that available libraries, like the 'SoftwareSerial' and 'EnableInterrupt' libraries I'm trying to use, grab all three available pin change interrupt vectors. I need to do something along the lines of using 'SoftwareSerial' routines on ports B & D ('digital' pins 4-19) but 'EnableInterrupt' routines on port C ('analog' pins 23-28). I can't help thinking it would be relatively easy to make these libraries *default* to grabbing all three interrupts (for inexperienced users) but allow compiler directives to exclude one or more groups (for more experienced users) so two libraries don't cause clashes. e.g.

#softwareserial exclude portC
#enableinterrupt exclude portB
#enableinterrupt exclude portD

to allow me to mix the two as suggested above.

Any mileage in such a suggestion ?? It would certainly add some more flexibility.

Regards
PaulM

Robin2

There are all sorts of situations in which Arduino libraries conflict with each other. There is no standard guidance for writing libraries, or even for documenting the resources that a library uses. There is also the problem that the Arduino has few resources so it may not always be possible to avoid conflicts.

If I understand you correctly, you are suggesting a scheme in which a library might be directed to use different pins or different interrupt vectors so that your code could use the pins or vectors that you would like to use.

I feel bound to suggest that it would be a lot less trouble if your code were to use the pins or vectors that you might redirect the libraries to.

And, of course, the library source code is included with the Arduino IDE so you are free to make your own version of any library.

...R

PaulM47

There are all sorts of situations in which Arduino libraries conflict with each other. There is no standard guidance for writing libraries, or even for documenting the resources that a library uses. There is also the problem that the Arduino has few resources so it may not always be possible to avoid conflicts.
Yes, the small PIC processors have the same problem with limited resources :-(

Quote
If I understand you correctly, you are suggesting a scheme in which a library might be directed to use different pins or different interrupt vectors so that your code could use the pins or vectors that you would like to use.

I feel bound to suggest that it would be a lot less trouble if your code were to use the pins or vectors that you might redirect the libraries to.
Almost, I have no problem using the pins the libraries are written for, except in the case of interrupts and these two libraries, all pins are applicable, hence both libraries grab all three interrupt vectors. What I'm suggesting is the ability to exclude certain groups of pins for each library, in this case hardware ports, to enable the two libraries to be compiled together without confict.

Quote
And, of course, the library source code is included with the Arduino IDE so you are free to make your own version of any library.

...R

Yes, I've had a look at that option but as yet haven't found enough information to allow me to do so. I installed the IDE from the ubuntu repositories but assume I'd need to download the IDE directly to find the standard library source files ? I found the 'EnableInterrupt' library on GitHub but as yet haven't fathomed out the way to edit and re-compile it as some of the required source files appear to be missing (*.cpp files etc.).

This is all quite new to me so any pointers to info on finding, editing and re-compiling the libraries would be very helpful. I'm quite used to the professional IDEs available for the PIC processors (Microchip/MikroElektronika etc.) which roll everything into one desktop package, so editing, building, making, compiling the hard way is taking a bit of fathoming out :-)

Many thanks again for your reply.

Regards
PaulM

Robin2

but assume I'd need to download the IDE directly to find the standard library source files
Thay are already included so they can be compiled if you want to use them.

The Arduino IDE is just a Java program so I don't bother with any installer.

...R

Go Up