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.

BQ4050: Communication with the gas gauge with PEC

Part Number: BQ4050


Hi all,

I am communicating with the BQ4050 chip via I2C driver on my MCU (since the vendor lacks SMBus driver implementation). 

I am successfully able to communicate with the device but since i do not read and verify PEC, it leads to read errors sometimes. 

I am trying to set-up communication with error detection and therefore was wondering how to enable PEC in BQ4050? The reference manual is not clear on this. Also it only mentions that optional support for PEC is available on BQ4050 but does not tell any default state.

Is PEC byte available by default or do I have to enable it manually? 

In case it is enabled by default, how to i calculate it? Do I take the whole packet (including the bytes sent to slave) or only the bytes received from the slave to calculate and verify the PEC (CRC8) ?

Thanks is advance.

Warm regards,

Ashutosh

  • Hello Ashutosh,

    This thread has been assigned to someone, and they should hopefully get back to you by the
    beginning of next week.

    Sincerely,
    Nick Richards

  • Hello Ashutosh,

    PEC is enabled by default but is optional. Calculation of PEC uses CRC-8. Details can be found in the SMBus specification.

  • Hi Shirish, 

    thanks for the reply! But I am not sure if I follow you correctly. Specifically, I am confused about the meaning of "default but optional". 

    Does it mean following? 

    PEC is enabled by default but is optional means that while sending data to the BQ4050 (Slave), we can choose to either include or not include the PEC byte when we are writing to the BQ4050 but is always sent for read response by the BQQ050 to the Master i.e. PEC is always appended after the data bytes by the BQ4050? 

    If above statement is true, then how is the stop bit handled? Because according to specifications, without PEC, the stop bit is sent after the last valid data byte and with PEC the stop bit is sent after the PEC byte at the end of, say, read transaction. This is where I am mainly confused. 

    Can you elaborate on what is meant by optional in this case? I mainly intend to use the PEC byte for sanity check while receiving data from the BQ4050.

    Thanks in advance!

  • Hello Ashutosh,

    It means the host does not need use use the PEC byte the gauge sent, and communication going to the gauge is not required to have the PEC byte. That is why it is optional, and also enabled by default, meaning it's always there but your choice to use it. Exactly as you have mentioned.

    Sincerely,

    Wyatt Keller

  • Thanks Wyatt. Exactly what I was looking for :)