In case any one gets here, K22F target must have some timing anomalies, perhaps other targets too.
The timing on the device is constant but different targets and libraries can effect the exact working delay timing.
I have been using Erik's library for some time and does work well other than may require slight timing adjustments.
It is not possible to overcome this by changing the library only address the situation if it arises when the MBED updates.
I have not found any adverse effect with long cables, mine range from 1 to 15 meters and I have had 8 devices connected.
I tweaked the part below (from 10 to 5) and now I can detect and read multiple devices on the same I/O pin. That was on todays MBED-DEV rev. 187.
For STM I would suggest this MBED-DEV revision as it overcomes the everlasting RTC issue:
https://os.mbed.com/users/maxxir/code/mbed-dev/
It does go back to rev. 177 but does work on STM F103, F401, F446, L152, L476 without timing changes, I've tried them. (that F446 is very fast!!)
DS1820.cpp snip
bool DS1820::onewire_bit_in(DigitalInOut *pin) {
bool answer;
ONEWIRE_OUTPUT(pin);
pin->write(0);
ONEWIRE_DELAY_US(3); // DXP modofied from 5
ONEWIRE_INPUT(pin);
ONEWIRE_DELAY_US(10); // DXP modified from 5 >>>>>>> put this back to 5 on K22F <<<<<<<<<<
answer = pin->read();
ONEWIRE_DELAY_US(45); // DXP modified from 50
return answer;
}
Hi,
I can easily run my board with the DS1820_Helloworld example. I am using the parasitic power function, the code finds one device and reports 19.2C this morning. Found 1 device(s) Device 0 returns 19.4oC Device 0 returns 19.4oC Device 0 returns 19.4oC Device 0 returns 19.4oC Device 0 returns 19.4oC Device 0 returns 19.4oC
However, if I upgrade MBED then it fails. I have tried MBED.src and MBED.dev but also just upgrading from within the online compiler, all failed.
The hardware now reports "Found 0 device(s)"
The code jumps from 17k to 26k but finds no devices.