|
PA9PA10設(shè)置為復(fù)用推挽輸出和復(fù)用輸入,然后導(dǎo)致st-link不能識(shí)別,要按著復(fù)位鍵才能識(shí)別,下載程序時(shí)也需要先按著復(fù)位鍵,然后點(diǎn)擊下載的瞬間松開(kāi)才能下載,這個(gè)是什么原因呢?
引腳配置如下:
void Usart1_Pin_Init(u32 brr)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
//打開(kāi)時(shí)鐘
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
//PA9 復(fù)用推挽輸出
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 復(fù)用輸入
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;//禁止奇偶校驗(yàn)
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);
}
|
|