关于没有搜索到串口的问题

2019-07-20 23:16发布

我把标准例程下载进来  
void  My_USART1_Init(void)
{

GPIO_InitTypeDef  GPIO_InitStructure;
USART_InitTypeDef  USART_InitStructure;//串口结构体定义
NVIC_InitTypeDef  NVIC_InitStructure;//优先级设置

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);//使能USART1时钟
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD,ENABLE);
   
GPIO_PinAFConfig(GPIOD,GPIO_PinSource12,GPIO_AF_USART1);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource13,GPIO_AF_USART1);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource14,GPIO_AF_USART1);
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource15,GPIO_AF_USART1);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//复用选择AF模式
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOD, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//复用选择AF模式
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOD, &GPIO_InitStructure);





   //USART1 初始化设置
USART_InitStructure.USART_BaudRate = 115200;//波特率设置
USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式
USART_InitStructure.USART_StopBits = USART_StopBits_1;//一个停止位(0.5 1 1.5 2 有什么区别?)
USART_InitStructure.USART_Parity = USART_Parity_No;//无奇偶校验位(有的话字长9位?)
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//无硬件数据流控制
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //收发模式

  USART_Init(USART1,&USART_InitStructure);
  USART_Cmd(USART1, ENABLE);

USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //接收到非空就中断



  NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;//串口1中断通道
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3;//抢占优先级3
NVIC_InitStructure.NVIC_IRQChannelSubPriority =3; //子优先级3
NVIC_Init(&NVIC_InitStructure); //根据指定的参数初始化VIC寄存器
}
但是始终提示这样  这是为什么 是硬件电路有问题吗?

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