LowPowerLab Forum

Hardware support => Moteino => Topic started by: Charly86 on January 12, 2015, 01:09:53 PM

Title: RFM69 library does not let me using free IRQ1 in my sktech
Post by: Charly86 on January 12, 2015, 01:09:53 PM
Hi there,

I've got an small issue, I know it's not Felix's Library that cause me the issue but more the way Arduino compile code and libraries when they have IRQ vector.

Let me explain, I need to have my own IRQ vector (for INT1) in my sketch so of course I'm using INT0 for RFM69.

But as soon as I declare the IRQ vesctor for INT1 in my sketch as following


ISR (INT1_vect)                                                                 
{
  // Inc counter
  iWakeCounter++;
}


I've got a compilation link stage error saying

WInterrupts.c:314: multiple definition of `__vector_2'
blah blah ... /my_sketch.ino.cpp:43: first defined here


Of course line 43 is my declaration of INT1 ISR vector. I think the issue is coming from compiler, may be as soon as it see an interrupt in code, it compile all "Arduino" interrupt code and declare all vectors (including the ones not used).

Any ideas are welcome, but may be it's just my coding "syntax" that is wrong  :-\


Title: Re: RFM69 library does not let me using free IRQ1 in my sktech
Post by: Felix on January 12, 2015, 01:58:47 PM
I run into this sometimes. I think you might be using a library that has already declared that elsewhere. The RFM69 lib does not have anything to do with INT1, in fact I bet if you do the same thing with the sketch without any RFM69 lib reference, you would get the same error. Can you verify this theory?
Title: Re: RFM69 library does not let me using free IRQ1 in my sktech
Post by: Charly86 on January 14, 2015, 01:27:07 PM
Felix,

Thanks for your answer, but it's just the Library that I use. For testing I loaded the Struct_receive sample from your latest RFM69 library and just added the following lines into the sktech :


ISR (INT1_vect)                                                                 
{
  // disable interrupt
  bitClear(EIMSK, INT1);
}


Then compilation fire me

core.a(WInterrupts.c.o): In function `__vector_2':
S:\Skydrive\PortableApps\Arduino-1.0.5\hardware\arduino\cores\arduino/WInterrupts.c:314: multiple definition of `__vector_2'
Struct_receive.cpp.o:S:\Skydrive\PortableApps\Arduino-1.0.5/Struct_receive.ino:25: first defined here


So I think the problem is coming from core, as soon as it sees one IRQ routine it is creating all ISR vectors even the one not used !!!

Title: Re: RFM69 library does not let me using free IRQ1 in my sktech
Post by: Charly86 on January 14, 2015, 01:38:08 PM
Felix,

Bingo !!!

As soon as you use Attach or Detach interrupt routine, Arduino compile WInterrupts.c file which contains ISR0 and ISR1 IRQ code !!!

the only way to go out is that I use also attach interrupt code to bring it to my ISR routine, what a pain this is exactly I did not wanted to do since my IRQ are very critical in term of timing, playing with IRQ flags, ... and I don't want any overhead code.

Not your fault, I'm just pushing Arduino framework to its limits ...