Post Go back to editing

Seeking Support for Reading ROM code of I-Button

Category: Software
Product Number: DS9092L

Dear AD Team,

                     In our custom board, we are using the DS9092L+ IButton probe with the DS1990A IButton interfaced with MSP432E4 Microcontroller. However, we are facing difficulties in reading the ROM code of the IButton.

Below are the connections for your reference:

  • IButton Probe:

o   Green (Data) connected to PORTE- E2 on the microcontroller

o   Black (+ve LED) connected to PORTE- E3 on the microcontroller

o   White (-ve LED) connected to GND

o   Red (Ground) connected to GND

Additionally, we have connected a 4.7kohm resistor for pull-up on the data line.

Problem Facing: 
                          I can able to detect the I Button successfully but could not able to read the 64bit ROM code of the IButton.Reading ROM code i am sending 0x33 command to the I Button.
I Button code:
 


#ifdef I_BUTTON_INTERFACE


#if 1

    int index;

    led_init(); // Initialize the LED

    I_ButtonInit();

    /* Clear the buffer */
    memset(&DestBuff[0], 0x00, sizeof(DestBuff));
    while(1)
    {
        onewire_reset();

        memset(&DestBuff[0], 0x00, sizeof(DestBuff));
        /* Find the One Wire device */
        Read_ROMCode(&DestBuff[0]);

        UARTprintf("OneWire ROMCode = ");
        for (index = 0; index < 8; index++)
        {
            UARTprintf("0x%x ", DestBuff[index]);
        }
        UARTprintf("\r\n");
        delayms(50);
    }
#endif


void led_init() {


    UINT8 u8RetVal;
    u8RetVal = GPIO_Output_Init(SYSCTL_PERIPH_GPIOK,GPIO_PORTK_BASE,GPIO_PIN_4,GPIO_PIN_4);

    ROM_GPIOPinWrite(GPIO_PORTK_BASE, (GPIO_PIN_4), GPIO_PIN_4);
    delaySec(1);
    ROM_GPIOPinWrite(GPIO_PORTK_BASE, (GPIO_PIN_4), 0);


}

void I_ButtonInit()
{
    UINT8 u8RetVal;


    u8RetVal = GPIO_Output_Init(SYSCTL_PERIPH_GPION,GPIO_PORTN_BASE,GPIO_PIN_4,GPIO_PIN_4);//PN4 set as output

    ROM_GPIOPinWrite(GPIO_PORTN_BASE, (GPIO_PIN_4), GPIO_PIN_4); //making as high

}



unsigned int onewire_reset() {

    UINT8 u8RetVal;
    u8RetVal = GPIO_Output_Init(SYSCTL_PERIPH_GPION,GPIO_PORTN_BASE,GPIO_PIN_4,GPIO_PIN_4);

    ROM_GPIOPinWrite(GPIO_PORTN_BASE, (GPIO_PIN_4), 0);//Making Data line as low
    delayus(480);

    ROM_GPIOPinWrite(GPIO_PORTN_BASE, (GPIO_PIN_4), GPIO_PIN_4);//Making Data line as high
    delayus(70);

    u8RetVal = GPIO_Input_Init(SYSCTL_PERIPH_GPION,GPIO_PORTN_BASE,GPION,GPIO_PIN_4,INT_GPION,GPIO_PULLUP_ENABLE,GPIO_FALLING_EDGE,GPIO_INT_DISABLE);//Data line configured as Input

    UINT32 presence = ROM_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_4);//Reading the data line status
    delayus(410);


    UARTprintf("\n");
    UARTprintf("Presesnce:%x\n",presence);

    if(presence == 0)
    {
        UARTprintf("I_BUTTON DETECTED\n");
        ROM_GPIOPinWrite(GPIO_PORTK_BASE, (GPIO_PIN_4), GPIO_PIN_4);

    }
    else
    {
        UARTprintf("I_BUTTON NOT DETECTED\n");
        ROM_GPIOPinWrite(GPIO_PORTK_BASE, (GPIO_PIN_4), 0);
    }

    GPIO_Output_Init(SYSCTL_PERIPH_GPION,GPIO_PORTN_BASE,GPIO_PIN_4,GPIO_PIN_4);//Data line configured as Output

}


void OneWire_WriteByte(char byte)
{
    int l;
    // Loop to write each bit in the byte, LS bit first
    for (l = 0; l < 8; l++)
    {
        OneWire_WriteBit(byte & 0x01);
        byte >>= 1;
    }

}

void OneWire_WriteBit(char bit)
{

    if (bit)
    {
        // Write '0' bit for the WriteOne bit
        ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4, 0);
        delayus(6);
        ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4, GPIO_PIN_4);
        delayus(64);
    }
    else
    {
        // Write '0' bit for the WriteZero bit
        ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4, 0);
        delayus(70);
        ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4, GPIO_PIN_4); //if not working change to 0 and check
        delayus(10);
    }

}

unsigned char OneWire_Readbyte(void)
{

    int l;
    unsigned char result = 0;

    for (l = 0; l < 8; l++)
    {
        result |= (OneWire_Readbit() << l);
    }
    return result;

}



unsigned char OneWire_Readbit(void)
{
    unsigned char result;
    UINT8 u8RetVal;

    GPIO_Output_Init(SYSCTL_PERIPH_GPION,GPIO_PORTN_BASE,GPIO_PIN_4,GPIO_PIN_4);//Data line configured as Output


    /* Start the Read bit sequence */
    ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4, 0);
    delayus(6);//    delayms(6);

    ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4, GPIO_PIN_4);//if u want to make high uncomment it
    delayus(9);

    /* Make the pin as Input for reading the data */
    u8RetVal = GPIO_Input_Init(SYSCTL_PERIPH_GPION,GPIO_PORTN_BASE,GPION,GPIO_PIN_4,INT_GPION,GPIO_PULLUP_ENABLE,GPIO_FALLING_EDGE,GPIO_INT_DISABLE);//Data line configured as Input

    result = ROM_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_4);
    delayus(45);

    /* Revert back the GPIO state as ouput */
    GPIO_Output_Init(SYSCTL_PERIPH_GPION,GPIO_PORTN_BASE,GPIO_PIN_4,GPIO_PIN_4);//Data line configured as Output
    return result;

}



void Read_ROMCode(unsigned char *destbuf)
{
    int n;

    if (NULL == destbuf)
        return;


        onewire_reset();

    OneWire_WriteByte(0x33);

    for (n = 0; n < 8; n++)
    {
        destbuf[n] = OneWire_Readbyte();
    }

}
When i keep I button on the probe some random value is coming,if I do not keep printing all 0xFF.
Ibutton Used:DS1990A.
Please let me know what will be the issue in reading ROM  code of the I Button.