aboutsummaryrefslogtreecommitdiff
path: root/c/timer/timer.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2021-06-05 11:10:23 +0000
committerrodri <rgl@antares-labs.eu>2021-06-05 11:10:23 +0000
commitedf5f145013aa28ffbc7f19f874cd489a92f8449 (patch)
tree05a7dfdae1b63a79bdfbb1fab84af35a51b5b99c /c/timer/timer.c
downloadavrtoys-edf5f145013aa28ffbc7f19f874cd489a92f8449.tar.gz
avrtoys-edf5f145013aa28ffbc7f19f874cd489a92f8449.tar.bz2
avrtoys-edf5f145013aa28ffbc7f19f874cd489a92f8449.zip
public release.HEADmaster
Diffstat (limited to 'c/timer/timer.c')
-rw-r--r--c/timer/timer.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/c/timer/timer.c b/c/timer/timer.c
new file mode 100644
index 0000000..f1231b1
--- /dev/null
+++ b/c/timer/timer.c
@@ -0,0 +1,23 @@
+#include <avr/io.h>
+
+enum{
+ Dcnt = 62499
+};
+
+int
+main()
+{
+ int led;
+
+ led = 1<<PB1;
+ DDRB |= led;
+ TCCR1B |= 1<<CS12;
+
+ for(;;){
+ if(TCNT1 >= Dcnt){
+ PORTB ^= led;
+ TCNT1 = 0;
+ }
+ }
+}
+