added Makefile switches to change F_CPU

This commit is contained in:
Steffen Vogel 2012-04-15 13:47:20 +02:00
parent 77b07f1b89
commit 1a5c60e4c4
3 changed files with 14 additions and 7 deletions

View file

@ -11,14 +11,17 @@ TARGET=atmega8
HFUSE=0xc9
LFUSE=0xef
# crystal frequency
#F_CPU=12000000
F_CPU=16000000
# ISP=bsd PORT=/dev/parport0
# ISP=ponyser PORT=/dev/ttyS1
# ISP=stk500 PORT=/dev/ttyS1
# ISP=usbasp PORT=/dev/usb/ttyUSB0
# ISP=stk500v2 PORT=/dev/ttyUSB0
ISP=usbasp
PORT=/dev/usb/ttyUSB0
ISP=avrisp2
PORT=usb
help:
@echo "Usage: make same as make help"
@ -33,11 +36,11 @@ help:
@echo " TARGET=${TARGET}"
@echo " LFUSE=${LFUSE}"
@echo " HFUSE=${HFUSE}"
@echo " CLOCK=12000000"
@echo " CLOCK=${F_CPU}"
@echo " ISP=${ISP}"
@echo " PORT=${PORT}"
COMPILE = avr-gcc -Wall -O2 -Iusbdrv -I. -mmcu=$(TARGET) # -DDEBUG_LEVEL=2
COMPILE = avr-gcc -Wall -O2 -Iusbdrv -I. -mmcu=$(TARGET) -DF_CPU=${F_CPU} # -DDEBUG_LEVEL=2
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o isp.o clock.o tpi.o main.o

View file

@ -11,9 +11,13 @@
#ifndef __clock_h_included__
#define __clock_h_included__
#define F_CPU 12000000L /* 12MHz */
#ifndef F_CPU /* should be defined in Makefile */
#define F_CPU 16000000L /* 16MHz */
#endif
#define TIMERVALUE TCNT0
#define CLOCK_T_320us 60
#define CLOCK_T_320us (320e-6*F_CPU/64) /* prescaler is 64 as defined below */
#ifdef __AVR_ATmega8__
#define TCCR0B TCCR0

View file

@ -35,7 +35,7 @@ the newest features and options.
* This may be any bit in the port. Please note that D+ must also be connected
* to interrupt pin INT0!
*/
#define USB_CFG_CLOCK_KHZ 12000
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
/* Clock rate of the AVR in MHz. Legal values are 12000, 16000 or 16500.
* The 16.5 MHz version of the code requires no crystal, it tolerates +/- 1%
* deviation from the nominal frequency. All other rates require a precision