Pages: [1]   Go Down
Author Topic: Newb Q re. interrupts & timers  (Read 507 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, all,
First post.

Arduino is "in the mail". I'm studying up and seem to be missing some documentation.

I have the Arduino Reference (it came with the Arduino-011 package) and the Atmel reference (376 pages!) for the ATmega168.

I want to use timers and interrupts yet I see little (only attach & detach; not even enable & disable!) information in the Arduino extended reference.

Where's the "nitty gritty" on implementing interrupts and using timers in Arduino? Is this possible using the Arduino tools? Or does this require something like writing an assembly lib. routine?

Help finding documentation and suggestions as to how interrupts and timers are used would be appreciated...ß smiley-sad

I found this article which helps in the basics, but it's not done in the Arduino environment:
http://www.evilmadscientist.com/article.php/avrdac

Thanks,
Dave

PS, if this is an inappropriate place to ask this Q, apologies; just point me in the right direction...
« Last Edit: April 19, 2008, 01:04:56 pm by Sparkyy » Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 854
Arduino rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There's a pretty good library that implements timer interrupts on Arduino:
http://www.arduino.cc/playground/Code/FrequencyTimer2

Just remember whatever frequency you set, it will run your interrupt handler at twice that rate (it's a silly bug that caused me a lot of trouble).
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
There's a pretty good library that implements timer interrupts on Arduino:
http://www.arduino.cc/playground/Code/FrequencyTimer2

Thanks for your reply.

I don't want to implement interrupts generated by the counter. I want to use external interrupts to execute a routine which will read the value of the counter then reset it. I'm comparing the timing of 2 external events. (I need 2 timers, 2 external interrupts.)

So the general answer to my Q is that this capability isn't handled by Arduino's standard implementation; I need to use library functions to handle interrupts and manipulate the counters? This is why no mention is made in the reference?

Thanks again,
Dave
Newb'
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can use the External interrupts 0 and 1, available on digital pins 2 and 3 respectively. These are the two interrupts that use the attachInterrupt function. When you call it, it will automatically enable the interrupts for those two vectors.
You can set the interrupts to trigger on the falling or rising edge of the signal, or when it is low. The datasheet describes them as INT0 and INT1, starting from page 67.
Logged

Pages: [1]   Go Up
Jump to: