C8051F320使用外部22.1184M晶振,usb时钟该如何设置
- UID
- 819600
|
C8051F320使用外部22.1184M晶振,usb时钟该如何设置
设备用到了usb与uart端口,为保证长时音的稳定用了22.1184M晶振。
调试时用了内部时钟,usb能被pc正常识别并安装驱动,但切换到外部晶振后被pc识别为未知的设备(晶振已起振),这是用config2.exe生成的时钟配置,有问题吗?
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 |
|
|
|
|
|