stm32f10x串口初始化

2019-03-23 19:44发布

void USART1_Init(void){
    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_HardwareFlowControl = USART_HardwareFlowControl_None;  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;  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;
  /* Configure the USART1 */  USART_Init(USART1, &USART_InitStructure);
/* Enable the USART Transmoit interrupt: this interrupt is generated when the    USART1 transmit data register is empty */    USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
/* Enable the USART Receive interrupt: this interrupt is generated when the    USART1 receive data register is not empty */  USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //中断方式接收
  /* Enable USART1 */  USART_Cmd(USART1, ENABLE); }
中断方式操作串口,为什么要把收中断disable?我尝试把它enable,结果设备初始化不成功,哪位大侠给解释下 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
2条回答
robinwei
1楼-- · 2019-03-24 03:36
/ 是发中断
电子机器人
2楼-- · 2019-03-24 09:22
 精彩回答 2  元偷偷看……

一周热门 更多>