Hello
Sometimes, when I'm doing an smb block read to 0x44, I get a nack on the smbus address. Why ? IIRC, smbus protocol does not allow a device to nack its address.
Here is an oscilloscope capture of the problem:
Thanks for the help !
Philippe
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.
It's possible that is the problem. You should not attempt to send reads more often than every 22mSec and writes more often than 66mSec for Block Read/Write. Can you try to increase your delay and see if this helps?
Best,
Justin
Dear Justin,
I've implemented a wait of 22ms after each smb Block read and it still fail randomly (it seems a bit less).
Here are the exact access which are triggering this problem (the sleep 22ms is done in order to wait at least 22ms between the start of each cmd. the time to transfert the data is not included into it)
smbWriteWord(0x0, MAC_DASTATUS1)
smbReadBlock(0x44)
sleep(22ms)
smbWriteWord(0x0, MAC_DASTATUS2)
smbReadBlock(0x44)
sleep(22ms)
smbWriteWord(0x0, MAC_CHARGINGSTATUS)
smbReadBlock(0x44) [usually fail at this point]
sleep(22ms)
smbWriteWord(0x0, MAC_GAUGINGSTATUS)
smbReadBlock(0x44)
sleep(22ms)
smbReadWord(0x14) [charging Current]
sleep(22ms)
smbReadWord(0x0A) [current]
BTW, I'm wondering if this 22ms timeout is not a direct violation of the SMBus specification. The device is allowed to NACK the transfer after the address, but not the address itself.
Thanks for the help,
Philippe
SMBus made simple v6.pdfHi Philippe,
Is there a delay built into the smbWriteWord command? You need to wait at least 66ms between write commands. I see you do a WriteWord and ReadBlock consecutively. Can you verify if there is indeed a delay?
In addition I included a useful document called SMBus made simple for your reference.
Best,
Justin
Hi Justin,
Indeed, if I implement a such wait it does not fail anymore. But the device access is /very/ slow.
BTW, according to the SMBus specification version 2.0, section 4.2 (page 19):
"An SMBus device must always acknowledge (ACK) its own address."
So it seems that the bq40z50 is not fully smbus compliant.
Does we have to implement a such wait if we are doing a simple "SBS command" (such as a block read with cmd 0x56 which is identical to a manufacturer access to 0x0056) ?
Thanks,
Philippe
You have an extra acknowledge from the master on the last byte read in the block, this confuses the firmware as it indicates in a i2c transaction that it will be clocked again to continue reading. Most of the BQXXXXX firmwares can't handle an erroneous ack in a transaction. Some pull the data line low indefinitely, others eventually timeout the transaction.