写STR711程序时,USB的时钟配置过程遇到以下问题,我用的是4M晶振,并直接连接到HCLK上 以下时钟培植过程中,前两个在USB枚举的过程中找不到设备,后两个时钟配置是可以成功找到设备.不知道为什么,差别也就在PCLK这块,我如果将PCLK配置为>24M就不行 /////////ERROR ERROR ERROR ERROR void Set_USBClock(void) { u32 Tmp; RCCU_Div2Config(DISABLE); RCCU_PLL1Config ( RCCU_PLL1_Mul_24 , RCCU_Div_2 ) ; for ( Tmp = 0x7f ; Tmp> 0; Tmp--) RCCU_RCLKSourceConfig ( RCCU_PLL1_Output ) ; /*Configure MCLK = RCLK*/ RCCU_MCLKConfig (RCCU_DEFAULT ); // MCLK=RCLK RCCU_FCLKConfig (RCCU_RCLK_2); // FCLK =RCLK/2 RCCU_PCLKConfig (RCCU_RCLK_2); // PCLK =RCLK/2
// Configure the PLL2 ( * 12 , / 1 ) HCLK=4MHz RCCU_PLL2Config (RCCU_PLL2_Mul_12,RCCU_Div_1); PCU->PLL2CR = 0x81D0; } void Set_USBClock(void) { u32 Tmp; RCCU_Div2Config(DISABLE); RCCU_PLL1Config ( RCCU_PLL1_Mul_24 , RCCU_Div_2 ) ; // RCCU_PCLKConfig (RCCU_RCLK_2); // APB2 PCLK2=RCLK/2 for ( Tmp = 0x7f ; Tmp> 0; Tmp--) RCCU_RCLKSourceConfig ( RCCU_PLL1_Output ) ;
/*Configure MCLK = RCLK*/ RCCU_MCLKConfig (RCCU_DEFAULT ); RCCU_PCLKConfig (RCCU_RCLK_2); // APB2 PCLK2=RCLK/2 RCCU_FCLKConfig (RCCU_RCLK_2); // APB2 PCLK2=RCLK/2
// Configure the PLL2 ( * 12 , / 1 ) assuming HCLK=4MHz RCCU_PLL2Config (RCCU_PLL2_Mul_12,RCCU_Div_1); PCU->PLL2CR = 0x81D0; }
/////////OK OK OK OK OK OK
void Set_USBClock(void) { u32 Tmp; RCCU_Div2Config(DISABLE); RCCU_PLL1Config ( RCCU_PLL1_Mul_12 , RCCU_Div_1 ) ; // RCCU_PCLKConfig (RCCU_RCLK_2); // APB2 PCLK2=RCLK/8 for ( Tmp = 0x7f ; Tmp> 0; Tmp--) RCCU_RCLKSourceConfig ( RCCU_PLL1_Output ) ;
/*Configure MCLK = RCLK*/ RCCU_MCLKConfig (RCCU_DEFAULT ); RCCU_PCLKConfig (RCCU_RCLK_4); // APB2 PCLK2=RCLK/8 RCCU_FCLKConfig (RCCU_RCLK_2); // APB2 PCLK2=RCLK/8
// Configure the PLL2 ( * 12 , / 1 ) assuming HCLK=4MHz RCCU_PLL2Config (RCCU_PLL2_Mul_12,RCCU_Div_1); PCU->PLL2CR = 0x81D0; }
void Set_USBClock(void) { u32 Tmp; RCCU_Div2Config(DISABLE); RCCU_PLL1Config ( RCCU_PLL1_Mul_24 , RCCU_Div_2 ) ; // RCCU_PCLKConfig (RCCU_RCLK_2); // APB2 PCLK2=RCLK/2 for ( Tmp = 0x7f ; Tmp> 0; Tmp--) RCCU_RCLKSourceConfig ( RCCU_PLL1_Output ) ;
/*Configure MCLK = RCLK*/ RCCU_MCLKConfig (RCCU_DEFAULT ); RCCU_PCLKConfig (RCCU_RCLK_4); // APB2 PCLK2=RCLK/2 RCCU_FCLKConfig (RCCU_RCLK_2); // APB2 PCLK2=RCLK/2
// Configure the PLL2 ( * 12 , / 1 ) assuming HCLK=4MHz RCCU_PLL2Config (RCCU_PLL2_Mul_12,RCCU_Div_1); PCU->PLL2CR = 0x81D0; }
|