Other Parts Discussed in Thread: BQSTUDIO
I'm using the bq34z100-G1, communicating via I2C from a microcontroller.
Control() Subcommands for type and version return:
- DEVICE TYPE: 0x0100
- FW_VERSION: 0x0016
- HW_VERSION: 0x0080
I'm having trouble configuring the sleep and full-sleep modes, and
noticed some oddities when dealing with the flash. Data sheet section
"7.3.3.1 Accessing Data Flash" explains how to read and write from the
flash for settings that do not have a Data Command. I've copied the
important paragraph below:
> To access data flash locations individually, the block containing
> the desired data flash location(s) must be transferred to the
> command register locations where they can be read to the host or
> changed directly. This is accomplished by sending the set-up command
> BlockDataControl() (code 0x61) with data 0x00. Up to 32 bytes of
> data can be read directly from the BlockData() command locations
> 0x40…0x5F, externally altered, then re-written to the BlockData()
> command space. Alternatively, specific locations can be read, altered,
> and re-written if their corresponding offsets are used to index into the
> BlockData() command space. Finally, the data residing in the command
> space is transferred to data flash, once the correct checksum for the
> whole block is written to BlockDataChecksum() (command number 0x60).
The example goes through the following steps, which I have followed.
Note I was looking at subclass 68 offset 2 for sleep current instead of
class 64 offset 0 as in the example.
1. Unseal the device. Skipped, my device was not sealed according
to the status register.
2. Write 0x00 to BlockDataControl (0x61) to enable block data
flash control.
3. Write 0x44 (Power Configuration Subclass) to DataFlashClass
(0x3E) to access the registers subclass.
4. Write block offset (0x00) to DataFlashBlock (0x3F)
5. Read 0x42 (Sleep Current). Expected 0x0a for default Sleep
Current of 10mA. Got 0xf0. Then, instead of reading just 0x42,
I read all 32 bytes from 0x40 to 0x5F. Looking at that I see
the expected value.
6. Read the 1-byte checksum from BlocKDataChecksum (0x60). I
found out later that this value was also wrong.
7. Calculate new value. In this case 0x64, the max allowed value
for Sleep Current of 100 mA.
8. Write new value 0x64 to offset 0x42.
9. Calculate and write new checksum to BlockDataChecksum
(0x60). Writing the new checksum based on the one from
BlockDataChecksum I get an I2C NAK. I then calculated the
checksum based on the entire block I read and got a different
number than the one read from BlockDataChecksum. Calculating the
checksum based on the entire block with my change seems to work.
I write that checksum and don't get the I2C NAK, then read back
the entire block and see my changes.
10. Reset the gauge by writing the RESET (0x0041) subcommand to
the Control (0x00) register.
11. Seal the gauge. Skipped, my devices was not sealed to
begin with.
By reading/writing full blocks and calculating the checksum based on
the full blocks I was able to make some changes.
Then when I booted, the device did go into sleep mode according to
the status register. At an early stage during my debuging I think
I remember it leaving sleep mode correctly once more power was drawn.
However, now it cycles between sleep mode and normal mode once a second.
I read the status register via I2C every 100ms and see it change from
sleep mode to normal, then one second later back to sleep, etc.
I also tried to get the device into full sleep mode. I set the FS Wait
and used the SET_FULLSLEEP Control Subcommand. At least once early on it
became completely unresponsive to I2C messages. Now the status register
shows the FULLSLEEP bit always set, even though the datasheet says:
> Status bit that indicates the bq34z100-G1 is in FULL SLEEP mode. True
> when set. The state can only be detected by monitoring the power used by
> the bq34z100-G1 because any communication will automatically clear it.
Questions:
- Any idea why I'm unable to read/write single bytes correctly
after loading a block?
- Is there any way to do a full reset to factory defaults of
all settings? Or does that require a firmware flash?
- Is there a way to flash the firmware from a linux based
computer?
- How can I be reading the FULLSLEEP bit set when the datasheet
says that should be impossible?
- Is there a list of hardware or firmware errata per version?
I'm not saying there is necessarily something wrong with the
hardware or firmware, but the behavior I'm seeing is weird enough
that I'd like to know if there are any problems I need to watch
out for.
- Can anyone give a full example of configuration steps that
have successfully put a device into sleep and full sleep modes?
I'm happy to provide clarification and try any suggestions.
Thanks,
Evan