GreyGnome / EnableInterrupt

New Arduino interrupt library, designed for Arduino Uno/Mega 2560/Leonardo/Due
329 stars 73 forks source link

WInterrupts.c.o (symbol from plugin): In function `attachInterrupt': (.text+0x0): multiple definition of `__vector_1' #45

Closed DaMicrok closed 6 years ago

DaMicrok commented 6 years ago

Massive apologies in advance, first time I've posted a problem. Like the title says I get a compiling error due to attachInterrupt and multiple definition of vector 1 and 2. I've tried using different digital pins and including #define EI_NOTINT0 and #define EI_NOTINT1 in my sketch but I do not know what is going wrong. I've read that you are not meant to use serial.print but that surely can't be the problem? because serial print is a major function of Arduino prototyping.

I am using 3 pins to read 3 Hall effect sensors and migrated from using attachInterrupt to enableInterrupt as the prior does not accommodate more than 2 pins.

Below is the error message


Arduino: 1.8.3 (Linux), Board: "Arduino/Genuino Uno"

In file included from /local/XXXX/Arduino/flow_oct_v1/flow_oct_v1.ino:1:0: /local/XXXX/Arduino/libraries/EnableInterrupt-master/EnableInterrupt.h:22:125: note: #pragma message: NOTICE: EnableInterrupt library version pre-0.9.6. This is not a problem. Keep calm, and carry on.

pragma message("NOTICE: EnableInterrupt library version pre-0.9.6. This is not a problem. Keep calm, and carry on. ")

                                                                                                                         ^

WInterrupts.c.o (symbol from plugin): In function attachInterrupt': (.text+0x0): multiple definition of__vector_1' sketch/flow_oct_v1.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here WInterrupts.c.o (symbol from plugin): In function attachInterrupt': (.text+0x0): multiple definition of__vector_2' sketch/flow_oct_v1.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here collect2: error: ld returned 1 exit status exit status 1 Error compiling for board Arduino/Genuino Uno.

-------------------------------------------------------------------------------------------------------------------------------------------And this is my sketch

include

define EI_NOTINT0

define EI_NOTINT1

/* Liquid flow rate sensor -DIYhacking.com Arvind Sanjeev

Measure the liquid/water flow rate using this code. Connect Vcc and Gnd of sensor to arduino, and the signal line to arduino digital pin 2.

*/

byte statusLed = 13;

// byte sensorInterrupt = 0; // 0 = digital pin 2 byte sensorPin1 = 5;

// The hall-effect flow sensor outputs approximately 4.5 pulses per second per // litre/minute of flow. float calibrationFactor = 4.5;

volatile byte pulseCount1;

float flowRate1; unsigned int flowMilliLitres1; unsigned long totalMilliLitres1;

unsigned long oldTime;

byte sensorPin2 = 4; // The hall-effect flow sensor outputs approximately 4.5 pulses per second per // litre/minute of flow.

volatile byte pulseCount2;

float flowRate2; unsigned int flowMilliLitres2; unsigned long totalMilliLitres2;

byte sensorPin3 = 7;

volatile byte pulseCount3;

float flowRate3; unsigned int flowMilliLitres3; unsigned long totalMilliLitres3;

void setup() {

// Initialize a serial connection for reporting values to the host Serial.begin(9600);

// Set up the status LED line as an output pinMode(statusLed, OUTPUT); digitalWrite(statusLed, HIGH); // We have an active-low LED attached

pinMode(sensorPin1, INPUT); digitalWrite(sensorPin1, HIGH);

pinMode(sensorPin2, INPUT); digitalWrite(sensorPin2, HIGH);

pinMode(sensorPin3, INPUT); digitalWrite(sensorPin3, HIGH);

pulseCount1 = 0; flowRate1 = 0.0; flowMilliLitres1 = 0; totalMilliLitres1 = 0;

pulseCount2 = 0; flowRate2 = 0.0; flowMilliLitres2 = 0; totalMilliLitres2 = 0;

pulseCount3 = 0; flowRate3 = 0.0; flowMilliLitres3 = 0; totalMilliLitres3 = 0;

oldTime = 0;

// The Hall-effect sensor is connected to pin 2 which uses interrupt 0. // Configured to trigger on a FALLING state change (transition from HIGH // state to LOW state) // attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

enableInterrupt(5, pulseCounter1, FALLING);

enableInterrupt(4, pulseCounter2, FALLING);

enableInterrupt(7, pulseCounter3, FALLING);

Serial.println("Qf,,Vf1,,Vf2,,Qr,,Vr1,,Vr2,,Qp,,Vp1,,Vp2,,"); }

/**

/ Insterrupt Service Routine / void pulseCounter1() { // Increment the pulse counter pulseCount1++; } void pulseCounter2() { // Increment the pulse counter pulseCount2++; } void pulseCounter3() { // Increment the pulse counter pulseCount3++; }

Apologies again as I can only presume there must be a painfully obvious solution to those that know. And thanks. Michael

GreyGnome commented 6 years ago

Hello, no problem... we've all been there. You have a line detachInterrupt(7); which needs to be changed to disableInterrupt(7);. That will fix your sketch.

You can use Serial.print()... as a matter of fact, my examples do so. You just shouldn't put it inside an Interrupt Service Routine. Your technique of updating the pulse counters is just fine, as is your using Serial.print() to display output.

DaMicrok commented 6 years ago

Oh my, haha, what a schoolboy error! Thank you GreyGnome, I will test this out asap 👍

DaMicrok commented 6 years ago

Yep, tried and tested. Works like a dream.

I am amazed and full of gratitude that you took time out to respond to such a newbie mistake and you did so very quickly. Thank you so so much. :1st_place_medal:

dukepow commented 3 years ago

Using radiohead rh_ask.h the exact same thing happens. I don't know of this error.

GreyGnome commented 3 years ago

This must be because you are not excluding the interrupts properly in enable interrupt. Have you, double checked the documentation on how to exclude interrupts?

On Tue, Mar 23, 2021, 8:30 PM dukepow @.***> wrote:

Using radiohead rh_ask.h the exact same thing happens. I don't know of this error.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/GreyGnome/EnableInterrupt/issues/45#issuecomment-805402416, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2KFGJUOY54QBBBQXFRVSTTFE6CBANCNFSM4D76V6IA .