timer Question

Can anyone explain why the code below is not given a 1/10 of second blink?

The timer initialize function is defined to have its parameter as microseconds

So how am i getting much slower blink then 10 blinks a second with this code.

Any help would be much appreciated. Im sure im missing something simple.

#include <TimerOne.h>

//My timer Test



void setup(){

pinMode(13,OUTPUT);
Timer1.initialize(100000);

Timer1.attachInterrupt(my_isr);
Serial.begin(96000);




}



void loop(){



}


void my_isr(){

digitalWrite(13,!digitalRead(13));


}

So how am i getting much slower blink then 10 blinks a second with this code.

How much slower? You are turning the LED on every other time, and off every other time the ISR is called. So, I'd expect the light to come on 5 times per second.

Thats kind of what i was thinking i was doing by accident.

It looks to the naked eye to be about half as fast as it should be

Any recommendations how to get the full speed by modifying my ISR code?

Thanks

Timer1.initialize(100000);

the 100000 misses UL Timer1.initialize(100000UL);

That may cause some strange effects

Timer1.initialize(50000UL); would double the speed.

All i really want to happen is i want an interrupt ever 1/10th of a second

Then save the value of millis() in your ISR, and print it out in the main loop. This will tell you how often your ISR gets called.

automagp68:
All i really want to happen is i want an interrupt ever 1/10th of a second

That's what you are doing.

If you want to complete a full (OFF to ON to OFF) blink every 1/10th of a second, you need to change the state every 1/20th of a second.

automagp68:
It looks to the naked eye to be about half as fast as it should be

I don't know how fast you think it should be. At what frequency is it actually flashing?