返回首页
当前位置: 主页 > 操作系统 > Linux教程 >

STM32 串口无法进入中断

时间:2015-05-08 23:42来源:电脑教程学习网 www.etwiki.cn 编辑:admin

串口配置程序如下,NVIC已经正确配置,GPIO也正确配置,
但是还是始终无法进入串口接收中断。

USART_InitTypeDef USART_InitStructure;
USART_ClockInitTypeDef USART_ClockInitStructure;
/* USART1 configuration ----------------------------------------------- -------*/
/* USART1 configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled (RTS and CTS signals)
- Receive and transmit enabled
- USART Clock disabled
- USART CPOL: Clock is active low
- USART CPHA: Data is captured on the middle
- USART LastBit: The clock pulse of the last data bit is not


output to
the SCLK pin
*/
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;
/* Configure the USART1 synchronous paramters */
USART_ClockInit(USARTx, &USART_ClockInitStructure);
USART_InitStructure.USART_BaudRate = bound;//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;
/* Configure USART1 basic and asynchronous paramters */
USART_Init(USARTx, &USART_InitStructure);
/* Enable USART1 Receive and Transmit interrupts */
USART_ITConfig(USARTx, USART_IT_RXNE, ENABLE);
USART_ITConfig(USARTx, USART_IT_TXE, ENABLE);
/* Enable USART1 */
USART_Cmd(USARTx, ENABLE);


经查,注掉串口发送中断使能就可以了。
//USART_ITConfig(USARTx, USART_IT_TXE, ENABLE);


应该是二者不能同时使能吧。

------分隔线----------------------------
标签(Tag):Linux Android Ubuntu Unix 操作系统 fedora debian
------分隔线----------------------------
推荐内容
猜你感兴趣