OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3333|回复: 0

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

[复制链接]

1

主题

1

帖子

0

精华

新手入门

积分
24
金钱
24
注册时间
2015-9-8
在线时间
1 小时
发表于 2016-9-7 14:32:08 | 显示全部楼层 |阅读模式
1金钱
STM32F207开发板无法通过串口硬件流控制方式和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_ClockStructInit(&USART_ClockInitStruct);
       //PA9: USART1_TX                 PA10 :USART1_RX            PA11:USART1_CTS            PA12:USART1_RTS
        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_PP;
        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);
}



正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-5-25 18:58

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表