当前位置:网站首页>STM32 problem collection
STM32 problem collection
2022-07-31 03:02:00 【yyhnet.cn】
KeilDownloader crashes
删除当前目录下的.uvoptx
后缀文件,Just reconfigure the magic wand
HALThe library serial port interrupt is not called
STM32采用HAL库HAL_UART_Receive_IT()
只调用一次,The first thing to do is to enable global interrupts,Then make sure to call it after the serial port initialization is completeHAL_UART_Receive_IT()
确定返回HAL_OK
,Then add it to the receive interrupt callback function,And make sure the received byte length is 1,因为采用HAL库,Receive serial port in interrupt mode,只有当RxXferCount == 0 时,也就是调用这个函数,When receiving the specified amount of data size is complete,才会调用回调函数HAL_UART_RxCpltCallback().所以紧接着,In the serial port interrupt service function,又调用了一次,继续接收,This will not cause the specified data frame length to be received and will not enter the interrupt.
uint8_t uart1_rxbuf[10];
uint8_t uart2_rxbuf[10];
if(HAL_UART_Receive_IT(&huart1, uart1_rxbuf, 1)==HAL_OK)
{
HAL_UART_Transmit(&huart1, (uint8_t *)"ok", 2,0xffff);
}
if(HAL_UART_Receive_IT(&huart2, uart2_rxbuf, 1)==HAL_OK)
{
HAL_UART_Transmit(&huart2, (uint8_t *)"ok", 2,0xffff);
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if(huart->Instance == USART1)
{
HAL_UART_Transmit(&huart2, uart1_rxbuf, 1,0xffff); // 把收到的字节原样发送出去
HAL_UART_Receive_IT(&huart1, uart1_rxbuf, 1); // 重新注册一次,Otherwise, you won't receive it next time
}
if(huart->Instance == USART2)
{
HAL_UART_Transmit(&huart1, uart2_rxbuf, 1,0xffff);
HAL_UART_Receive_IT(&huart2, uart2_rxbuf, 1);
}
}
边栏推荐
猜你喜欢
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
关于 mysql8.0数据库中主键位id,使用replace插入id为0时,实际id插入后自增导致数据重复插入 的解决方法
知识蒸馏7:知识蒸馏代码详解
JS function this context runtime syntax parentheses array IIFE timer delay self.backup context call apply
什么是系统?
Getting Started with CefSharp - winform
10、Redis实现点赞(Set)和获取总点赞数
Office automation case: how to automatically generate period data?
软件积累 -- 截图软件ScreenToGif
SQL injection Less46 (injection after order by + rand() Boolean blind injection)
随机推荐
Difference between CMOS and TTL?
CorelDRAW2022精简亚太新增功能详细介绍
Is interprofessional examination difficult?Low success rate of "going ashore"?Please accept this practical guide!
CloudCompare&PCL 计算两个点云之间的重叠度
局域网电脑硬件信息收集工具
多线程下类对象的服务承诺探讨
Go 项目实战-获取多级分类下的全部商品
CefSharp入门-winform
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
知识蒸馏7:知识蒸馏代码详解
mycat的主从关系 垂直分库 水平分表 以及mycat分片联表查询的配置详解(mysql5.7系列)
SQL 面试用题(重点)
【C语言】求两个整数m和n的最大公因数和最小公倍数之和一般方法,经典解法
Clustering index, and what is the difference between a clustering index
6、显示评论和回复
PMP微信群日常习题
SQALE 是什么
Moxa NPort 设备缺陷可能使关键基础设施遭受破坏性攻击
What is distributed and clustered?What is the difference?
Chapter 9 SVM Practice