当前位置:网站首页>空闲中断无法清除
空闲中断无法清除
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);
}
}
边栏推荐
- apache、iis6、ii7独立ip主机屏蔽拦截蜘蛛抓取(适用vps云主机服务器)
- [today in history] June 16: Oracle Bone Inscriptions was established; Microsoft MSX was born; The inventor of fast Fourier transform was born
- Simple elk configuration to realize production level log collection and query practice
- > Could not create task ‘:app:MyTest.main()‘. > SourceSet with name ‘main‘ not found.问题修复
- [today in history] June 24: Netease was established; The first consumer electronics exhibition was held; The first webcast in the world
- 横向滚动的RecycleView一屏显示五个半,低于五个平均分布
- [522. longest special sequence II]
- [today in history] June 8: the father of the world wide web was born; PHP public release; IPhone 4 comes out
- 多快好省,低门槛AI部署工具FastDeploy测试版来了!
- adb双击POWER键指令
猜你喜欢

Thesis reading: General advantageous transformers

Intel Ruixuan A380 graphics card will be launched in China

Raspberry pie - environment settings and cross compilation
![[today in history] June 16: Oracle Bone Inscriptions was established; Microsoft MSX was born; The inventor of fast Fourier transform was born](/img/4f/67e1598b523058a8fb6f3148136902.png)
[today in history] June 16: Oracle Bone Inscriptions was established; Microsoft MSX was born; The inventor of fast Fourier transform was born

Get 5 offers after being notified of layoffs
![[today in history] June 25: the father of notebook was born; Windows 98 release; First commercial use of generic product code](/img/ef/a26127284fe57ac049a4313d89cf97.png)
[today in history] June 25: the father of notebook was born; Windows 98 release; First commercial use of generic product code

访问网站提示:您未被授权查看该页恢复办法

【插件-statistic】统计代码行数和相关数据

您的物联网安全性是否足够强大?

2021年软件测试工具总结——模糊测试工具
随机推荐
Gateway微服务路由使微服务静态资源加载失败
一位博士在华为的22年(干货满满)
Usage details of staticlayout
面试:List 如何根据对象的属性去重?
Flask Foundation: template inheritance + static file configuration
ADB double click the power key command
MFC CString to LPVOID
Packet capturing and sorting out external Fiddler -- understanding the toolbar [1]
[issue 21] face to face experience of golang engineer recruited by Zhihu Society
RichView TRVStyle TextStyles
Why are so many people keen on big factories because of the great pressure and competition?
AgilePLM异常解决-Session篇
[today in history] June 19: iPhone 3GS launched; Pascal was born; Anti terrorist elite begins testing
微信小程序中生成二维码
【插件-statistic】统计代码行数和相关数据
抓包整理外篇fiddler————了解工具栏[一]
嵌入式DSP音频开发
Heartless sword English Chinese bilingual poem 004 Meditation
Reading makes people quiet
RichView TRVStyle TextStyles