DS18x20_Temperature module

The TeensyDuino One Wire library website contains this description:

The DS18x20_Temperature does not properly handle lower resolution (faster) modes on some chips. Thanks to Pete Hardie for this fix. Replace this:

  } else {

byte cfg = (data[4] & 0x60);
    if (cfg == 0x00) raw = raw << 3;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw << 2; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw << 1; // 11 bit res, 375 ms
    // default is 12 bit resolution, 750 ms conversion time
  }




With this:



} else {
    unsigned char t_mask[4] = {0x7, 0x3, 0x1, 0x0};
    byte cfg = (data[4] & 0x60) >> 5;
    raw &= ~t_mask[cfg];
  }

I would like to know: is the following code equivalent? Would it be more performant since it has no addressing operations?

raw &= ~0 << (3 – ((data[4] >> 5) & 3));

Does anyone have an applicable DS18x20_Temperature device to check this?

Thanks!

I would like to know: is the following code equivalent?

It looks like it is.

Would it be more performant since it has no addressing operations?

What's the rush? The DS18B20 takes nearly 100 milliseconds to do a 9-bit conversion, so shaving off a few microseconds isn't going to make any difference.

Pete

Certainly a conversion could be done before the temperature lag of the device would come into play... and be either displayed or used... AN LCD takes longer than that and relays usually have 40 to 100 ms pull in time. I shudder at coding a PID loop around the latency of a DS18B20. Perhaps for serial comm but again what of the response time?

Doc

From the sounds of it you're right that speed isn't an important factor here. I was more curious than anything. Anyway, thanks.