Pages: [1]   Go Down
Author Topic: How to access TCNT1 (ATmega168)?  (Read 1834 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

Hi,
Writing my first sketch.

I need to read the value of the 16-bit timer/counter TCNT1 and also at some later time reset it. Regarding set-up, full-speed (divide by 1) is fine (this is default?).

Is this supported in Arduino 0011? Do I need to INCLUDE (not sure how to do that) something in order to use TCNT1?

Examples would be appreciated, but not required http://www.arduino.cc/yabbfiles/Templates/Forum/default/wink.gif

Thanks in advance,
Dave
Logged

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

Include avr/io.h and then you can read/write directly to TCNT1, like so:

TCNT1 = 0;
Logged

London
Offline Offline
Faraday Member
**
Karma: 9
Posts: 6247
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Note that io.h is included automatically by the arduino build process.

  TCNT1 = 0;

will work without explicitly adding the include file.
Logged

Pages: [1]   Go Up
Jump to: