当前位置:网站首页>空闲中断无法清除
空闲中断无法清除
2022-06-28 01:47:00 【双古】
调试环境
单片机型号:stm32F103RCT6
异常代码如下。使用串口助手发送一个字节时,一直进入空闲中断,且无法清除空闲中断标志位。
void USART2_IRQHandler(void)
{
if (UART_GET_FLAG(USART2, UART_FLAG_RXNE) != RESET)
{
fifoUart2.buf[fifoUart2.rcvCnt++] = USART2->DR;
UART_CLEAR_FLAG(USART2, UART_FLAG_RXNE);
}
if (UART_GET_FLAG(USART2, UART_FLAG_IDLE) != RESET)
{
fifoUart2.parseFlag = RT_TRUE;
UART_CLEAR_FLAG(USART2, UART_FLAG_IDLE);
rt_event_send(rcvEvent, RCV_EVENT_UART2);
}
}
解决方式
清除空闲终端标志前,再读取一次DR寄存器的值。从手册对于空闲中断寄存器这一位的描述也没看出原理。
void USART2_IRQHandler(void)
{
uint32_t dr = 0;
if (UART_GET_FLAG(USART2, UART_FLAG_RXNE) != RESET)
{
fifoUart2.buf[fifoUart2.rcvCnt++] = USART2->DR;
UART_CLEAR_FLAG(USART2, UART_FLAG_RXNE);
}
if (UART_GET_FLAG(USART2, UART_FLAG_IDLE) != RESET)
{
dr = USART2->DR;
fifoUart2.parseFlag = RT_TRUE;
UART_CLEAR_FLAG(USART2, UART_FLAG_IDLE);
rt_event_send(rcvEvent, RCV_EVENT_UART2);
}
}
边栏推荐
- Online text batch inversion by line tool
- You got 8K in the 3-year function test, but were overtaken by the new tester. In fact, you are pretending to work hard
- 2-5 basic configuration -win2003 add attack surface
- [today in history] June 10: Apple II came out; Microsoft acquires gecad; The scientific and technological pioneer who invented the word "software engineering" was born
- Get 5 offers after being notified of layoffs
- 音视频技术开发周刊 | 251
- A16z:元宇宙解锁游戏基础设施中的新机遇
- Opencv -- geometric space transformation (affine transformation and projection transformation)
- Publicity of the third batch of shortlisted enterprises! Annual Top100 smart network supplier selection
- 第一次使用gcc和makefile编写c程序
猜你喜欢
![[today in history] June 5: Lovelace and Babbage met; The pioneer of public key cryptography was born; Functional language design pioneer born](/img/af/1faf1df4262940e73104ed2880f08d.png)
[today in history] June 5: Lovelace and Babbage met; The pioneer of public key cryptography was born; Functional language design pioneer born

math_(函数&数列)极限的含义&误区和符号梳理/邻域&去心邻域&邻域半径

math_ (function & sequence) meaning of limit & misunderstanding and symbol sorting / neighborhood & de centring neighborhood & neighborhood radius

【Kotlin】在Android官方文档中对其语法的基本介绍和理解

ByteDance Interviewer: how to calculate the memory size occupied by a picture

Simple file transfer protocol TFTP
![[today in history] June 17: the creator of the term](/img/00/30ccc2f54415a6aca000c42e277dc3.png)
[today in history] June 17: the creator of the term "hypertext" was born; The birth of Novell's chief scientist; Discovery channel on
![[today in history] June 7: kubernetes open source version was released; Worldofwarcraft landed in China; Birth of the inventor of packet switching network](/img/70/6864b41e17502ec391db23ae83bd4b.png)
[today in history] June 7: kubernetes open source version was released; Worldofwarcraft landed in China; Birth of the inventor of packet switching network

How to run unity webgl after packaging (Firefox configuration)

【iptables&icmp】iptables默认策略中关于icmp协议的说明
随机推荐
How to run unity webgl after packaging (Firefox configuration)
Gateway microservice routing failed to load microservice static resources
嵌入式DSP音频开发
TensorRT 模型推理优化实现
暴雨去哪儿?天气预报不准谁的锅?
Feign远程调用fallback回调失败,无效果
抓包整理外篇fiddler————了解工具栏[一]
如何编写简洁代码?(上)
Reading makes people quiet
[today in history] June 16: Oracle Bone Inscriptions was established; Microsoft MSX was born; The inventor of fast Fourier transform was born
Online JSON to plaintext tool
Flask Foundation: template inheritance + static file configuration
在线文本按行批量反转工具
CMU提出NLP新范式—重构预训练,高考英语交出134高分
A16z:元宇宙解锁游戏基础设施中的新机遇
[today in history] June 19: iPhone 3GS launched; Pascal was born; Anti terrorist elite begins testing
[today in history] June 11: the co inventor of Monte Carlo method was born; Google launched Google Earth; Google acquires waze
云成本优化有哪些优秀实践?
[issue 21] face to face experience of golang engineer recruited by Zhihu Society
Mysql database operation - stored procedure, view, transaction, index, database backup