Other Parts Discussed in Thread: BQSTUDIO
Hi
Just got a question about some parameters on the BQ4050.
What exactly is the AtRate variable for? (Chap 13.5 of TRM) I know the TRM says it's used to calculate the TimeToFull and TimeToEmpty but it is defaulted to 0. If I wanted to use the TimeToFull and TimeToEmpty values, how would I set the AtRate value? Would I have to set it manually each time a charge or discharge condition is detected?
Also, I've been working on firmware to interface with the BQ4050 and the information in chapter 13.1.51 in the TRM on how to write Data Flash is a little lacking I think. You need to write bytes of data in the following order to correctly have the data saved into memory:
deviceAddress(w) + 0x44 + numBytes + flashAddrLowByte + flashAddrHighByte + Data1LowByte + Data1HighByte + PECByte
deviceAddress is normally 0x0B plus the write bit, so it will appear as 0x16 on an analyser.
numBytes is the number of bytes about to be sent including flash address bytes, flash data bytes and PEC byte. BQStudio always seems to write 32 bytes every time you change a single value so this appears as 0x22.
flashAddr bytes are the low and high bytes of the 2 bytes addresses that are listed in chapter 14.15 Data Flash Summary
Data bytes are 1 to 4 bytes, depending on the Data Flash item. Negative values are 2's compliment stored, so for all values you can just >> 8 for each progressive byte.
PECByte is calculated with CRC8 and is based on every preceding byte in the packet. The address byte used for the calculation includes write bit, so 0x16. There is an online calculator here http://www.sunshine2k.de/coding/javascript/crc/crc_js.html and an example calculation algorithm here http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html
To read bytes from the DF the following format is used:
deviceAddress(w) + 0x44 + numBytes(0x02) + flashAddrLowByte + flashAddrHighByte + PECByte
wait 15ms
deviceAddress(w) + 0x44
The returned data goes
numbeBytes(0x22) + flashAddrLowByte + flashAddrHighByte + Data1.......
Maybe this is useful information for anyone else.
Thanks