Disabling Timer0 interrupt

The AAG weather station that I'm reprogramming has the Hall effect for wind speed connected to T0. Reconnecting it to a different input would be a major pita so i'd rather not.

Since Timer0 is used by the system, I can't just commandeer it for my own purpose without disabling the Timer0 ISR. What is the best way to do that?

I've considered commenting out it's initialization routine in wiring.h void init() and then redefining SIGNAL(TIMER0_OVF_vect). Is there more to it than that? I realize I'll lose millis() and some PWM but that doesn't concern me.

As you'll have to reconfigure some registers for using the external clock input for timer0 anyway, you can also disable the overflow interrupt.

For ATmegaXX8 chips, this would be

TIMSK0 &= ~_BV(TOIE0); // disable timer0 overflow interrupt

However, this does not remove the code inside the ISR form the hexfile. Fortunately in case of Timer0 it is just a few bytes. So I guess what you were planning is the way to go. Now it would be good to know if delay is used in the core libraries themselves.

I can just do it and see what happens but I was hoping someone knew if it was going to break anything else.

The most obvious thing is that everything that uses an unmodified delay() will hang for quite a while. I guess the frequency of your hall sensor will be lower than the clock rate of the unmodified timer0.

I'll have to write my own delay(). I intend to repurpose the other timer/counters anyway, it's just a pity that AAG didn't use a different pin.

EmilyJane:
I'll have to write my own delay(). I intend to repurpose the other timer/counters anyway, it's just a pity that AAG didn't use a different pin.

You shouldn't have to roll your own from scratch (unless you wish to), avr-libc has the following available:

http://www.nongnu.org/avr-libc/user-manual/group__util__delay.html

Just add this to your sketch and the function should be available: #include <util/delay.h>

Disclaimer: I haven't actual tried this function, however I have used other avr-libc functions and they seemed
to do what they say they will.

Home page for avr-libc http://www.nongnu.org/avr-libc/user-manual/index.html

Lefty

Thank you, I'll check that out.

Disclaimer: I haven't actual tried this function, however I have used other avr-libc functions and they seemed to do what they say they will.

I have. The libc delay functions work very well. Warning: Passing a variable for the delay may pull in the floating-point code.