Hardware environment: P89LPC917, DS1820 temperature chip, VDD = 3.3V, debug serial port; software environment: keil uvision2, serial communication controller (used to receive serial port data) Process: Look at the information, which has many C51 single-chip operation DS1820 instance, However, its crystal frequency is a 51-chip of the standard, 11.059 MHz. The crystal of the P89LPC917 is 7372800Hz. Since the single bus is very strict, it is very short, so it is a loop code to use. When this is the key is how the delay program under 7372800Hz is doing? Read the book understanding what clock cycle, machine cycle, the instruction cycle is planned to calculate a precise delay program, but the occasion is written in the C language, This is not good. Finally, even the oscilloscope is used to measure the time. After a toss, I got the following conclusions: Delayed code is: // delay - with an AN 7.3728MHz crystal // Calling the routine Takes About 4μs, and then // Each Count Takes Another 3.2μsvoid Delay (UINT16 US) {Volatile Uint16 S; for (S = 0; S // Pull DQ Line Low delay (141); // Leave IT Low for 480μs DQ = 1; // ALLOW LINE TO RETURN High Delay (// Wait for Presence Presence = DQ; // Get Presence Signal DELAY 110); // Wait for end of time,} // presence = 0, no part = 1 // Read UINT8 read_bit (void) {dq = 0; // pull DQ LOW To start Timeslot DQ = 0; DQ = 0; DQ = 0; DQ = 1; // Ten Return High Delay (3); // DELAY 15μs from Start of Timeslot Return (DQ); // Return Value of DQ Line} // Writing Void Write_bit (int8 bitval) {dq = 0; // pull DQ low start Timeslot DQ = 0; // Maintain at least 1us DQ = 0; DQ = 0; if (Bitval == 1) DQ = 1; // Return DQ High if write 1 delay (18); // Hold Value for Remainder of Timeslot, 60us DQ = 1 } // / / reading UINT8 read_byte (void) {uint8 i; uint8 value = 0; for (i = 0; i <8; i ) {if (read_bit ()) value | = 0x01 << i; // Reads Byte in, One Byte At a Time and The // Shifts It Left Delay (18);