Timer Lib or Timer interrupt for Teensy 3.0/3.1

Status
Not open for further replies.

Vignesh

Member
Hi
I am looking for Timer Lib or some Library with which I can schedule a timer. When the timer expires it will invoke the callback registered with it. Is there any such library ? if not, is there any ref code on Timer and Timer interrupt that I can look at ?
This is for Teensy 3.1
Thanks and regards,
Vignesh
 
Thanks nox771 ! that worked !!
I had tried the code mentioned in post #2 here :http://forum.pjrc.com/threads/25375-Teensy-Timer-Counter-Example-for-the-T3-amp-T3-1?highlight=timer
..and it strangely did not work!
here is my code in case if some one is interested..
Thanks and Regards
Vignesh

IntervalTimer myTimer;
const int ledPin = 13;
int led_state = 0;

void timer_fun()
{
if (led_state == 0)
{
digitalWrite(ledPin, HIGH); // set the LED on
led_state = 1;
}
else
{
digitalWrite(ledPin, LOW); // set the LED off
led_state = 0;
}
}

void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
myTimer.begin(timer_fun, 150000);
led_state = 0;
}

void loop()
{
Serial.println(led_state); // Not int protected !
delay(500); // wait for a second
}
 
Status
Not open for further replies.
Back
Top