ISR(TIMER0_OVF_vect) gives a compiler error

Hello,

i am playing around with the timers of the arduino uno board, and noticed that timer0-ovf doesn't compile.
what is the reason for that??
See code attached:

Thanks for the info .....

Timer_8bits_16bits_interrupt.ino (1.59 KB)

It compiles. It doesn't link, because TIMER0_OVF_vect (note spelling) is already used by the micros() and millis() library.

how can i make it run??

Change your loop function to be:

int main ()
  {
  setup ();
  
  // do other stuff here  
  }

Now it doesn't call init() and thus doesn't initialize the timers, and now it compiles. Be aware that you won't be able to use millis(), micros(), delay() etc.

I don't see where you are using Timer 2. Why not use Timer 2 instead of Timer 0, then you won't have these problems.

boolean updown;
boolean onoff0;

They should be declared volatile, by the way.

Nice trick

thanks

Is the program will run faster if we use int main () instead setup and loop.
I thought that if we do not use millis, micros, delay in sketch, ISR(TIMER0_OVF_vect) is not busy, and the controller does not waste time to increase millis and micros?

Yes, it would save spending around 4µS x 1000 per second (say, 4 mS per second) by doing that.

I wouldn't call it a "waste" to keep track of time. Still, if you don't need it you don't have to. Or, you could just stop the timer.