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.

failed to update DataFlash in bq20z80

Other Parts Discussed in Thread: BQ20Z80

Hi,

I need to do small DataFlash update in the existing device with bq20z80DBT controller (ver1.02). I have no EV2300, so I use BusPirate's I2C capability.

The change is to switch the controller to use internal termistor only. So the target is Subclass 64.

Reading subclass  ([ -means Start bit, ] - stop bit, r:33 - read 33 bytes):

[0x16 0x77 0x40 0x00][0x16 0x78 [0x17 r:33]

Gives the response:

0x08 ACK 0x0E ACK 0x29 ACK 0x3C ACK 0xD8 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x21 ACK 0x21 ACK ... rest of the bytes here to fill 32 bytes range

Response is correct, now I change first byte from 0x0E to 0x06 which sets Temp1,0 [4,3]: to – 0,0 = Only internal temperature sensor is used to generate Temperature.

(It's from Literature Number: SLUA380 June 2006 стр 79:)

Now writing:

[0x16 0x77 0x40 0x00][0x16 0x78 0x06 0x29 0x3C 0xDB 0x00 0x00 0x00 0x00]

All bytes sent are acknowledged with ACK signals but DataFlash is not updated. What am I missing?

The TechnicalReference (SLUU241A) says:
"""
Reading and Writing subclass data are block operations which are 32 Bytes long each. but data can be written in shorter block sizes. The final block in one subclass can be shorter than 32 bytes so care must be taken not to write over the subclass boundary. None of the values written are bounded by the bq20z80 and the values are not rejected by the gas gauge. Writing an incorrect value may result in hardware failure
due to firmware program interpretation of the invalid data. The data written is persistent, so a Power On
Reset does resolve the fault.

"""

Does it says that only _last_ block of subclass could be shorter? How about subclass 64 which is only 8-bytes long?

I was afraid to write 32-bytes there because of the warning above - to get out of boundary.

And I do not understand to if I corrupted DataFlash how Power On Reset could resolve the problem?

Thanks.

 

 

 

 

 

  • Just discovered, when you reading or writing subclass to dataflash , first byte should always be length of the following byte block.

    When proper length in first byte is provided all following bytes to write are acknowledged with ACK bits.

    Why dataflash is not updated? What am I still missing?

     

     

  • Dmitry,

    When you are writing/reading a subclass, it's a SMBus block write/read. As part of the protocol, you will need to provide the byte count following by the data for a block write. As for a block read, you'll receive the byte count following by the data. For detail, please refer to the SMBus spec available at http://smbus.org/

     

    Now for reading and writing a subclass, you can write up to 32bytes. It doesn't mean you have to write 32byte every time, the length of the array depends on the size of the subclass. As long as you provide a correct byte count for a block write, it will work even if you send a 32-byte data array to a subclass that is less than 32byte in size.  We will clarify that in the TRM. Sorry for the confusion.

     

    For example, in bq20z80, subclass 0 has 22 bytes. This subclass has only 1 page (1page = 32 byte), so only cmd 0x78 will be used for read/write

    To update a parameter in this subclass

    1. Send a SMbus write word, cmd = 0x77, word = 0x00. To set up the subclass.

    2. Send a SMBus block read, cmd = 0x78. You should receive 23 byte of data, where the 1sst byte is the byte count

    3. Update your data array for the parameter you want to modify

    4. Send a SMBus block write, cmd = 0x78, block size = 22 follow by your data array

  • Jackie,

    Thanks for the reply.

    That's right what I did. The only difference is that I repeated setting subclass with cmd =0x77 before issuing cmd=0x78 and sending changed data array.

    And all bytes sent were _acknowledged_ with ACK signal.

    Instead of the task mentioned in my initial message I was experimenting with subclass 48 which is long enough so my cmd=0x78 data array was really 32 bytes long.

    All good except that subsequent reading  of the same subclass returned unmodified data.

     

  • Make sure your device is unseal and the voltage is higher than the Flash update voltage parameter in data flash.

    Also make sure you don't have any PF error set. Maybe you can try using EVSW to ensure your setup is good to update flash, and then run your code.

  • Jackie,

    Now the EV2300 screen looks like this :