zh020506 发表于 2017-2-11 21:26:18

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

在cmsis-rtos环境下初始化ds18b20失败,哪位大神有办法,请赐教!

eric2013 发表于 2017-2-12 09:40:55

ds18b20对时序的要求比较严格,在rtos启动前先做外设的初始化,在任务中读取温度值时,务必要做开关中断保护。

zh020506 发表于 2017-2-12 20:59:02

嗯先试试
在线程中读取数据时 有没啥注意的地方 或者技巧?
谢了!

eric2013 发表于 2017-2-13 09:11:44

回 zh020506 的帖子

zh020506:嗯先试试
在线程中读取数据时 有没啥注意的地方 或者技巧?
谢了! (2017-02-12 20:59) images/back.gif

做好开关中断保护,切不可被任何其它任务打断,18B20就是这个样子的。

zh020506 发表于 2017-2-13 21:41:02

回 eric2013 的帖子

eric2013:做好开关中断保护,切不可被任何其它任务打断,18B20就是这个样子的。 (2017-02-13 09:11) images/back.gif

初始化已解决,读取时数据波动的厉害 可否简单的关闭中断,读取后再打开中断 来解决?

eric2013 发表于 2017-2-15 00:27:35

回 zh020506 的帖子

zh020506:初始化已解决,读取时数据波动的厉害 可否简单的关闭中断,读取后再打开中断 来解决? (2017-02-13 21:41) images/back.gif

可以的,另外就是最好1-2秒更新一次即可。

wdliming 发表于 2020-1-9 11:15:03

eric2013 发表于 2017-2-15 00:27
可以的,另外就是最好1-2秒更新一次即可。

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

eric2013 发表于 2020-1-9 11:39:54

wdliming 发表于 2020-1-9 11:15
请问硬汉哥,ds18b20的引脚设置为开漏输出,是吗?

开漏OD

wdliming 发表于 2020-1-9 11:55:51

eric2013 发表于 2020-1-9 11:39
开漏OD

好的谢谢,程序上看到了

emwin 发表于 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.

eric2013 发表于 2020-3-26 12:58:21

emwin 发表于 2020-3-26 12:26
搜了下相关讨论,这个比较全面:

这个最早是来自美信
https://www.maximintegrated.com/en/design/technical-documents/tutorials/2/214.html

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

xunmengv88 发表于 2020-7-8 23:03:28

冯矿伟MACD精华视频全集 https://www.youxuan68.com/jiangzuo/144368.html
页: [1]
查看完整版本: cmsis-rtos下实现ds18b20困难,哪位大神指点一下?