新手,第一次自己搭建开发环境,碰到了问题,希望能人帮忙解决一下。
问题描述:
从ST官网下载的207的串口的历程库
板子有4个485口。
USART4的TX 和RX映射到PC10 PC11上,定义如下:
#define EVAL_COM1 UART4
#define EVAL_COM1_CLK RCC_APB1Periph_UART4
#define EVAL_COM1_TX_PIN GPIO_Pin_10
#define EVAL_COM1_TX_GPIO_PORT GPIOC
#define EVAL_COM1_TX_GPIO_CLK RCC_AHB1Periph_GPIOC
#define EVAL_COM1_TX_SOURCE GPIO_PinSource10
#define EVAL_COM1_TX_AF GPIO_AF_UART4
#define EVAL_COM1_RX_PIN GPIO_Pin_11
#define EVAL_COM1_RX_GPIO_PORT GPIOC
#define EVAL_COM1_RX_GPIO_CLK RCC_AHB1Periph_GPIOC
#define EVAL_COM1_RX_SOURCE GPIO_PinSource11
#define EVAL_COM1_RX_AF GPIO_AF_UART4
#define EVAL_COM1_IRQn UART4_IRQn
这个口一切正常,受发均可
但是一下定义的口都不能用:
#define EVAL_COM2 USART3
#define EVAL_COM2_CLK RCC_APB1Periph_USART3
#define EVAL_COM2_TX_PIN GPIO_Pin_10
#define EVAL_COM2_TX_GPIO_PORT GPIOB
#define EVAL_COM2_TX_GPIO_CLK RCC_AHB1Periph_GPIOB
#define EVAL_COM2_TX_SOURCE GPIO_PinSource10
#define EVAL_COM2_TX_AF GPIO_AF_USART3
#define EVAL_COM2_RX_PIN GPIO_Pin_11
#define EVAL_COM2_RX_GPIO_PORT GPIOB
#define EVAL_COM2_RX_GPIO_CLK RCC_AHB1Periph_GPIOB
#define EVAL_COM2_RX_SOURCE GPIO_PinSource11
#define EVAL_COM2_RX_AF GPIO_AF_USART3
#define EVAL_COM2_IRQn USART3_IRQn
#define EVAL_COM3 UART5
#define EVAL_COM3_CLK RCC_APB1Periph_UART5
#define EVAL_COM3_TX_PIN GPIO_Pin_12
#define EVAL_COM3_TX_GPIO_PORT GPIOC
#define EVAL_COM3_TX_GPIO_CLK RCC_AHB1Periph_GPIOC
#define EVAL_COM3_TX_SOURCE GPIO_PinSource12
#define EVAL_COM3_TX_AF GPIO_AF_UART5
#define EVAL_COM3_RX_PIN GPIO_Pin_2
#define EVAL_COM3_RX_GPIO_PORT GPIOD
#define EVAL_COM3_RX_GPIO_CLK RCC_AHB1Periph_GPIOD
#define EVAL_COM3_RX_SOURCE GPIO_PinSource2
#define EVAL_COM3_RX_AF GPIO_AF_UART5
#define EVAL_COM3_IRQn UART5_IRQn
#define EVAL_COM4 USART6
#define EVAL_COM4_CLK RCC_APB2Periph_USART6
#define EVAL_COM4_TX_PIN GPIO_Pin_6
#define EVAL_COM4_TX_GPIO_PORT GPIOC
#define EVAL_COM4_TX_GPIO_CLK RCC_AHB1Periph_GPIOC
#define EVAL_COM4_TX_SOURCE GPIO_PinSource6
#define EVAL_COM4_TX_AF GPIO_AF_USART6
#define EVAL_COM4_RX_PIN GPIO_Pin_7
#define EVAL_COM4_RX_GPIO_PORT GPIOC
#define EVAL_COM4_RX_GPIO_CLK RCC_AHB1Periph_GPIOC
#define EVAL_COM4_RX_SOURCE GPIO_PinSource7
#define EVAL_COM4_RX_AF GPIO_AF_USART6
#define EVAL_COM4_IRQn USART6_IRQn
串口已经初始化:
USART_InitStructure.USART_BaudRate = 1200;
USART_InitStructure.USART_WordLength = USART_WordLength_9b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
STM_EVAL_COMInit(COM1, &USART_InitStructure);
COM1,COM2,COM3,COM4都是如法**制
EVAL_COM1的通信正常,其余三个都不行
调试的时候发现在函数
void SerialPutChar(uint8_t c)
{
USART_SendData(EVAL_COM2, c);
while (USART_GetFlagStatus(EVAL_COM2, USART_FLAG_TXE) == RESET)
{
}
}
中的while上死循环了。
请教怎么回事
新手,分数不多,拜托各位高手 |