added arduino archive programs to /firmware/ref/archive-code/arduino
[athena:athena.git] / firmware / ref / archive-code / atmega / Timer1Testing / Timer1Testing.c
1 \r
2 #include <avr/io.h>\r
3 \r
4 int count=1;\r
5 \r
6 void init_timer1()\r
7 {\r
8         TCCR1B=0x19;\r
9         TCNT1=0;\r
10         TCCR1A=0xa2;\r
11         TIMSK=0x00;\r
12         sei();\r
13         OCR1A=0x0000;\r
14 \r
15 }\r
16 \r
17 int main()\r
18 {\r
19         DDRD=0xff;\r
20 \r
21         init_timer1();\r
22 \r
23         while(1)\r
24         {\r
25                                 \r
26 \r
27                 if(OCR1A==20000)\r
28                 {\r
29                         OCR1A=0x0000;\r
30                         count=1;\r
31                 }\r
32                 else\r
33                 {\r
34                         OCR1A=(100*count);\r
35                         _delay_ms(10);\r
36                         count++;\r
37                 }\r
38 \r
39         }\r
40 \r
41 }\r
42 \r
43 \r
44         }\r
45 }\r