参考手册《ATMega32U4.pdf》
C:\WinAVR-20100110\doc\avr-libc\avr-libc-user-manual.pdf
C:\WinAVR-20100110\doc\avr-libc\avr-libc-user-manual\ 下面的网页
clock_prescale_set() 函数在 C:\WinAVR-20100110\avr\include\avr\power.h中定义
1、USB 时钟
《ATMega32U4.pdf》page40:
#define PINDIV 4/** Indicates that the target AVR microcontroller belongs to the Series 4 AVR8 USB controller* (i.e. ATMEGAxxU4) when defined.*/#define USB_SERIES_4_AVR#if !defined(F_USB)#error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile.#endif#if (F_USB == 8000000)#if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \defined(__AVR_ATmega32U2__))#define USB_PLL_PSC 0#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))#define USB_PLL_PSC 0#elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__))#define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))#elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))#define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))#endif#elif (F_USB == 16000000)#if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \defined(__AVR_ATmega32U2__))#define USB_PLL_PSC (1 << PLLP0)#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))#define USB_PLL_PSC (1 << PINDIV)#elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))#define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1))#elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))#define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP0))#endif#endif
2、CPU时钟
如果DIV8 设置了,被烧写了,那么分频是8分频。
如果DIV8没有设置,那么直接晶振是几Mhz ,系统CPU运行,就是多少MHZ
查看一下 arduino的 16u2的 DIV8 是设置的多少 ?