Maxim DS2482 1-wire master library, slow read


i have found ds2482 library posted sivu (see http://www.arduino.cc/cgi-bin/yabb2/yabb.pl?num=1242137666/4)  extremely useful going quickly.

unfortunately ran across bug in wirereadbyte. existing code is:

code: [select]
uint8_t ds2482::wirereadbyte()
{
busywait(true);
begin();
wire.send(0x96);
end();
busywait();
setreadptr(ptr_read);
busywait();
return readbyte();
}


the problem occurs last 3 lines above: after setting read pointer read data register, busywait starts poll , wait until device not busy. busywait expecting read status register gets data register instead. if lsb of data 1 concludes device busy , times out waiting. after timeout last line correctly reads data.

the impact silent because timeout not reported, takes time (about 250ms default settings on duemilanove). occurs half time if data random. reading 9 bytes ds18s20 temperature sensor translates 1s read data, slow.

as far can see reading ds2482 data sheet there no need wait device ready @ point, busywait can eliminated in corrected code:

code: [select]
uint8_t ds2482::wirereadbyte()
{
busywait(true);
begin();
wire.send(0x96);
end();
busywait();
setreadptr(ptr_read);
return readbyte();
}


in case takes 19ms read 9 bytes temperature sensor  :).

why using 2 wire library when mention 1-wire devices?


Arduino Forum > Forum 2005-2010 (read only) > Software > Development > Maxim DS2482 1-wire master library, slow read


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums