yes it was a misunderstanding.
Our example is made without configuring the 18B20 sensor resolution.
Sensor resolution is set to default (12bit in case of 18B20).
TEMP_RESOLUTION constant is introduced for switching between the different sensors (1820, 18S20, 18B20...).
You misunderstood this constant and you treated is as a constant for
configuring 12bit sensor 18B20 measuring resolution.
We were talking about different things
and there is no bug in the example.
One tip:
If you want to form CONF_WORD value, you don't need case
Code: Select all
switch (TEMP_RESOLUTION)
{
case 9 : CONF_WORD = 0b00011111 ; break;
case 10: CONF_WORD = 0b00111111 ; break;
case 11: CONF_WORD = 0b01011111 ; break;
case 12: CONF_WORD = 0b01111111 ; break;
}
Code: Select all
CONF_WORD = ((TEMP_RESOLUTION - 9) << 5) | 0b00011111;
Try to organize your code in functions and avoid GOTOs in C.
(If you are migrating from Basic to C this could be hard, but it is worth trying )
If you have some other question in the future feel free to ask on forum, mE team and other users will be happy to help you
(Try to avoid to name topic "Example bugs" if you aren't 100% sure in that statement, as we saw - there is no bug in this example)