source: avrstuff/blinkled/main.c@ 4fbae10

main
Last change on this file since 4fbae10 was 4fbae10, checked in by Adrien Destugues <pulkomandy@…>, 10 years ago

Make it easier to use blinkdel with various AVRs.

git-svn-id: svn://pulkomandy.tk/avrstuff@97 c6672c3c-f6b6-47f9-9001-1fd6b12fecbe

  • Property mode set to 100644
File size: 641 bytes
Line 
1#include <avr/io.h>
2#include <avr/interrupt.h>
3#include <avr/wdt.h>
4#include <avr/pgmspace.h>
5#include <util/delay.h>
6
7#include <string.h>
8#include <stdbool.h>
9
10#ifdef __AVR_ATmega48P__
11#define TIFR TIFR0
12#endif
13
14int main() {
15 wdt_enable(WDTO_2S);
16 // configure timer 0 for a rate of 16M/(256 * 256) = ~244Hz
17 TCCR0A = 0; // timer 0 prescaler: 256
18 TCCR0B = 4;
19
20 //debug LED - output
21 DDRD |= 255;
22
23 PORTD = 0xAA;
24
25 while(1) {
26 wdt_reset();
27
28
29 // check timer if we need periodic reports
30 if (TIFR & (1 << TOV0)) {
31 TIFR = (1 << TOV0); // reset flag
32 PORTD++;
33 }
34 }
35
36 return 0;
37}
38
Note: See TracBrowser for help on using the repository browser.