STM32F101VE6芯片。连接关系,STM32:RTS->DTE:CTS;STM32:CTS<-DTE:RTS
初始化: RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); /* Configure USART2 Rx (PA.03)/CTS(PA.00) as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_0; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Configure USART2 Tx(PA.02)/RTS(PA.01) as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_1; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Configure USART2 */ USART_InitStructure.USART_BaudRate = 19200; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_RTS_CTS; // USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART2, &USART_InitStructure); /* Enable USART2 Receive and Transmit interrupts */ USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); //USART_ITConfig(USART2, USART_IT_TXE, ENABLE); /* Enable the USART2 */ USART_Cmd(USART2, ENABLE); /* Enable the USART2 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQChannel; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure);
结果是STM32:RTS=0;STM32:CTS=0; 而我们的外部模块要求必须有流控制。 接上我们的设备后STM32:RTS=0;STM32:CTS=1;也不知道怎么搞的 |