PA9PA10設置為復用推挽輸出和復用輸入,然后導致st-link不能識別,要按著復位鍵才能識別,下載程序時也需要先按著復位鍵,然后點擊下載的瞬間松開才能下載,這個是什么原因呢?
引腳配置如下:
void Usart1_Pin_Init(u32 brr)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
//打開時鐘
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
//PA9 復用推挽輸出
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);
//PA10 復用輸入
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_Init(GPIOA,&GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = brr;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//禁止硬件流
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;//模式
USART_InitStructure.USART_Parity = USART_Parity_No;//禁止奇偶校驗
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_Init(USART1,&USART_InitStructure);
USART_ITConfig(USART1,USART_FLAG_RXNE | USART_IT_TXE,ENABLE);
USART_Cmd(USART1,ENABLE);
}
|