Problem with ISR(TIMER0_OVF_vect)

I want to write a program that allows me to read a sum signal from my RC-receiver.

Here is my code:

volatile unsigned char cSumSig[8]; //Array to store the channels
volatile uint8_t iCounter=0,iValid=0; 

//If I delete this code then Arduino compiles 
ISR(TIMER0_OVF_vect) {
  iCounter=0;                        // Reset Counter on Overflow
  iValid=0;                        // "disable" Timer 'till next rising

ISR(INT0_vect) {
  if(iValid==1) {                        // don't count before first pulse
    cSumSig[iCounter] = TCNT0;            // save pulse length
      iCounter++;                  // increase counter
  } else {
    iValid = 1;                        // "enable" Timer after first pulse
  TCNT0 = 0;                        // reset Timer

 void setup() {
  TIMSK0 |= (1<<TOIE0);                        // Overflow Interrupt enable
  TCCR0A |= ((1<<CS00) | (1<<CS02));            // Prescaler 128
  TCNT0 = 0;                              // Overflow between 2,2ms & 3,8ms
  EIMSK |= (1<<INT0);                        // INT0 enable
  EICRA |= ((1<<ISC01) | (1<<ISC00));              // external Interrupt on rising 
  sei();                              // enable global interrupts

 void loop() {
   Serial.println('test');   //just a test - i want to display the channels here later

arduino gives me the following debug information:

/tmp/build3799302546627044279.tmp/core.a(wiring.c.o): In function `init’:

/usr/share/arduino/hardware/arduino/cores/arduino/wiring.c:160: multiple definition of `__vector_16’

o:/tmp/build3799302546627044279.tmp/susi.cpp:26: first defined here

Can somebody help me please? I just cant see any reason why it is not working…


Timer 0 is used for the time calculation used by millis(), etc. The timer 0 overflow handler is defined in the core.

Thanks - so this means I have to use Timer2 right? Ill give it a try right away.

I changed timer0 to timer1:



 TIMSK1 |= (1<<TOIE0);                        // Overflow Interrupt enable
 TCCR1A |= ((1<<CS00) | (1<<CS02));            // Prescaler 128
 TCNT1 = 0;

With this changes I am able to compile the code, but it seems not to be working.
I guess the problem lies within the prescaler or so because this code is from a tutorial for a “ATMega128 with 14,745600MHz” as said in the tut.
I am using the Arduino Dueminlanove - so this is a ATMega328 right? I tried to get some information from the Atmel Datasheet but was not able to figure it out.

Would be nice if someone has a clue.


TIMSK1 |= (1<<TOIE0); // Overflow Interrupt enable

What are the values for the other bits? Is it possible the other bits in the TIMSK1 are set to the wrong values?

TCCR1A |= ((1<<CS00) | (1<<CS02)); // Prescaler 128

What are the values for the other bits? Is it possible the other bits in the TCCR1A are set to the wrong values?

@Coding Badly: I have to admit that I have no clue what the other bits are set to. As I already said, I just copied the code from some tut and modified the timer used. Could you please give me an example how they should be set?

Does this help…

Bear in mind that example manipulates Timer 2.