STM32高手过来帮小弟看哈

2019-03-23 20:04发布

void USART_Configuration()
{
 USART_InitTypeDef USART_InitStructure;
 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_Mode=USART_Mode_Rx|USART_Mode_Tx;
 USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;
 USART_InitStructure.USART_Clock=USART_Clock_Disable;
 USART_InitStructure.USART_CPOL=USART_CPOL_Low;
 USART_InitStructure.USART_CPHA=USART_CPHA_2Edge;
 USART_InitStructure.USART_LastBit=USART_LastBit_Disable;
 USART_Init(USART1,&USART_InitStructure);
 USART_Cmd(USART1,ENABLE);
}
[ 本帖最后由 TopMars 于 2011-8-12 15:04 编辑 ] 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
9条回答
0900820417
2019-03-25 04:49

void USART_Configuration(void)//串口初始化

{ USART_InitTypeDef USART_InitStructure; //定义USART_InitTypeDef的结构体变量USART_InitStructure USART_ClockInitTypeDef USART_ClockInitStructure;//

USART_ClockInitStructure.USART_Clock = USART_Clock_Disable;// 时钟低电平活动 USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low; // 时钟输出极性为低电平 USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge; // 时钟的第二个时钟沿进行数据捕获 USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable;//最后一位时钟脉冲不从SCLK输出

USART_ClockInit(USART1, &USART_ClockInitStructure);// USART_InitStructure.USART_BaudRate = 115200;//设置波特率为115200 USART_InitStructure.USART_WordLength = USART_WordLength_8b;//设置数据位宽为8为 USART_InitStructure.USART_StopBits = USART_StopBits_1;//停止位为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;//设置为发射和接收模式

 USART_Init(USART1, &USART_InitStructure);//初始化串口

 USART_Cmd(USART1, ENABLE);//使能串口

[ 本帖最后由 0900820417 于 2012-3-21 19:44 编辑 ]

一周热门 更多>