Changeset 6f22754 in avrstuff for blinkled/main.c
- Timestamp:
- Sep 7, 2019, 6:17:17 PM (5 years ago)
- Branches:
- main
- Children:
- e5dd493
- Parents:
- bbcd1f8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
blinkled/main.c
rbbcd1f8 r6f22754 8 8 #include <stdbool.h> 9 9 10 #ifdef __AVR_ATmega48P__ 11 #define TIFR TIFR0 10 #if defined(__AVR_ATmega8__) 11 #define _TCCA TCCR1A 12 #define _TCCB TCCR1B 13 #define _TIFR TIFR 14 #define _TOV TOV1 15 #elif defined(__AVR_ATmega48P__) 16 #define _TCCA TCCR0A 17 #define _TCCB TCCR0B 18 #define _TIFR TIFR0 19 #define _TOV TOV0 20 #else 21 #error Unknown device! Add it to main.c and set the timer properly 12 22 #endif 13 23 … … 15 25 wdt_enable(WDTO_2S); 16 26 // configure timer 0 for a rate of 16M/(256 * 256) = ~244Hz 17 TCCR0A = 0; // timer 0 prescaler: 25618 TCCR0B = 4;27 _TCCA = 0; // timer 0 prescaler: 256 28 _TCCB = 4; 19 29 20 30 //debug LED - output … … 28 38 29 39 // check timer if we need periodic reports 30 if ( TIFR & (1 << TOV0)) {31 TIFR = (1 << TOV0); // reset flag40 if (_TIFR & (1 << _TOV)) { 41 _TIFR = (1 << _TOV); // reset flag 32 42 PORTD ^= (1<<PD6); 33 43 }
Note:
See TracChangeset
for help on using the changeset viewer.