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.

UCD9081: UCD9081 Write unsuccessful

Part Number: UCD9081

 According to UCD9081 program guide to  design software, can read  internal register normally. But t the register cannot be written normally.

Can  you help to  provide one actual demonstration program code to me, Thanks!?

in the section 3.7.1 of UCD9081 program guide,we have some questions about the write process using i2c,

1,when write  data to  a block ,Is it  one-time write 2byte and repeat 16 times to write 32 bytes?

2, Do we  need to write all of your page of  user data or config para,only then can Close the Flash.

Thanks!

  • you can generate a i2c transcation file from UCD9081 GUI to see how the data are written into the device.

    Regards

    Yihe

  • Thanks for your reply,I have followed your suggestion to design the software program according to CD9081 GUI.
    But still cannot write normally.
    Could you help check it? Thank you very much!


    #!/bin/sh

    #NOTE
    #This script use open source tools "i2c-tools-3.1.2" to configuration ucd9081
    #This script function is write 512-byte block data by 256 2-byte segments starts at address 0xE000.

    #Tools usage:
    #i2cset [-f] [-y] [-m MASK] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]
    # I2CBUS is an integer or an I2C bus name
    # ADDRESS is an integer (0x03 - 0x77)
    # MODE is one of:
    # c (byte, no value)
    # b (byte data, default)
    # w (word data)
    # i (I2C block data)
    # s (SMBus block data)
    # Append p for SMBus PEC

    #This script arguments explain here
    #9: I2C BUS NUMBER
    #0X68: Device Address
    #0x2e: FLASHLOCK Register Address
    #0x30: WADDR Register Address
    #0x32: WDATA Register Address
    #s: MODE(SMBus block data)

    #circulate time
    local a=16
    local aa=16
    local aaa=16
    local aaaa=16
    local b=16
    local bb=16
    local bbb=16
    local bbbb=16
    local c=16
    local cc=16
    local ccc=16
    local cccc=16
    local d=16
    local dd=16
    local ddd=16
    local dddd=16

    i2cset -f -y 9 0x68 0x2e 0x02 #Open the FLASH
    i2cset -f -y 9 0x68 0x30 0xe0 0x00 s #Set base address: 0xe000
    i2cset -f -y 9 0x68 0x32 0xba 0xdc s #Unlock and erase the FLASH

    #Write Data address 0xe000 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe0 0x00 s
    while [ $a -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "a-=1"
    done

    #Write Data address 0xe020 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe0 0x20 s
    while [ $aa -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "aa-=1"
    done

    #Write Data address 0xe040 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe0 0x40 s
    while [ $aaa -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "aaa-=1"
    done

    #Write Data address 0xe060 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe0 0x60 s
    while [ $aaaa -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "aaaa-=1"
    done

    #Write Data address 0xe080 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe0 0x80 s
    while [ $b -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "b-=1"
    done

    #Write Data address 0xe0a0 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe0 0xa0 s
    while [ $bb -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "bb-=1"
    done

    #Write Data address 0xe0c0 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe0 0xc0 s
    while [ $bbb -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "bbb-=1"
    done

    #Write Data address 0xe0e0 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe0 0xe0 s
    while [ $bbbb -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "bbbb-=1"
    done

    #Write Data address 0xe100 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe1 0x00 s
    while [ $c -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "c-=1"
    done

    #Write Data address 0xe120 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe1 0x20 s
    while [ $cc -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "cc-=1"
    done

    #Write Data address 0xe140 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe1 0x40 s
    while [ $ccc -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "ccc-=1"
    done

    #Write Data address 0xe160 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe1 0x60 s
    while [ $cccc -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "cccc-=1"
    done

    #Write Data address 0xe180 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe1 0x80 s
    while [ $d -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "d-=1"
    done

    #Write Data address 0xe1a0 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe1 0xa0 s
    while [ $dd -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "dd-=1"
    done

    #Write Data address 0xe1c0 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe1 0xc0 s
    while [ $ddd -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "ddd-=1"
    done

    #Write Data address 0xe1e0 and Write Data 2-byte Up to 16 times (32 bytes)
    i2cset -f -y 9 0x68 0x30 0xe1 0xe0 s
    while [ $dddd -gt 0 ]
    do
    i2cset -f -y 9 0x68 0x32 0x11 0x22 s
    let "dddd-=1"
    done

    i2cset -f -y 9 0x68 0x2e 0x00 #Lock and close the FLASH

    exit 0
  • Help, who can Help answer my questions.Thanks!
    1,when write data to a block ,Is it one-time write 2byte and repeat 16 times to write 32 bytes?

    2, Do we need to write all of your page of user data or config para,only then can Close the Flash?
  • #1. either one is fine, but you have to make sure to adjust the address with correct increment for each write.

    #2. yes, you have to write anything together. you can not just writ partial.

    Regards

    Yihe