当前位置:网站首页>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);
}
}
边栏推荐
- try-catch中含return
- YOLOV5学习笔记(三)——网络模块详解
- LeetCode简单题之找到和最大的长度为 K 的子序列
- 跨专业考研难度大?“上岸”成功率低?这份实用攻略请收下!
- execsnoop tool
- C primer plus学习笔记 —— 8、结构体
- JetPack component Databinding
- TCP详解(二)
- 8. Unified exception handling (controller notifies @ControllerAdvice global configuration class, @ExceptionHandler handles exceptions uniformly)
- Mysql 45讲学习笔记(二十三)MYSQL怎么保证数据不丢
猜你喜欢
随机推荐
分布式与集群是什么 ? 区别是什么?
解析小结—自用
7. List of private messages
遗留系统的自动化策略
TCP/IP four-layer model
Compile Hudi
接口测试关键技术
CloudCompare&PCL 计算两个点云之间的重叠度
Getting Started with CefSharp - winform
Modbus on AT32 MCU
观察者模式
JS function this context runtime syntax parentheses array IIFE timer delay self.backup context call apply
Uninstallation of mysql5.7.37 under CentOS7 [perfect solution]
Moxa NPort 设备缺陷可能使关键基础设施遭受破坏性攻击
华为分布式存储FusionStorage知识点总结【面试篇】
【编译原理】递归下降语法分析设计原理与实现
公司官网建站笔记(六):域名进行公安备案并将备案号显示在网页底部
TCP详解(一)
Graphical lower_bound & upper_bound
6、显示评论和回复