OSCXCN = 0x67;
for (i = 0; i < 3000; i++); // Wait 1ms for initialization
while ((OSCXCN & 0x80) == 0);
CLKMUL = 0x80;
for (i = 0; i < 20; i++); // Wait 5us for initialization
CLKMUL |= 0xC0;
while ((CLKMUL & 0x20) == 0);
CLKSEL = 0x11;
OSCICN = 0x83;
用内部时钟没问题:
CLKSEL = 0x00; // Set SYSCLK to 12 / 8 MHz
OSCICN &= ~0x03;
CLKMUL = 0x00;
CLKMUL |= 0x80; // Enable clock multiplier
// delay about 5 us (8 clock)
_nop_(); _nop_(); _nop_(); _nop_();
_nop_(); _nop_(); _nop_(); _nop_();
CLKMUL |= 0xC0; // Initialize the clock multiplier
while(!(CLKMUL & 0x20)); // Wait for multiplier to lock
CLKSEL = USB_4X_CLOCK | SYS_4X_DIV_2; // Select system clock and USB clock