for a project based on XMEGA128A1U, I use the sample code of LUFA :
Clock startup system is like following:
XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB);
As it can be seen, Internal 2MHz clock is multiplied to 16 to produce F_CPU clock by using PLL and is set for CPU Clock.
And internal R32MHz clock is enabled and by using DFLL is set to be used for USB clock which is 48MHz.
Based on my observations, I find that CPU clock does not have enough accuracy and has near 2% error.
Thus I need to event precise it or use external clock source for CPU clock.
I use following code for internal clock source but it does not work properly.
I find that I can not read any more data from USB device if I use above code.
Please help me.
1. How to set external clock (my external clock crystal is 8 MHz) in a way that it works.
2. Or how to make internal clock accurate (by using DFLL technique)
Please let me know how to use LUFA functions to reach this goal.