1wire/onewire/ow and "no power" mode
Posted: Sat Oct 03, 2015 11:11 pm
I'm trying to get a DS18B20 temp sensor working. Or rather, I have got it working with some workarounds. First, the 20150704 firmware has an error in onewire_search
Next, onewire_select() and onewire_skip() call onewire_write with the 3rd argument (power) set to zero, i.e.
I noticed on my logic analyser, the output pin goes low at this point, which I believe it should not do. I believe the intent is for the pin to be tri-stated (high impedance) and the external resistor pulls up the pin to 3v3.
Looking at the code for onewire_write() ...
There seems to be a problem here. DIRECT_MODE_INPUT is defined as
When I worked around the problem by calling onewire_write() myself with power = 1, the pin output anomaly vanished and my temp sensor worked.
Next, onewire_select() and onewire_skip() call onewire_write with the 3rd argument (power) set to zero, i.e.
Code: Select all
void onewire_skip(uint8_t pin)
{
onewire_write(pin, 0xCC, 0); // Skip ROM
}
I noticed on my logic analyser, the output pin goes low at this point, which I believe it should not do. I believe the intent is for the pin to be tri-stated (high impedance) and the external resistor pulls up the pin to 3v3.
Looking at the code for onewire_write() ...
Code: Select all
if ( !power) {
noInterrupts();
DIRECT_MODE_INPUT(pin);
DIRECT_WRITE_LOW(pin);
interrupts();
}
There seems to be a problem here. DIRECT_MODE_INPUT is defined as
Code: Select all
which disables output for the pin. But DIRECT_WRITE_LOW calls GPIO_OUTPUT_SET which re-enables output!GPIO_DIS_OUTPUT(pin_num[pin])
When I worked around the problem by calling onewire_write() myself with power = 1, the pin output anomaly vanished and my temp sensor worked.