Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error compile when define ISR routine for external interrrupt #66

Closed
vlad2005 opened this issue Sep 17, 2016 · 6 comments
Closed

error compile when define ISR routine for external interrrupt #66

vlad2005 opened this issue Sep 17, 2016 · 6 comments

Comments

@vlad2005
Copy link

vlad2005 commented Sep 17, 2016

I got an error when i try to implement in ISR for external interrupt:

09:30:12 Building the project | Processing...
.pioenvs/optibootPro16MHzatmega328/libFrameworkArduino.a(WInterrupts.o): In function `__vector_2':
collect2: error: ld returned 1 exit status
09:30:16 ERROR | it took 4.49s

Here is implementation

#ifdef EXTERNAL_INTERRUPT
ISR(INT1_vect) {
  CounterControl::GATE_ISR();
};

void CounterControl::GATE_ISR() {

}
#endif
@gepd
Copy link
Owner

gepd commented Sep 17, 2016

Which board are you using megaatmega2560?
If don't, please upload your platformio.ini

I've added the setup and the loop and it compiled without problem

#ifdef EXTERNAL_INTERRUPT
ISR(INT1_vect) {
  CounterControl::GATE_ISR();
};

void CounterControl::GATE_ISR() {

}
#endif

void setup()
{

}
void loop()
{

}

@vlad2005
Copy link
Author

vlad2005 commented Sep 17, 2016

i don't use atmega 2560
Anyway, is very strange. In same file i have another precompile condition for another ISR (pin change interrupt) and compile without any problem.
In fact my cpp file contain two implementation. One for pin change interrupt and another for external interrupt. Both have same structure. When define pin change interrupt i don't have any error. When define external interrupt i got this error.
platformio.ini

[env:optibootPro16MHzatmega328]
platform = atmelavr
framework = arduino
board = optibootPro16MHzatmega328
[platformio]
src_dir = /home/dev/Arduino/test/Gate

here is board config

{
    "optibootPro16MHzatmega328": {
        "build": {
            "core": "arduino",
            "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_PRO",
            "f_cpu": "16000000L",
            "mcu": "atmega328p",
            "variant": "eightanaloginputs"
        },
        "frameworks": ["arduino"],
        "name": "Arduino Pro Mini Optiboot ATmega328 (5V, 16 MHz)",
        "platform": "atmelavr",
        "upload": {
            "disable_flushing": true,
            "maximum_ram_size": 2048,
            "maximum_size": 32256,
            "protocol": "arduino",
            "require_upload_port" : true,
            "speed": 115200
        },
        "url": "http://arduino.cc/en/Main/ArduinoBoardProMini",
        "vendor": "Arduino"
    }
}

@vlad2005
Copy link
Author

vlad2005 commented Sep 17, 2016

Remove package, delete all files and reinstall deviot with platformio 3.0.1. I have same problem.

L.E.
I try to compile same project using Arduino IDE. Also i got an error, so i think that is not related to deviot package.
Here is error:

WInterrupts.c.o (symbol from plugin): In function `attachInterrupt':
(.text+0x0): multiple definition of `__vector_2'
sketch/CounterControl.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board [Optiboot] Arduino Pro Mini 5V 16Mhz w/ ATmega328.

@vlad2005
Copy link
Author

vlad2005 commented Sep 17, 2016

Solved!
It's seem that EXTERNAL_INTERRUPT is used in some libraries. I change name to EXT_INTERRUPT and now project compile without error.
It is not a issue relating to Deviot package.
I apologize for the inconvenience!

L.E. Pfuffff! Now i found real problem. Because i use RCSwitch library witch work on external interrupt pin, obviously here are some implementation for ISR routine. When i try to re-implement same routine i got error. Everything compile fine if remove RCSwitch library. So it's an conflict with that library.

@gepd
Copy link
Owner

gepd commented Sep 17, 2016

Good to hear!

As recommendation, I realized your JSON file hasn't the right format, in PlatformIO 3 it should be like this:

{
    "build": {
        "core": "arduino",
        "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_PRO",
        "f_cpu": "16000000L",
        "mcu": "atmega328p",
        "variant": "eightanaloginputs"
    },
    "frameworks": ["arduino"],
    "name": "Arduino Pro Mini Optiboot ATmega328 (5V, 16 MHz)",
    "platform": "atmelavr",
    "upload": {
        "disable_flushing": true,
        "maximum_ram_size": 2048,
        "maximum_size": 32256,
        "protocol": "arduino",
        "require_upload_port" : true,
        "speed": 115200
    },
    "url": "http://arduino.cc/en/Main/ArduinoBoardProMini",
    "vendor": "Arduino"
}

Rename the json file as: optibootPro16MHzatmega328.json That way you will avoid any problem

@vlad2005
Copy link
Author

vlad2005 commented Sep 18, 2016

Yes, is truth! After i make update i see that not working with old json and need to do exactly what u say (after many try's). Maybe is better to make an update to this threat to help and other users.

@gepd gepd closed this as completed Sep 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants