我有打开内核时钟监视,看到PCLK2频率是8Mhz,感到好生奇怪。手动调整SW为HSE clock。然后就是如下图的时钟了。
然后PCLK2时钟就是72Mhz了。
有问题的如下图:
[mw_shl_code=c,true]
void USART1_Init()
{
GPIO_InitTypeDef GPIO_InitStruct;
USART_InitTypeDef USART_InitStruct;
USART_ClockInitTypeDef USART_ClockInitStruct;
/* ?ò??·????????????±???????°USART1???±?? */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |
//RCC_APB2Periph_AFIO |
RCC_APB2Periph_USART1,ENABLE);
/* ????USART1??·????? */
GPIO_InitStruct.GPIO_Pin = USART1_TX;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStruct);
/* ????USART1???????? */
GPIO_InitStruct.GPIO_Pin = USART1_RX;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA,&GPIO_InitStruct);
/* ????USART1???¨???????????????é??×??¤?? */
//USART_StructInit(&USART_InitStruct);
USART_InitStruct.USART_BaudRate = 9600;
USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStruct.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
USART_InitStruct.USART_Parity = USART_Parity_No ;
USART_InitStruct.USART_StopBits = USART_StopBits_1;
USART_InitStruct.USART_WordLength = USART_WordLength_8b ;
USART_Init(USART1,&USART_InitStruct);
/* ????USART1???±?????????? */
USART_ClockStructInit(&USART_ClockInitStruct);
USART_ClockInit(USART1,&USART_ClockInitStruct);
/* ?ò??USART1 */
USART_Cmd(USART1,ENABLE);
}
[/mw_shl_code]
|