This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMP1826-1-WIRE®︎-CODE: mcu_rxOneWireByte() function error

Part Number: TMP1826-1-WIRE-CODE
Other Parts Discussed in Thread: TMP1826, TMP1827

// Send Bus Reset
mcu_txOneWireReset();

// Send SKIP ADDRESS command
mcu_txOneWireByte(0xCC);

// Send TEMP CONVERT function
mcu_txOneWireByte(0x44);

// Wait for tCONV = 5.5 ms
DelayMS(6);

// Send Bus Reset
// mcu_txOneWireReset();
// Send SKIP ADDRESS command
// mcu_txOneWireByte(0xCC);
// Send READ SCRATCHPAD-1 function
// mcu_txOneWireByte(0xBE);
// Read two bytes of temperature data

TempLSB = mcu_rxOneWireByte();
TempMSB = mcu_rxOneWireByte();
Temp = TempLSB | (TempMSB << 8);

Application Note Implementing Host Controller for TMP1826 and TMP1827 Single-Wire Temperature Sensor -->> The code was implemented based on that document.

Using an oscilloscope, the results of executing the "mcu_txOneWireReset()", "mcu_txOneWireByte(0xCC)", and "mcu_txOneWireByte(0x44)" functions were printed and confirmed.

The results were output the same as the corresponding documents Figure 2-3 and Figure 2-4.

However, TempLSB = 0xff and TempMSB = 0xff continue to be output in the Read section.

Please advise.

Additionally, I would appreciate it if you could tell me the formula to convert the obtained TempLSB and TempMSB data into temperature values.

