Changeset 6f22754 in avrstuff
- Timestamp:
- Sep 7, 2019, 6:17:17 PM (5 years ago)
- Branches:
- main
- Children:
- e5dd493
- Parents:
- bbcd1f8
- Location:
- blinkled
- Files:
-
- 3 added
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
blinkled/Makefile
rbbcd1f8 r6f22754 1 # Set vars2 MCU=atmega 48p1 # User configurable variables 2 MCU=atmega8 3 3 FCPU=16000000 4 COMPILE = avr-gcc -Wall -Os -std=c99 -mmcu=$(MCU) -DF_CPU=20000000 4 PROG=stk500 -P /dev/ports/usb0 5 6 # You should not need to change anything below 7 # ----------------------------------------------------------------------------- 8 COMPILE = avr-gcc -Wall -Wextra -Werror -Os -std=c99 -mmcu=$(MCU) -DF_CPU=$(FCPU) 5 9 6 10 #Rules … … 18 22 $(COMPILE) -mmcu=$(MCU) -std=c99 -c $< -o $@ 19 23 20 flash: 21 avrdude -c usbasp-p $(MCU) -Uflash:w:$(MCU).hex24 flash: $(MCU).hex 25 avrdude -c $(PROG) -p $(MCU) -Uflash:w:$(MCU).hex 22 26 23 27 clean: -
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.