Problem beim Kompilieren von ISR Routine

Eine Datei test.ino

#include <avr/io.h>
#include <avr/interrupt.h>

ISR ( TIMER2_OVF_vect ) {


}

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

lässt sich sofort kompilieren. Wenn ich die Datei aber folgendermaßen zerlege:

test.ino

#include "best.c"

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

und best.c

#include <avr/io.h>
#include <avr/interrupt.h>

ISR ( TIMER2_OVF_vect ) 
{
  

}

erhalte ich folgende Fehlermeldung:

Arduino: 1.6.7 (Windows 8.1), Board: "Arduino/Genuino Uno"

sketch\test.ino.cpp.o: In function `__vector_9':

sketch/best.c:5: multiple definition of `__vector_9'

sketch\best.c.o:sketch/best.c:5: first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1

Fehler beim Kompilieren.

Was klappt hier nicht? Über Eure Hilfe würde ich mich sehr freuen!!! Danke!

Da du ein .c Datei includest und die IDE alle .ino und .c Dateien übersetzt und linkt,
hast du zwei Definitionen von ISR ( TIMER2_OVF_vect ).

Die IDE Setzt alle Sketche die als Tabs offen sind zusammen und kompiliet dann (sind dann im selben unterverzeichnis).
Wenn Du best.c in test.ino includierst und beide im selben Unterverzeichnis sind dann hast Du best.c 2 mal includiert mit den Fehlern die Du bekommst.

Lösungen:

  • Laß das Include weg.
    und andere

Uwe