当前位置:网站首页>HAL_Delay()延时误差约1ms的问题
HAL_Delay()延时误差约1ms的问题
2022-07-24 05:20:00 【喵喵锤锤你小可爱】
问题:
测试端口输出方便用HAL_Delay()发现延时始终存在1ms的偏差,1ms延时是1.99ms,2ms是,如后面的图所示:
http://www.ing10bbs.com/forum.php?mod=viewthread&tid=2317
https://www.shangmayuan.com/a/2b860e61dd114889bc021cdd.html
原因:
扒了一下HAL_Delay()的源码发现这个地方wait多加了一个数值uwTickFreq,这个宏最后对应的数值为1,所以就是多加了一个1。
解决方法是可以重定义HAL_Delay()函数,因为u函数本身是__weak修饰的。
现象


测试代码:
GPIO_InitTypeDef GPIO_InitStruct = {
0};
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_6,1);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(GPIOB,GPIO_PIN_6);
HAL_Delay(1);
}
边栏推荐
- ThreadLocal存储当前登录用户信息
- Sqlserver completely deleted
- 多商户商城系统功能拆解13讲-平台端会员管理
- 多商户商城系统功能拆解12讲-平台端商品评价
- The female colleague of the company asked me to go to her residence to repair the computer at 11 o'clock at night. It turned out that disk C was popular. Look at my move to fix the female colleague's
- [virtualization] how to convert virtual machines from workstation to esxi
- 多商户商城系统功能拆解04讲-平台端商家入驻
- STM32 DSP库MDK VC5\VC6编译错误: 256, (const float64_t *)twiddleCoefF64_256, armBitRevIndexTableF64_256,
- ++cnt1[s1.charAt(i) - ‘a‘];
- "Statistical learning methods (2nd Edition)" Li Hang Chapter 16 principal component analysis PCA mind map notes and after-school exercise answers (detailed steps) PCA matrix singular value Chapter 16
猜你喜欢

labelme转voc代码中的一个小问题

多商户商城系统功能拆解07讲-平台端商品管理

在网络中添加SE通道注意力模块

【深度学习】手写神经网络模型保存

《统计学习方法(第2版)》李航 第十三章 无监督学习概论 思维导图笔记

The way to attack the first poca hackson project "Manta network"

Multi merchant mall system function disassembly lecture 09 - platform end commodity brands

世界坐标系、相机坐标系和图像坐标系的转换

多商户商城系统功能拆解09讲-平台端商品品牌

如何解决训练集和测试集的分布差距过大问题
随机推荐
Are you still trying to limit MySQL paging?
How to quickly connect CRM system and ERP system to realize the automatic flow of business processes
测试数据增强后标签和数据集是否对应
电商系统PC商城模块介绍
likeshop单商户SAAS商城系统无限多开
Numpy array broadcast rule memory method array broadcast broadcast principle broadcast mechanism
Multi merchant mall system function disassembly lecture 04 - platform side merchants settling in
What do programmers often mean by API? What are the API types?
谷歌/火狐浏览器管理后台新增账号时用户名密码自动填入的问题
The female colleague of the company asked me to go to her residence to repair the computer at 11 o'clock at night. It turned out that disk C was popular. Look at my move to fix the female colleague's
Watermelon book / Pumpkin book -- Chapter 1 and 2 Summary
Use streaming media to transfer RSTP to the Web terminal for playback (II) [review]
第五章神经网络
Jupyter notebook选择conda环境
"Statistical learning methods (2nd Edition)" Li Hang Chapter 16 principal component analysis PCA mind map notes and after-school exercise answers (detailed steps) PCA matrix singular value Chapter 16
第四章 决策树总结
Mysqldump export Chinese garbled code
Official account development custom menu and server configuration are enabled at the same time
systemctl + journalctl
Test whether the label and data set correspond after data enhancement