{
GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; /* USART2 Tx --> PD05 */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; /* PD05 --> JP7 WR */ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; /* USART2 Rx --> PD06 */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE); }
该程序将USART2重映射到PD05,PD06引脚
4、实验现象
PD05连接的是USART2 Tx,PD06连接的是USART2 Rx,通过串口调试助手就可以在电脑上面显示Program Running!
5、实验总结
通过本次实验,可以实现对异步通信USART2的重映射,再通过串口调试助手在电脑上显示出来。
11