Browse Source

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

T. Meissner 7 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
4 4
 CC = avr-gcc
5 5
 OBJCOPY = avr-objcopy
6 6
 MMCU = atmega88
7
+F_CPU = 10000000UL
8
+#F_CPU = 11059200UL
7 9
 
8 10
 DUMMY_BINARY:=$(shell mkdir -p binary)
9 11
 
10
-CFLAGS = -mmcu=$(MMCU) -Wall -Os -std=gnu99
12
+CFLAGS = -mmcu=$(MMCU) -DF_CPU=$(F_CPU) -Wall -Os -std=gnu99
11 13
 
12 14
 compile : binary/$(PROJECT).out
13 15
 
@@ -18,7 +20,7 @@ binary/$(PROJECT).out: $(SOURCES)
18 20
 	$(CC) $(CFLAGS) -I./ -o binary/$(PROJECT).out $(SOURCES)
19 21
 
20 22
 program: binary/$(PROJECT).hex
21
-	avrdude -p m88 -c buspirate -P /dev/cu.PL2303-003012FA -e -U flash:w:binary/$(PROJECT).hex
23
+	avrdude -p m88 -c buspirate -P /dev/cu.PL2303-00* -e -U flash:w:binary/$(PROJECT).hex
22 24
 
23 25
 clean:
24 26
 	rm -rf binary/

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

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