From 99145a8d7c88d9af065cfb7f5e8507d5b65ff811 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 26 Feb 2009 05:48:47 +0000 Subject: Makefiles and library modified to add a new F_CLOCK constant to give the unprescaled master input clock frequency, so that the correct PLL mask can be determined even when the CPU (F_CPU) clock rate is prescaled outside the normal input range of the PLL. Started to clean up the AVRISP Programmer project code, donated by Opendous Inc. --- LUFA/ChangeLog.txt | 2 ++ LUFA/Drivers/USB/LowLevel/LowLevel.h | 9 +++++++-- LUFA/GettingStarted.txt | 16 ++++++++++++---- LUFA/MigrationInformation.txt | 8 ++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) (limited to 'LUFA') diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt index fd21b3f10..af15a964d 100644 --- a/LUFA/ChangeLog.txt +++ b/LUFA/ChangeLog.txt @@ -21,6 +21,8 @@ * - Fixed KeyboardMouse demo discarding the wIndex value in the REQ_GetReport request * - USBtoSerial demo now discards all Rx data when not connected to a USB host, rather than buffering characters for transmission * next time the device is attached to a host. + * - Added new F_CLOCK compile time constant to the library and makefiles, to give the raw input clock (used to feed the PLL before any + * clock prescaling is performed) frequency, so that the PLL prescale mask can be determined * * \section Sec_ChangeLog090209 Version 090209 * diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.h b/LUFA/Drivers/USB/LowLevel/LowLevel.h index faafbd7bf..9721baca0 100644 --- a/LUFA/Drivers/USB/LowLevel/LowLevel.h +++ b/LUFA/Drivers/USB/LowLevel/LowLevel.h @@ -66,7 +66,12 @@ #endif /* Preprocessor Checks and Defines: */ - #if (F_CPU == 8000000) + #if !defined(F_CLOCK) + #error F_CLOCK is not defined. You must device F_CLOCK to the frequency of the unprescaled input clock in your project makefile. + #define F_CLOCK 0 + #endif + + #if (F_CLOCK == 8000000) #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__)) #define USB_PLL_PSC 0 #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || \ @@ -76,7 +81,7 @@ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) #define USB_PLL_PSC 0 #endif - #elif (F_CPU == 16000000) + #elif (F_CLOCK == 16000000) #if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__)) #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1)) #elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)) diff --git a/LUFA/GettingStarted.txt b/LUFA/GettingStarted.txt index 0fe3f50b9..a88a82533 100644 --- a/LUFA/GettingStarted.txt +++ b/LUFA/GettingStarted.txt @@ -57,14 +57,22 @@ * directory into a /Board/ folder inside the application directory, and the stub driver completed with the appropriate code to drive the * custom board's hardware. * - * \subsection SSec_F_CPU The F_CPU Parameter - * This parameter indicates the target AVR's master clock frequency, in Hz. Consult your AVR model's datasheet for allowable clock frequencies - * if the USB interface is to be operational. + * \subsection SSec_F_CLOCK The F_CLOCK Parameter + * This parameter indicates the target AVR's input clock frequency, in Hz. This is the actual clock input, before any prescaling is performed. In the + * USB AVR architecture, the input clock before any prescaling is fed directly to the PLL subsystem, and thus the PLL is derived directly from the + * clock input. The PLL then feeds the USB and other sections of the AVR with the correct upscaled frequencies required for those sections to function. * - * Note that this value does not actually *alter* the AVR's clock frequency, it is just a way to indicate to the library the clock frequency + * Note that this value does not actually *alter* the AVR's input clock frequency, it is just a way to indicate to the library the clock frequency * of the AVR as set by the AVR's fuses. If this value does not reflect the actual running frequency of the AVR, incorrect operation of one of more * library components will ocurr. * + * \subsection SSec_F_CPU The F_CPU Parameter + * This parameter indicates the target AVR's master CPU clock frequency, in Hz. + * + * Note that this value does not actually *alter* the AVR's CPU clock frequency, it is just a way to indicate to the library the clock frequency + * of the AVR core as set by the AVR's fuses. If this value does not reflect the actual running frequency of the AVR, incorrect operation of one of more + * library components will ocurr. + * * \subsection SSec_CDEFS The CDEFS Parameter * Most applications will actually have multiple CDEF lines, which are concatenated together with the "+=" operator. This ensures that large * numbers of configuration options remain readable by splitting up groups of options into seperate lines. diff --git a/LUFA/MigrationInformation.txt b/LUFA/MigrationInformation.txt index 1cdb55ae7..cd23da332 100644 --- a/LUFA/MigrationInformation.txt +++ b/LUFA/MigrationInformation.txt @@ -12,6 +12,14 @@ * * \section Sec_MigrationXXXXXX Migrating from 090209 to XXXXXX * + * All + * - LUFA projects must now give the raw input clock frequency (before any prescaling) as a compile time constant "F_CLOCK", + * defined in the project makefile and passed to the compiler via the -D switch. + * - The makefile EEPROM programming targets for FLIP and dfu-programmer no longer program in the FLASH data in addition to the + * EEPROM data into the device. If both are to be programmed, both the EEPROM and FLASH programming targets must be called. + * + * Library Demos + * - The USBtoSerial demo now discards all data when not connected to a host, rather than buffering it for later transmission. * * \section Sec_Migration090209 Migrating from 081217 to 090209 * -- cgit v1.2.3