xufengww 2016-09-07 06:41 采纳率: 0%
浏览 2865

如何在STM32F207中实现串口硬件流控制

在STM32中采用硬件流控制RTS/CTS时,没有办法和PC的串口调试助手进行通信,而不采用流控制就可以正常通信。
其中串口初始化代码为:
void USART_Configuration(void)
{

GPIO_InitTypeDef GPIO_InitStructure;

USART_InitTypeDef USART_InitStructure;
USART_ClockInitTypeDef USART_ClockInitStruct;

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOD, ENABLE);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);

USART_DeInit(USART1);

USART_StructInit(&USART_InitStructure);//ÔØÈëĬÈÏUSART²ÎÊý
USART_ClockStructInit(&USART_ClockInitStruct);//ÔØÈëĬÈÏUSART²ÎÊý  

// PA9:USART1_TX           PA10:USART1_RX      PA11:USART1_CTS    PA12:USART1_RST  
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; 
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_USART1);     

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;        
GPIO_Init(GPIOA, &GPIO_InitStructure);                                                                                                                 
GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_USART1);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;        
GPIO_Init(GPIOA, &GPIO_InitStructure);                                                                                                                 
GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_USART1);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;  
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; 
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);                                                                                                                 
GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_USART1);

USART_ClockInit(USART1,&USART_ClockInitStruct);


USART_InitStructure.USART_BaudRate = 115200;
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(USART1,&USART_InitStructure); 

USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);    
USART_ClearITPendingBit(USART1, USART_IT_TC);
USART_Cmd(USART1,ENABLE);

}

  • 写回答

1条回答 默认 最新

  • Cincinnati_De 2016-09-07 12:10
    关注

    你的问题很深奥,可以多看看API嘛,嘻嘻

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料