STM32F103 uart3的RXD引脚一直为高电平,强制拉低后可进入串口接收中断

2019-08-22 13:13发布

STM32F103 uart3的RXD引脚在配置完引脚后为浮动模式(蓝 {MOD}部分),一旦进入使能串口(红 {MOD}部分)就会持续为高,强制拉低后可进入串口接收中断,但是强制拉低是测试电流为50ma。
以下为初始化代码,请大家帮忙看看,这个问题困惑我一个星期了。
void uart3_init ()
{
    GPIO_InitTypeDef GPIO_InitStructure;
    USART_InitTypeDef USART_InitStructure;
    NVIC_InitTypeDef NVIC_InitStructure;

   //?????RCC??
   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB , ENABLE); //??UART3??GPIOB???
   RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);

   //?????GPIO???
   // Configure USART2 Rx (PB.11) as input floating  
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
   GPIO_Init(GPIOB, &GPIO_InitStructure);

   // Configure USART2 Tx (PB.10) as alternate function push-pull
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
   GPIO_Init(GPIOB, &GPIO_InitStructure);

   //????
   USART_InitStructure.USART_BaudRate = 9600;
   USART_InitStructure.USART_WordLength = USART_WordLength_9b;
   USART_InitStructure.USART_StopBits = USART_StopBits_1;
   USART_InitStructure.USART_Parity = USART_Parity_Even;
   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
   USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;


   // Configure USART3
   USART_Init(USART3, &USART_InitStructure);//????3

  // Enable USART1 Receive interrupts ????????
   USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
   //??????????????
   //USART_ITConfig(USART2, USART_IT_TXE, ENABLE);

   // Enable the USART3
   USART_Cmd(USART3, ENABLE);//????3

   //??????
   //Configure the NVIC Preemption Priority Bits   
   NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

   // Enable the USART3 Interrupt
   NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
   NVIC_Init(&NVIC_InitStructure);
}

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。