Browse Source

declaration of F_CPU now in the makefile, only check in the c-source, if it was forgotten

master
T. Meissner 12 years ago
parent
commit
b8d183c04c
2 changed files with 8 additions and 6 deletions
  1. +4
    -2
      avr/makefile
  2. +4
    -4
      avr/src/avrtest.c

+ 4
- 2
avr/makefile View File

@ -4,10 +4,12 @@ SOURCES = src/avrtest.c
CC = avr-gcc
OBJCOPY = avr-objcopy
MMCU = atmega88
F_CPU = 10000000UL
#F_CPU = 11059200UL
DUMMY_BINARY:=$(shell mkdir -p binary)
CFLAGS = -mmcu=$(MMCU) -Wall -Os -std=gnu99
CFLAGS = -mmcu=$(MMCU) -DF_CPU=$(F_CPU) -Wall -Os -std=gnu99
compile : binary/$(PROJECT).out
@ -18,7 +20,7 @@ binary/$(PROJECT).out: $(SOURCES)
$(CC) $(CFLAGS) -I./ -o binary/$(PROJECT).out $(SOURCES)
program: binary/$(PROJECT).hex
avrdude -p m88 -c buspirate -P /dev/cu.PL2303-003012FA -e -U flash:w:binary/$(PROJECT).hex
avrdude -p m88 -c buspirate -P /dev/cu.PL2303-00* -e -U flash:w:binary/$(PROJECT).hex
clean:
rm -rf binary/

+ 4
- 4
avr/src/avrtest.c View File

@ -3,13 +3,13 @@
#include <stdint.h>
#ifndef F_CPU
#warning "F_CPU wasn't set in makefile, so we do it now with 8.0 MHz"
#define F_CPU 1000000UL
#warning "F_CPU wasn't set in makefile, so we do it now with 10.0 MHz"
#define F_CPU 10000000UL
#endif
// setting baud rate
#define BAUD 4800UL
#define BAUD 9600UL
// uart baud rate checks
#define UBRR_VAL ((F_CPU+BAUD*8)/(BAUD*16)-1)
@ -17,7 +17,7 @@
#define BAUD_ERROR ((BAUD_REAL*1000)/BAUD)
#if ((BAUD_ERROR<990) || (BAUD_ERROR>1010))
#error baudrate error higher than 1%!
#warning baudrate error higher than 1%!
#endif


Loading…
Cancel
Save