Gast
#738249
Hallo, ich versuche ein Projekt mit dem DS18B20 zu bauen. Ich benutze die files von Peter Dannegger; Bei der Rom search wird auch richtig -2 für keine Device zurückgegben. Wenn allerdings ein Device am Bus hängt bekomme ich als cnt 0. Er kommt da aus der search rom routine nicht wieder oder bringt einen falschen Rückgabewert. Die Zeile if (i ==40){return i;} habe ich eingefügt. Die 40 bekomme ich auch noch. Wenn ich die Zahl auf 32 ändere bekomme ich als rückgabe von rom search 0... kann mir jemand helfen? Danke Gruß Christian uchar w1_rom_search( uchar diff, uchar idata *id, uchar W1PIN ) { uchar i, j, next_diff,a; bit b; if( w1_reset( W1PIN) ){ return PRESENCE_ERR; // error, no device found } w1_byte_wr( SEARCH_ROM, W1PIN); // ROM search command next_diff = LAST_DEVICE; // unchanged on last device i = 8 * 8; // 8 bytes do{ j = 8; // 8 bits do{ b = w1_bit_io( 1 , W1PIN); // read bit if( w1_bit_io( 1 , W1PIN) ){ // read complement bit if( b ) // 11 return DATA_ERR; // data error }else{ if( !b ){ // 00 = 2 devices if( diff > i || ((*id & 1) && diff != i) ){ b = 1; // now 1 next_diff = i; // next pass 0 } } } w1_bit_io( b , W1PIN); // write bit *id >>= 1; if( b ){*id |= 0x80;}// store bit i--; }while( --j ); id++; // next byte if (i ==40){return i;} }while( i );