void Usart4_Initial(void)
{
GPIO_Config_T gpioConfig;
USART_Config_T usartConfigStruct;
RCM_EnableAHBPeriphClock(RCM_AHB_PERIPH_GPIOC);
RCM_EnableAPB1PeriphClock(RCM_APB1_PERIPH_USART4);
GPIO_ConfigPinAF(GPIOC, GPIO_PIN_SOURCE_10, GPIO_AF_PIN0); /* Connect PXx to USARTx_Tx */
GPIO_ConfigPinAF(GPIOC, GPIO_PIN_SOURCE_11, GPIO_AF_PIN0); /* Connect PXx to USARTx_Rx */
USART_EnableSWAPPin(USART4);
/* Configure USART Tx as alternate function push-pull */
/* Configure USART Rx as input floating */
gpioConfig.mode = GPIO_MODE_AF;
gpioConfig.pin = GPIO_PIN_10 | GPIO_PIN_11;
gpioConfig.speed = GPIO_SPEED_50MHz;
gpioConfig.outtype = GPIO_OUT_TYPE_PP;
gpioConfig.pupd = GPIO_PUPD_PU;
GPIO_Config(GPIOC, &gpioConfig);
/* MINI_USARTs configured as follow: */
/* BaudRate = 115200 baud */
usartConfigStruct.baudRate = 115200; /* BaudRate = 115200 baud */
usartConfigStruct.mode = USART_MODE_TX_RX; /* Receive and transmit enabled */
usartConfigStruct.hardwareFlowCtrl = USART_FLOW_CTRL_NONE; /* Hardware flow control disabled (RTS and CTS signals) */
usartConfigStruct.parity = USART_PARITY_NONE; /* No parity */
usartConfigStruct.stopBits = USART_STOP_BIT_1; /* One Stop Bit */
usartConfigStruct.wordLength = USART_WORD_LEN_8B; /* Word Length = 8 Bits */
USART_Config(USART4, &usartConfigStruct); /* USART_Config */
/* Enable USART_Interrupt_RXBNEIE */
USART_EnableInterrupt(USART4, USART_INT_RXBNEIE);
NVIC_EnableIRQRequest(USART3_4_IRQn, 2);
/* Enable USART */
USART_Enable(USART4);
}
USART4按上述配置后,P10/P11引脚交换, TX发不出信号,RX接收没有问题。如果不配置交换引脚功能,TX是可以发出信号的。想请教这个问题怎么解决 |
|