Mbed OS 6.1+ bug?

Hello Alain,

In case of one-wire the most critical thing is to meet the read time slot constrains.


First, the GPIO shall be pulled down for at least 1us. That’s easy to achieve by having the GPIO configured as ouput and writing a 0 to it.
Then the GPIO has to be reconfigured from output to input. This will release the bus and let the DS1820 either keep it down (indicated as Master read “0” slot in the picture above) or pull the bus up (indicated as Master read “1” slot in the picture above). The read operation (indicated as ‘Master samples’ in the picture above) shall be accomplished as close to the end of a 15 us time frame as possible. Unfortunately, on some ARM targets the GPIO transition from output to input takes quite a long time. When it exceeds 15 us it could render the given MCU unusable for the one-wire bus. However, my experience is that some DS1820 sensors are able to operate at sample point beyond the 15 us time frame.

To improve the library the transition time from output to input of the selected GPIO is now measured in the constructor. If it exceeds the sample point (defaults to 13 us) a runtime error is reported. For example:

++ MbedOS Error Info ++
Error Status: 0x80FF0144 Code: 324 Module: 255
Error Message: Assertion failed: _out_to_in_transition_us < _sample_point_us
...

It is now also possible to modify the sample point (defaults to 13 us) by passing a second parameter in the OneWire constructor:

OneWire  oneWire(D8, 15);  // sample point set to 15 us

or in the DS1820 constructor:

DS1820  ds1820(D8, 15);  // sample point set to 15 us

Best regards, Zoltan