Interrupt or timer call?

Hi All,

Is it possible to set up a timer or an interrupt to call a function every 10ms? I know how to do it with polling, but I'd rather have a function called that will simply increment a variable.

Thanks in advance.

Is it possible to set up a timer or an interrupt to call a function every 10ms?

Yes. I assume you are asking about the hardware timers in the processor rather than a millis() or micros() based software timer.

You can use either one of Paul Stoffregen's simple timer libraries which both have one line instructions to call an interrupt at an interval.

If you want to write your own code to interface with the hardware timers you can start with this tutorial

Google search for "atmega328 timer tutorial" or "avr timer tutorial" and you will find plenty more.

If you you are motived, search out the holy ATmega 328 data sheet

MitchSF:
Is it possible to set up a timer or an interrupt to call a function every 10ms?

Yes it is.

Thank you!