OnTimer0

From Pinguino
Revision as of 12:28, 31 August 2011 by Skc (talk | contribs) (Documentation from paintitblack posted on the mailling list.)
Jump to: navigation, search

Name

OnTimer0 - Call a function at fixed interval

Description

Call a function at a fixed interval using Timer0. The function is called indefinitely.

Since

beta 9.05

Syntax

 void OnTimer0(void (*callback)(), u8 timediv, u16 delay);
callback

Function called each time Timer0 trigger an interrupt

timediv

INT_MICROSEC, INT_MILLISEC or INT_SEC (for ms, us and sec.)

delay

time before interrupt is triggered (using timediv as unit)

Example

void blink13()
{
	toggle(13); // set pin 13 high if it's low and vice-versa
}

void setup()
{
       pinMode(13, OUTPUT);
       OnTimer0(blink13, INT_MILLISEC, 500); // Use Timer0 to toggle pin 13 every 500 ms
}

void loop()
{
}

Bugs

  • No method documented to disable it.
  • Does multi-call to OnTime0() stacks? Or does the last one overwrite the previous one?

See also

OnTimer1

OnTimer2

Comments