新手上路
- 积分
- 30
- 金钱
- 30
- 注册时间
- 2014-6-19
- 在线时间
- 0 小时
|
5金钱
芯片:stm32f103rc ,USART3选择部分重映射到PC10、PC11,第一版程序,串口的收发功能正常,但是当我将 PC12 配置为GPIO_Mode_Out_PP时(此时为第二版程序),发现串口只能发送,但是不能接收,这是怎么回事? PC10、PC11、PC12分别对应着USART3_RX、USART3_TX、USART3_CK
程序如下:
/* Partial Remap the ports of USART3 */
GPIO_PinRemapConfig(GPIO_PartialRemap_USART3,ENABLE);
/* Configure USART3 Rx as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/* Configure USART3 Tx as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/* 开启这个初始化,则串口接收功能失效,关闭则串口接收功能正常 */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|