Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
单总线
5
单总线1-Wire里面的us级延时占用cpu时间太长
发布于 2021-09-30 17:28:10 浏览:871
订阅该版
单总线1-Wire里面的us级延时占用cpu时间太长,还不能取消掉,有什么办法能把这段时间释放掉让cpu干其他的事情,我用的stm32H743,480M主频加了这个ds18b20明显降低了效率。 ```c static void ds18b20_reset(rt_base_t pin) { rt_pin_mode(pin, PIN_MODE_OUTPUT); rt_pin_write(pin, PIN_LOW); rt_hw_us_delay(750); /* 480us - 960us */ rt_pin_write(pin, PIN_HIGH); rt_hw_us_delay(25); /* 15us - 60us*/ } static uint8_t ds18b20_read_bit(rt_base_t pin) { uint8_t data; rt_pin_mode(pin, PIN_MODE_OUTPUT); rt_pin_write(pin, PIN_LOW); rt_hw_us_delay(2); rt_pin_write(pin, PIN_HIGH); rt_pin_mode(pin, PIN_MODE_INPUT); /* maybe 12us, maybe 5us, whatever...I have no idea */ rt_hw_us_delay(5); if(rt_pin_read(pin)) data = 1; else data = 0; rt_hw_us_delay(50); return data; } static void ds18b20_write_byte(rt_base_t pin, uint8_t dat) { uint8_t j; uint8_t testb; rt_pin_mode(pin, PIN_MODE_OUTPUT); for (j = 1; j <= 8; j++) { testb = dat & 0x01; dat = dat >> 1; if(testb) { rt_pin_write(pin, PIN_LOW); rt_hw_us_delay(2); rt_pin_write(pin, PIN_HIGH); rt_hw_us_delay(60); } else { rt_pin_write(pin, PIN_LOW); rt_hw_us_delay(60); rt_pin_write(pin, PIN_HIGH); rt_hw_us_delay(2); } } } ```
查看更多
aozima
2021-09-30
调网络不抓包,调I2C等时序不上逻辑分析仪,就像电工不用万用表!多用整理的好的文字,比截图更省流量,还能在整理过程中思考。
这么高主频的芯片,可以尝试用[HWTIMER](https://club.rt-thread.org/ask/tag/1595.html)来做
2
个回答
默认排序
按发布时间排序
cxhxy12345
2021-10-07
这家伙很懒,什么也没写!
你的CPU负担是不是太重了,因为一次数据数据的读取也就最多2~3ms,而且温度的变化是非常缓慢的,你可以按S级周期性的读取温度数据,如果要求不高甚至可以是按分来读取。
撰写答案
登录
注册新账号
关注者
0
被浏览
871
关于作者
LiuYue
这家伙很懒,什么也没写!
提问
1
回答
0
被采纳
0
关注TA
发私信
相关问题
1
关于单总线传感器驱动问题
2
51单片机 IO口作为参数问题
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
机器人操作系统 (ROS2) 和 RT-Thread 通信
4
国产MCU移植系列教程汇总,欢迎查看!
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
rt-thread 挂载romfs与ramfs
2
[Vision Board创客营]使用openmv识别阿尼亚
3
smart启动流程详解
4
小内存管理(1)--- 内存初始化
5
spi自动初始化程序
热门标签
RT-Thread Studio
串口
LWIP
Env
SPI
Bootloader
AT
ART-Pi
Hardfault
CAN总线
FinSH
USB
文件系统
DMA
RT-Thread
SCons
线程
RT-Thread Nano
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
ota在线升级
WIZnet_W5500
I2C_IIC
UART
flash
cubemx
packages_软件包
freemodbus
PWM
潘多拉开发板_Pandora
定时器
ADC
BSP
中断
flashDB
编译报错
socket
keil_MDK
GD32
msh
Debug
SFUD
MicroPython
ulog
SDIO总线
rt_mq_消息队列_msg_queue
本月问答贡献
小小李sunny
3
个答案
3
次被采纳
a1012112796
3
个答案
2
次被采纳
聚散无由
1
个答案
2
次被采纳
用户名由3_15位
4
个答案
1
次被采纳
bernard
2
个答案
1
次被采纳
本月文章贡献
zhuzhuzhu
1
篇文章
4
次点赞
聚散无由
1
篇文章
3
次点赞
Hlafklio
1
篇文章
2
次点赞
YDPB_5935
1
篇文章
2
次点赞
aeniac
1
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部