硬汉嵌入式论坛

 找回密码
 立即注册
查看: 4137|回复: 9
收起左侧

[CMSIS-RTOS] cmsis-rtos下实现ds18b20困难,哪位大神指点一下?

[复制链接]

1

主题

2

回帖

1

积分

新手上路

积分
1
发表于 2017-2-11 21:26:18 | 显示全部楼层 |阅读模式
在cmsis-rtos环境下初始化ds18b20失败,哪位大神有办法,请赐教!
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106749
QQ
发表于 2017-2-12 09:40:55 | 显示全部楼层
ds18b20对时序的要求比较严格,在rtos启动前先做外设的初始化,在任务中读取温度值时,务必要做开关中断保护。
回复

使用道具 举报

1

主题

2

回帖

1

积分

新手上路

积分
1
 楼主| 发表于 2017-2-12 20:59:02 | 显示全部楼层
嗯先试试
在线程中读取数据时 有没啥注意的地方 或者技巧?
谢了!
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106749
QQ
发表于 2017-2-13 09:11:44 | 显示全部楼层

回 zh020506 的帖子

zh020506:嗯先试试
在线程中读取数据时 有没啥注意的地方 或者技巧?
谢了! (2017-02-12 20:59) 
做好开关中断保护,切不可被任何其它任务打断,18B20就是这个样子的。
回复

使用道具 举报

1

主题

2

回帖

1

积分

新手上路

积分
1
 楼主| 发表于 2017-2-13 21:41:02 | 显示全部楼层

回 eric2013 的帖子

eric2013:做好开关中断保护,切不可被任何其它任务打断,18B20就是这个样子的。 (2017-02-13 09:11) 
初始化已解决,读取时数据波动的厉害 可否简单的关闭中断,读取后再打开中断 来解决?
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106749
QQ
发表于 2017-2-15 00:27:35 | 显示全部楼层

回 zh020506 的帖子

zh020506:初始化已解决,读取时数据波动的厉害 可否简单的关闭中断,读取后再打开中断 来解决? (2017-02-13 21:41) 
可以的,另外就是最好1-2秒更新一次即可。
回复

使用道具 举报

73

主题

1193

回帖

1412

积分

至尊会员

积分
1412
发表于 2020-1-9 11:15:03 | 显示全部楼层
eric2013 发表于 2017-2-15 00:27
可以的,另外就是最好1-2秒更新一次即可。

请问硬汉哥,ds18b20的引脚设置为开漏输出,是吗?
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106749
QQ
发表于 2020-1-9 11:39:54 | 显示全部楼层
wdliming 发表于 2020-1-9 11:15
请问硬汉哥,ds18b20的引脚设置为开漏输出,是吗?

开漏OD
回复

使用道具 举报

73

主题

1193

回帖

1412

积分

至尊会员

积分
1412
发表于 2020-1-9 11:55:51

好的谢谢,程序上看到了

210

主题

1043

回帖

1683

积分

至尊会员

More we do, more we can do.

积分
1683
发表于 2020-3-26 12:26:24 | 显示全部楼层
搜了下相关讨论,这个比较全面:
The easiest way to get the right timing for 1wire is to use a UART.  If you set the baud just right, you can use 0x01 (or 0x80 depending on endian) and 0xff for short and long pulses, and set it up for half duplex so you can read the byte back to see if the device held a '1' for you.  A single schottky diode from TxD to the 1wire bus should be sufficient, plus the pull-up.

Otherwise, you have a few choices...

* Use a separate 1wire driver chip that talks SPI or I2C and hook it up to the existing busses.

* Disable interrupts and use a fixed timing loop for each pulse.

* Use a separate timer and do all the 1wire logic in its interrupt handler (i.e. outside the realm of the RTOS tasks)

* Use a separate chip like an R8C just to do the timing.

My furnace controller uses an R8C for each zone, and those R8Cs use a timer/interrupt to do the 1wire timing.  The 1wire search/scan logic is done in the main loop, and the results are passed back to the main MCU via I2c.
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106749
QQ
发表于 2020-3-26 12:58:21 | 显示全部楼层
emwin 发表于 2020-3-26 12:26
搜了下相关讨论,这个比较全面:

这个最早是来自美信
https://www.maximintegrated.com/ ... utorials/2/214.html

这个网友进行了实现:
https://stm32f4-discovery.net/2018/04/1-wire-uart/
回复

使用道具 举报

0

主题

0

回帖

0

积分

新手上路

积分
0
发表于 2020-7-8 23:03:28

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-4 05:25 , Processed in 0.284210 second(s), 31 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表