加载了ST 的 Joystick Mouse demo 程序,在一块8M外部晶体上运行很好,在另一块16M的晶体上却不能识别。
16M的程序修改如下:
void Set_System(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
/* RCC system reset(for debug purpose) */
RCC_DeInit();
/* Enable HSE */
RCC_HSEConfig(RCC_HSE_ON);
/* Wait till HSE is ready */
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if (HSEStartUpStatus == SUCCESS)
{
/* Enable Prefetch Buffer */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);
/* HCLK = SYSCLK */
RCC_HCLKConfig(RCC_SYSCLK_Div1);
/* PCLK2 = HCLK */
//----------------------------------------------------------------------------
// RCC_PCLK2Config(RCC_HCLK_Div1);
RCC_PCLK2Config(RCC_HCLK_Div2); // // 我修改过的
//----------------------------------------------------------------------------
/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);
//----------------------------------------------------------------------------
RCC_PLLConfig(RCC_PLLSource_HSE_Div2, RCC_PLLMul_10); // 我修改过的
//----------------------------------------------------------------------------
/* On STICE the PLL output clock is fixed to 72 MHz */
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
/* Enable PLL */
RCC_PLLCmd(ENABLE);
/* Wait till PLL is ready */
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{}
/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source */
while (RCC_GetSYSCLKSource() != 0x08)
{}
}
我是参照下面这个问题修改的。结果还是不正常。各位大虾,我应该如何改?
https://bbs.21ic.com/viewthread.php?tid=229480&highlight=usb%2B%E6%99%B6%E4%BD%93 |