Timer 0 overflow interrupt

Hi Everyone,

I plan to use timer 0 overflow interrupt to "tap" into the 490Hz frequency it generates.

Why?
I want to generate ADC conversions at this rate, instead of the default 4096Hz
I want to have a variable to generate accurate delays without having to compare the milis function every loop.

Issue is, I don't directly have access to it on the IDE, instead I have to go to line 49 of the wiring.c file and make my changes there, which pretty much become valid for every sketch.

Any suggestions to deal with this issue?

Provide a callback.
If the callback pointer is non zero, call it, otherwise, do nothing.
Simples.

Enable the pin change interrupt on one of the two output pins. Start the PWM output (analogWrite will work). Trigger a conversion in the pin change interrupt handler.

I want to have a variable to generate accurate delays without having to compare the milis function every loop.

...is an extremely weak argument for using interrupts.

AWOL:
Provide a callback.
If the callback pointer is non zero, call it, otherwise, do nothing.
Simples.

So I would place the callback on the wiring.c and would check it on the loop, correct?
Could you be so kind as to show an example of how to do this?

Thanks

I would still be using an interrupt, so what makes it more efficient?

Ok, i found a workaround.

Inside the Timer0 ISR I added a line to manually trigger an ADC conversion, as per above.

When the ADC is ready, it generates its own ISR (I am not using arduino built in ADC function), therefore I just increment the variable there.

Result: I get an accurate delay in the form of an ISR, save a timer and about 20 cycles required to call another ISR.

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=50106

Have a look at this topic.