please

  • Which version are you using, and on which MCU?

    Please share the oscilloscope pictures.

    There is a conversion function at the top of onewire_tmp1826_demo_singledevice_temp.c

    //*****************************************************************************
    //
    // Utility function to convert hex to degC print
    //
    //*****************************************************************************
    void
    converthextodegC(uint8_t uidevNo, uint16_t tempData)
    {
        uint16_t preDec;
        uint16_t postDec;
    
        UARTprintf("Temperature Data for Sensor %02d = ",uidevNo);
        // Print for 16-bit format
        if(tmp182x[uidevNo].devcnfg1_temp_fmt == CFG_REG1_TEMP_FMT_16BIT)
        {
            if((tempData & 0x8000) == 0x8000)
            {
                tempData = ~(tempData) + 0x1;
                preDec  = tempData >> 7;
                postDec = ((tempData - (preDec << 7))*7812)/1000;
                UARTprintf("-");
            }
            else
            {
                preDec  = tempData >> 7;
                postDec = ((tempData - (preDec << 7))*7812)/1000;
                UARTprintf("+");
            }
        }
        // Print for 12-bit format
        else
        {
            if((tempData & 0xF800) == 0xF800)
            {
                tempData = ~(tempData) + 0x1;
                preDec  = tempData >> 4;
                postDec = ((tempData - (preDec << 4))*625)/10;
                UARTprintf("-");
            }
            else
            {
                preDec  = tempData >> 4;
                postDec = ((tempData - (preDec << 4))*625)/10;
                UARTprintf("+");
            }
        }
    
        UARTprintf("%03d.%03d C\n",preDec,postDec);
    
    }

    There is also driver code in ASCStudio which has the following conversion functions:

    /*
     *  ======== TMP1826_toMilliCelsius ========
     *  Convert raw temperature register value to milli-degrees Celsius
     */
    int32_t TMP1826_toMilliCelsius(TMP1826_Handle sensor)
    {
        /* Scale to milli-degrees, convert Q7 or Q4 value to a whole number f*/
        uint8_t shift = (sensor->cfg1 & TMP1826_CFG1_TEMP_FMT_16BIT) ? 7 : 4;
        return ((1000 * (int32_t) sensor->temperature) >> shift);
    }
    
    /*
     *  ======== TMP1826_toFloatCelsius ========
     *  Convert raw temperature register value to degrees Celsius
     */
    float TMP1826_toFloatCelsius(TMP1826_Handle sensor)
    {
        /* Convert Q7 or Q4 value to a float */
        float lsb = (sensor->cfg1 & TMP1826_CFG1_TEMP_FMT_16BIT) ? 0.0078125f : 0.0625f;
        return ((float)sensor->temperature * lsb);
    }

    thanks,

    ren

  • Hello

    I am implementing it using FPGA,

    I will attach a photo of the oscilloscope and a circuit diagram below.

    The photo above shows the reset part.

    The photo above shows the 0xcc and 0x44 commands.

    If you look closely, the width of the waveform appears to be slightly different.

    After reading the data, 0xff 0xff appears as shown below.

    Below is my circuit diagram. Are there any problems with the circuit configuration?

    The pull up resistance is 2.2K

    u20: SN74LVC2G07DBV

    u21, u19: SN74AVC1T45DRLR

    please answer about my question.

  • I referred to "Application Note: Implementing Host Controller for TMP1826 and TMP1827 Single-Wire Temperature Sensor" 

  • It was implemented based on "Application Note: Implementing Host Controller for TMP1826 and TMP1827 Single-Wire Temperature Sensor: 2.1 Using GPIO as Host Interface" and set to FPGA2-TEMP_TX: OUT PIN, FPGA2_TEMP_RX: IN PIN.

  • Did you transmit Reset, SkipROM (0xCC), Read ScratchPad-1(0xBE) before the read byte loop?

    From the datasheet:

    See also GetTemperature() in tmp182x_func_driver.c included with TMP1826-1-WIRE-CODE download.

    thanks,

    ren

  • u16 readTemp()
    {
    u8 TempLSB;
    u8 TempMSB;
    u16 Temp;

    // Send Bus Reset
    mcu_txOneWireReset();


    // Send SKIP ADDRESS command
    mcu_txOneWireByte(0xCC);


    // Send TEMP CONVERT function
    mcu_txOneWireByte(0x44);


    // Wait for tCONV = 5.5 ms

    usleep(6000); //6ms
    //DelayMS(6);

    // Send Bus Reset
    mcu_txOneWireReset();


    // Send SKIP ADDRESS command
    mcu_txOneWireByte(0xCC);


    // Send READ SCRATCHPAD-1 function
    mcu_txOneWireByte(0xBE);


    // Read two bytes of temperature data

    TempLSB = mcu_rxOneWireByte();
    TempMSB = mcu_rxOneWireByte();
    return Temp = TempLSB | (TempMSB << 8);
    }

    Hi

    The current code is implemented as above.

    I sent Reset, SkipROM (0xCC), and Read ScratchPad-1 (0xBE) before the read byte loop, but the results are the same.

    Is there a problem with the code implemented as above?

    Best Regard

    KIM

  • This version of the code looks correct. Can you show me the waveform? Does TMP1826 send presence detect for both resets?

    thanks,

    ren

  • Hi

    I will attach the oscilloscope waveform signal.

    Figure1: total Code Signal

    Figure2: Reset + 0xcc + 0x44

    Figure3: Reset + 0xcc + 0xbe + mcu_rxOneWireByte + mcu_rxOneWireByte

    Figure4(Scale up Version): Reset + 0xcc + 0xbe + mcu_rxOneWireByte + mcu_rxOneWireByte

    Best Regard

    KIM

  • Can the signal come out like the picture above because of the circuit you configured?

  • The fact that presence detect works rules out any schematic issue. This looks correct to me, but we cannot decode it from oscilloscope. We would have to measure all the timings manually. Do you have access to a logic analyzer or other tool that can decode 1-Wire? My Digilent Discovery is able to decode 1-Wire. It could help us to see a timing mistake you've made. 

    Could you share your implementation of mcu_rxOneWireByte?

    thanks,

    ren

  • The mcu_rxOneWireByte function is as follows.

    u8 mcu_rxOneWireByte(void)
    {
    u8 count;
    u8 rxbyte;
    // Shift bits LSB to MSB
    for (count = 0; count < 8; count++)
    {
    rxbyte |= (mcu_rxOneWireBit() << count);
    }
    return(rxbyte);
    //cprintf("%d\r\n", rxbyte);
    }

    I will measure the signal with a logic analyzer and share it with you.

  • The functions of the internal function mcu_rxOneWireBit are as follows.

    uint8_t mcu_rxOneWireBit(void)
    {
    uint8_t rxbit;
    // Send the falling edge to begin the read
    //GPIOWrite(GPIO.OUT, 0);
    WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 0);
    // Wait for tRL = 2 us and release the bus
    usleep(2);
    //DelayUS(2);
    //GPIOWrite(GPIO.OUT, 1);
    WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 1);
    // Wait for tRC and sample the state of the bus
    //The tRC time is defined as the time taken for the bus voltage to rise from 0V to minimum VIH of the device. This is a function of the bus
    //pullup resistor, devices and parasitic capacitance of the trace or cable. The parameters must be characterized for the application.
    usleep(1);
    //DelayUS(1);
    //rxbit = GPIORead(GPIO.IN);
    rxbit = RD_REG(REG_ADDR + REG_BCM2_TEMP_IN);
    // Wait for remainder of the slot time (tSLOT-tMSW)
    usleep(8);
    //DelayUS(8);
    return(rxbit);
    }

    The functions of the internal function mcu_rxOneWireBit are as follows.

  • Is it possible you are transmitting your data backwards? It should be transmitted LSBit first. 

    Looking forward to your analysis of the oscilloscope timing.

    thanks,

    ren

  • Is it possible you are transmitting your data backwards? It should be transmitted LSBit first.
    ---> In the mcu_txOneWireByte() function, "mcu_txOneWireBit((bytevalue >> count) & 0x01);" Part "mcu_txOneWireBit((bytevalue << count) & 0x01);" Can I change it like this?

    I changed it, but the read data still shows 0xff.

  • #include "temperature.h"
    
    //#include "Process.h"
    
    u16 readTemp()
    {
    	u8 TempLSB;
    	u8 TempMSB;
    	u16 Temp;
    
    	// Send Bus Reset
    	mcu_txOneWireReset();
    
    
    	// Send SKIP ADDRESS command
    	mcu_txOneWireByte(0xCC);
    
    
    	// Send TEMP CONVERT function
    	mcu_txOneWireByte(0x44);
    
    
    	// Wait for tCONV = 5.5 ms
    
    	usleep(7200); //7200 * 0.8333 = 6ms
    	//DelayMS(6);
    
    	// Send Bus Reset
    	mcu_txOneWireReset();
    
    
    	// Send SKIP ADDRESS command
    	mcu_txOneWireByte(0xCC);
    
    
    	// Send READ SCRATCHPAD-1 function
    	mcu_txOneWireByte(0xBE);
    
    
    	// Read two bytes of temperature data
    
    	TempLSB = mcu_rxOneWireByte();
    
    	TempMSB = mcu_rxOneWireByte();
    
    	return Temp = TempLSB | (TempMSB << 8);
    }
    
    void mcu_txOneWireReset()
    {
    	// Send Bus Reset
    	//GPIOWrite(GPIO.OUT, 0);
    	WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 0);
    	// Wait for tRSTL = 48 us
    	usleep(60); //60 * 0.8333 = 49.9998us
    	//DelayUS(48);
    
    	// Release Bus Reset
    	//GPIOWrite(GPIO.OUT, 1);
    	WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 1);
    	// Wait for tPDH = 8 us
    	usleep(9); //9 * 0.83333 = 7.4997us
    	//DelayUS(8);
    	// Wait for Bus Reset Response
    
    	//while (GPIORead(GPIO.IN) != 0);
    	while (RD_REG(REG_ADDR + REG_BCM2_TEMP_IN) != 0);
    
    	//while (GPIORead(GPIO.IN) != 1);
    	while (RD_REG(REG_ADDR + REG_BCM2_TEMP_IN) != 1);
    
    }
    
    void mcu_txOneWireByte(u8 bytevalue)
    {
    	u8 count;
    	// Shift bits LSB to MSB
    	for (count = 0; count < 8; count++)
    	{
    		mcu_txOneWireBit((bytevalue >> count) & 0x01);
    		//mcu_txOneWireBit((bytevalue << count) & 0x01); //backward
    	}
    }
    void mcu_txOneWireBit(u8 bitvalue)
    {
    	// If logic '0' then set GPIO to 0 and wait for tWR0L
    	if (bitvalue == 0x00)
    	{
    		//GPIOWrite(GPIO.OUT, 0);
    		WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 0);
    		// Wait for tWR0L = 10 us
    		usleep(12); // 12 * 0.8333 = 9.9996
    		//DelayUS(10);
    	}
    	// If logic '1' then set GPIO to 0 and wait for tWR1L
    	else if (bitvalue == 0x01)
    	{
    		//GPIOWrite(GPIO.OUT, 0);
    		WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 0);
    		// Wait for tWR1L = 2 us
    		usleep(2); // 2 * 0.8333 = 1.66us
    		//DelayUS(2);
    	}
    	// Release the GPIO
    	//GPIOWrite(GPIO.OUT, 1);
    	WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 1);
    	// Wait for tREC = 2 us
    	usleep(3); //3 * 0.8333 = 2.5us
    	//DelayUS(2);
    
    }
    
    u8 mcu_rxOneWireByte(void)
    {
    	u8 count;
    	u8 rxbyte = 0x00;
    	// Shift bits LSB to MSB
    	for (count = 0; count < 8; count++)
    	{
    	rxbyte |= (mcu_rxOneWireBit() << count);
    	}
    
    	return(rxbyte);
    }
    
    
    uint8_t mcu_rxOneWireBit(void)
    {
    	uint8_t rxbit = 0;
    	// Send the falling edge to begin the read
    	//GPIOWrite(GPIO.OUT, 0);
    	WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 0);
    	// Wait for tRL = 2 us and release the bus
    	usleep(3); //3 * 0.8333 = 2.5us
    	//DelayUS(2);
    
    	//GPIOWrite(GPIO.OUT, 1);
    	WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 1);
    	// Wait for tRC and sample the state of the bus
    	//The tRC time is defined as the time taken for the bus voltage to rise from 0V to minimum VIH of the device. This is a function of the bus
    	//pullup resistor, devices and parasitic capacitance of the trace or cable. The parameters must be characterized for the application.
    	usleep(1);
    	//DelayUS(1);
    
    	//rxbit = GPIORead(GPIO.IN);
    	rxbit = RD_REG(REG_ADDR + REG_BCM2_TEMP_IN);
    	// Wait for remainder of the slot time (tSLOT-tMSW)
    	usleep(10); // 10 * 0.8333 = 8.333
    	//DelayUS(8);
    
    	return(rxbit);
    }

    I have attached my temperature.c code.

    My usleep() function has a problem where 1000us is controlled when 1200us is controlled, but the timing control time was controlled to satisfy Interface Timing. (In other words, to control 1000us, you must set it to 1200us)

    Below is the contents of temperature.h.

    #ifndef TEMPERATURE_H_
    #define TEMPERATURE_H_

    #include "Global.h"
    #include "Interrupt.h"
    #include "sleep.h"

    uint8_t mcu_rxOneWireBit(void);
    u8 mcu_rxOneWireByte(void);
    void mcu_txOneWireBit(u8 bitvalue);
    void mcu_txOneWireByte(u8 bytevalue);
    void mcu_txOneWireReset();
    u16 readTemp();

    #endif

  • #include "temperature.h"
    
    //#include "Process.h"
    
    u16 readTemp()
    {
    	u8 TempLSB;
    	u8 TempMSB;
    	u16 Temp;
    
    	// Send Bus Reset
    	mcu_txOneWireReset();
    
    
    	// Send SKIP ADDRESS command
    	mcu_txOneWireByte(0xCC);
    
    
    	// Send TEMP CONVERT function
    	mcu_txOneWireByte(0x44);
    
    
    	// Wait for tCONV = 5.5 ms
    
    	usleep(7200); //7200 * 0.8333 = 6ms
    	//DelayMS(6);
    
    	// Send Bus Reset
    	mcu_txOneWireReset();
    
    
    	// Send SKIP ADDRESS command
    	mcu_txOneWireByte(0xCC);
    
    
    	// Send READ SCRATCHPAD-1 function
    	mcu_txOneWireByte(0xBE);
    
    
    	// Read two bytes of temperature data
    
    	TempLSB = mcu_rxOneWireByte();
    
    	TempMSB = mcu_rxOneWireByte();
    
    	return Temp = TempLSB | (TempMSB << 8);
    }
    
    void mcu_txOneWireReset()
    {
    	// Send Bus Reset
    	//GPIOWrite(GPIO.OUT, 0);
    	WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 0);
    	// Wait for tRSTL = 48 us
    	usleep(60); //60 * 0.8333 = 49.9998us
    	//DelayUS(48);
    
    	// Release Bus Reset
    	//GPIOWrite(GPIO.OUT, 1);
    	WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 1);
    	// Wait for tPDH = 8 us
    	usleep(9); //9 * 0.83333 = 7.4997us
    	//DelayUS(8);
    	// Wait for Bus Reset Response
    
    	//while (GPIORead(GPIO.IN) != 0);
    	while (RD_REG(REG_ADDR + REG_BCM2_TEMP_IN) != 0);
    
    	//while (GPIORead(GPIO.IN) != 1);
    	while (RD_REG(REG_ADDR + REG_BCM2_TEMP_IN) != 1);
    
    }
    
    void mcu_txOneWireByte(u8 bytevalue)
    {
    	u8 count;
    	// Shift bits LSB to MSB
    	for (count = 0; count < 8; count++)
    	{
    		mcu_txOneWireBit((bytevalue >> count) & 0x01);
    		//mcu_txOneWireBit((bytevalue << count) & 0x01); //backward
    	}
    }
    void mcu_txOneWireBit(u8 bitvalue)
    {
    	// If logic '0' then set GPIO to 0 and wait for tWR0L
    	if (bitvalue == 0x00)
    	{
    		//GPIOWrite(GPIO.OUT, 0);
    		WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 0);
    		// Wait for tWR0L = 10 us
    		usleep(12); // 12 * 0.8333 = 9.9996
    		//DelayUS(10);
    	}
    	// If logic '1' then set GPIO to 0 and wait for tWR1L
    	else if (bitvalue == 0x01)
    	{
    		//GPIOWrite(GPIO.OUT, 0);
    		WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 0);
    		// Wait for tWR1L = 2 us
    		usleep(2); // 2 * 0.8333 = 1.66us
    		//DelayUS(2);
    	}
    	// Release the GPIO
    	//GPIOWrite(GPIO.OUT, 1);
    	WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 1);
    	// Wait for tREC = 2 us
    	usleep(3); //3 * 0.8333 = 2.5us
    	//DelayUS(2);
    
    }
    
    u8 mcu_rxOneWireByte(void)
    {
    	u8 count;
    	u8 rxbyte = 0x00;
    	// Shift bits LSB to MSB
    	for (count = 0; count < 8; count++)
    	{
    	rxbyte |= (mcu_rxOneWireBit() << count);
    	}
    
    	return(rxbyte);
    }
    
    
    uint8_t mcu_rxOneWireBit(void)
    {
    	uint8_t rxbit = 0;
    	// Send the falling edge to begin the read
    	//GPIOWrite(GPIO.OUT, 0);
    	WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 0);
    	// Wait for tRL = 2 us and release the bus
    	usleep(3); //3 * 0.8333 = 2.5us
    	//DelayUS(2);
    
    	//GPIOWrite(GPIO.OUT, 1);
    	WR_REG(REG_ADDR + REG_BCM2_TEMP_OUT, 1);
    	// Wait for tRC and sample the state of the bus
    	//The tRC time is defined as the time taken for the bus voltage to rise from 0V to minimum VIH of the device. This is a function of the bus
    	//pullup resistor, devices and parasitic capacitance of the trace or cable. The parameters must be characterized for the application.
    	usleep(1);
    	//DelayUS(1);
    
    	//rxbit = GPIORead(GPIO.IN);
    	rxbit = RD_REG(REG_ADDR + REG_BCM2_TEMP_IN);
    	// Wait for remainder of the slot time (tSLOT-tMSW)
    	usleep(10); // 10 * 0.8333 = 8.333
    	//DelayUS(8);
    
    	return(rxbit);
    }

    I have attached my temperature.c code.

    My usleep() function has a problem where 1000us is controlled when 1200us is controlled, but the timing control time was controlled to satisfy Interface Timing. (In other words, to control 1000us, you must set it to 1200us)

    Below is the contents of temperature.h.

    #ifndef TEMPERATURE_H_
    #define TEMPERATURE_H_

    #include "Global.h"
    #include "Interrupt.h"
    #include "sleep.h"

    uint8_t mcu_rxOneWireBit(void);
    u8 mcu_rxOneWireByte(void);
    void mcu_txOneWireBit(u8 bitvalue);
    void mcu_txOneWireByte(u8 bytevalue);
    void mcu_txOneWireReset();
    u16 readTemp();

    #endif

    I measured the timing with a program called DSView.

    www.dreamsourcelab.com/.../

    I have attached a photo and a file measuring the timing.

    The picture above is when the code below runs.

    mcu_txOneWireReset();


    // Send SKIP ADDRESS command
    mcu_txOneWireByte(0xCC);


    // Send TEMP CONVERT function
    mcu_txOneWireByte(0x44);

    The picture above is when the code below runs.

    // Send Bus Reset
    mcu_txOneWireReset();


    // Send SKIP ADDRESS command
    mcu_txOneWireByte(0xCC);


    // Send READ SCRATCHPAD-1 function
    mcu_txOneWireByte(0xBE);


    // Read two bytes of temperature data

    TempLSB = mcu_rxOneWireByte();

    TempMSB = mcu_rxOneWireByte();

    The delay between the two codes was 6ms.

    The extension of the attached file is .dsl file.

    temp_IC.zip

    Please review. Thank you for reading this long article. Please help me solve it.

  • Based on the logic analyzer data, you're using an Overdrive Reset and Standard Mode data packets. You can't mix Overdrive and Standard modes. The device is in Overdrive mode by default, but it will change to Standard mode once it sees a Standard Mode Reset pulse. The power-on behavior of your system could result in the 1-Wire bus being held low long enough to trigger a Standard Mode Reset. That's why it's good practice to force the use of Overdrive mode with OVD_SKIPADDR (0x3C) or similar, but it can make changing data rates complicated. The fact that your device responded with presence detect means it is still in Overdrive mode. If you change your code to overdrive timings for the data packets, it should start working correctly.

    thanks,

    ren

  • mcu_txOneWireByte(0x44);

    // Wait for tCONV = 5.5 ms

    DelayMS(6); //

    Send Bus Reset mcu_txOneWireReset();

    "DelayMS(6);" Is this why it is changed to standard mode?

  • The reset timing is inside mcu_txOneWireReset(). It is 480us for Standard and 48us for Overdrive. Your capture shows 51us, which is appropriate for Overdrive.

     

    You might be using this version of mcu_txOneWireReset within single_wire_gpio_driver.c. Here, Overdrive/Standard is configured in the busSpeed variable that is passed to the function.

    //*****************************************************************************
    //
    // Send Reset
    //
    //*****************************************************************************
    void
    mcu_txOneWireReset(bool busSpeed)
    {
        // Send Reset to device
        _GPIOWrite(GPIO_OWIRE_OUT_PIN, 0);
        if(busSpeed)
        {
            DEVICE_DELAY_US(H2D_RESET_OVD);
        }
        else
        {
            DEVICE_DELAY_US(H2D_RESET_STD);
        }
        _GPIOWrite(GPIO_OWIRE_OUT_PIN, 1);
    
        // Wait for Response to Reset
        if(busSpeed)
        {
            DEVICE_DELAY_US(H2D_PDH_OVD);
        }
        else
        {
            DEVICE_DELAY_US(H2D_PDH_STD);
        }
    
    #if (ONE_PIN_CONFIG == 1)
        _GPIOChangeWtoR(GPIO_OWIRE_OUT_PIN);
    #endif
    
        // Now Sample the Line for Being low
    #if (ONE_PIN_CONFIG == 0)
        while(_GPIORead(GPIO_OWIRE_IN_PIN) != 0);
    #endif
    #if (ONE_PIN_CONFIG == 1)
        while(_GPIORead(GPIO_OWIRE_OUT_PIN) != 0);
    #endif
    
        // Wait for 60 us minimum
        if(busSpeed)
        {
            DEVICE_DELAY_US(H2D_PDL_OVD);
        }
        else
        {
            DEVICE_DELAY_US(H2D_PDL_STD);
        }
    
        // Now Sample the Line for Being low
    #if (ONE_PIN_CONFIG == 0)
        while(_GPIORead(GPIO_OWIRE_IN_PIN) != 1);
    #endif
    #if (ONE_PIN_CONFIG == 1)
        while(_GPIORead(GPIO_OWIRE_OUT_PIN) != 1);
        _GPIOChangeRtoW(GPIO_OWIRE_OUT_PIN);
    #endif
    
        // Wait for 480 us minimum
        if(busSpeed)
        {
            DEVICE_DELAY_US((H2D_RSTH_OVD-(H2D_PDH_OVD+H2D_PDL_OVD)));
        }
        else
        {
            DEVICE_DELAY_US((H2D_RSTH_STD-(H2D_PDH_STD+H2D_PDL_STD)));
        }
    
    }