Shop OBEX P1 Docs P2 Docs Learn Events
problem with changing a password to ibutton1977 — Parallax Forums

problem with changing a password to ibutton1977

reggiereggie Posts: 5
edited 2014-02-12 21:03 in BASIC Stamp
i am writing and reading to ibutton1977 (from dallas) ..and it is being done ok.
if i try to write the same password again and again to the ibutton it is being done ok..

but when i try to write a diffrent password to the ibutton (from the first password ) i get error..
so i cant change passwords to my ibutton 1977...

what is the reason for that ?
does anybody know ?


now i am stuck with that confused.gif

Comments

  • skylightskylight Posts: 1,915
    edited 2009-11-17 13:30
    there are several considerations to be had with the passwords functions, for one have you disabled passwords before trying to change them?

    this datasheet may help?

    http://www.digchip.com/datasheets/parts/datasheet/280/DS1977-pdf.php
  • reggiereggie Posts: 5
    edited 2009-11-17 13:44
    i am working with this datasheet smile.gif

    how can i disable the password· after i make one ?

    where is it written how to disable a password ?

    i cant understand that from the datasheetsad.gif

    do you have an idea ?.


    thanks.
  • reggiereggie Posts: 5
    edited 2009-11-17 14:39
    if i want to enable i put 0xaa in the password control register...(EPW)

    what value do i need to put in the password control register in order to disable ??


    thanks

    roll.gif
    ·
  • skylightskylight Posts: 1,915
    edited 2009-11-17 20:42
    Password Control Register
    The data pattern stored in the Password Control Register determines whether password checking is enabled. If
    password checking is enabled, the password transmitted is compared to the passwords stored in the device.
    Reading from or writing to the scratchpad does not require a password.
    Password Control Register Bitmap
    ADDR b7 b6 b5 b4 b3 b2 b1 b0
    7FD0h EPW
    Register Details
    BIT DESCRIPTION BIT(S) DEFINITION
    EPW: Enable Passwords b0 to b7 This byte enables or disables the password protection, which applies
    to reading from and writing to the memory except for the scratchpad.
    If the EPW bits form a pattern of 10101010 (AAh), the device will
    execute these commands only if the correct password is transmitted.
    The default pattern of EPW is different from AAh.
    To enable password checking, the EPW bits need to form a binary pattern of 10101010 (AAh). If the EPW pattern
    is different from AAh, any password will be accepted, as long as it has a length of exactly 64 bits.

    So it sounds like if you dont have AAh (10101010) in the address 7FDoh then password checking IS disabled and will accept any 64bit password otherwise when enabled you have to place the correct password
  • reggiereggie Posts: 5
    edited 2009-11-18 15:04
    well,i try to disable the password by puting another value then AAh . i put 0x11h ,and it doesnot work.
    where can i find a code for C language which i can see how to disable a password and by that to change password ?
    here is my code to make a password :
    i can make a password , but if i try again to make another password its fails, like i wrote above..

    the code :


    int Set1977Password(char *pass)
    {
    int i,j,CompErrorFlag,ver1,ver2;
    char databuf[noparse][[/noparse]16],treg,dpass[noparse][[/noparse]8],ans,enpatt,str,xpass[noparse][[/noparse]16];

    CompErrorFlag=0;
    enpatt=0xaa;
    ans=0;
    ver1=ver2=0;

    for(i=0;i<8;i++) // copy the 8 byte password
    {
    xpass=pass;
    xpass[noparse][[/noparse]i+8]=pass;
    }

    for(i=0;i<8;i++) // set dummy password to be the sent password.
    dpass=pass;

    Write1977Scratch(xpass,16, 0x7fc0); // write the password on the scratch.
    Read1977Scratch(treg, databuf, 16 ); // read the password from the scratch back.

    for(i=0;i<16;i++) // compare the passwords to what was written.
    {
    if(databuf != xpass)
    CompErrorFlag=1;
    }

    if(CompErrorFlag==1)
    return 0 ; // compare failed
    if(CompErrorFlag!=1)
    {
    Copy1977ScratchPass(treg[noparse][[/noparse]0], treg, treg, dpass); // copy scratch with dummy password.

    StrongPullUp();

    ans=OWReadByte3(); // read answer.
    // make string
    if( ans == 0xaa ) // check if password was saved.
    {
    OW_Reset3(); // reset line.

    ver1=Verify1977Pass(8, 0x7fc0, pass); // verify 1st password.
    ver2=Verify1977Pass(8, 0x7fc8, pass); // verify 2nd password.

    if( (ver1 == 1) && (ver2 == 1) ) // if both passwords verified ok continue.
    {
    Write1977Scratch(&enpatt, 1, 0x7fd0 ); // write enable pattern.
    Read1977Scratch(treg, databuf, 1 ); // read the password from the scratch back.

    ans=0; // zero ans for next copyscratch check.
    CompErrorFlag=0; // zero error flag

    if(databuf[noparse][[/noparse]0] != enpatt)
    CompErrorFlag=1;

    if(CompErrorFlag==1)
    return 0; //compare was failed
    if(CompErrorFlag!=1)
    {
    Copy1977ScratchPass(treg[noparse][[/noparse]0], treg, treg, dpass); // copy scratch with dummy password. because password are not yet enabled!
    StrongPullUp();

    ans=OWReadByte3(); // read answer.
    if( ans != 0xaa )
    return 0; //answer failed
    OW_Reset3();
    }
    }
    else
    {
    return 0; //verify wrong
    }
    }
    else
    {
    return 0; //password wasnt saved
    }
    }
    return 1; //sucess
    }


    using the code :

    Set1977Password(password); //works
    Set1977Password(password2); //does not work ! so i cant change my password
  • skylightskylight Posts: 1,915
    edited 2009-11-18 22:11
    The manual states:

    The default pattern of EPW is different from AAh.
    To enable password checking, the EPW bits need to form a binary pattern of 10101010 (AAh). If the EPW pattern
    is different from AAh, any password will be accepted, as long as it has a length of exactly 64 bits.

    I can only assume then that there is an error in your programming?
  • reggiereggie Posts: 5
    edited 2009-11-23 08:11
    well ,
    i tried to disable the password and it does not work .

    i wonder if i can find a code example in "C" of disabling a password on ibutton 1977...

    do you have any idea ?

    thanks .
  • avinash.ahgavinash.ahg Posts: 1
    edited 2014-02-12 21:03
    Hello,
    I am facing problem with reading/writing scratchpad for DS1977. Can any one send me the working code for DS1977 writing/reading scratchpad. I am facing problem to interface with pic30f.

    Regards
    Avinash
Sign In or Register to comment.