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.

CCS: bq20z45R1 v1.05

Tool/software: Code Composer Studio

Hi, 

Im traying to develop a software in C# to create the ggfile... mostly looks well however i have problem get the CCGain... 

im getting these values in the Offset 0;  239, 3,34,5

Any idea?

It is my code:

EV23K.WriteSMBusWord(short.Parse("0077", System.Globalization.NumberStyles.HexNumber), short.Parse(104, System.Globalization.NumberStyles.HexNumber), 0X17);
EV23K.ReadSMBusBlock(short.Parse(0078, System.Globalization.NumberStyles.HexNumber), ref nBlock, ref nLen, 0X17);

double Exp = short.Parse(Block[0].ToString());
Exp = Math.Pow(2, (Exp - 128 - 24));

var nBlock = new List<byte>(Block);
nBlock.RemoveAt(0);
Block = nBlock.ToArray();

Block[0] = Convert.ToByte(short.Parse(Block[0].ToString()) + 128);

StringBuilder Hex = new StringBuilder(Block.Length * 2);
foreach (var Byts in Block)
Hex.AppendFormat("{0:X2}", Byts);

double x = (Convert.ToDouble(Int32.Parse(Hex.ToString(), System.Globalization.NumberStyles.HexNumber)));
Result = (9.418869838535785675048828125 / (x * Exp)).ToString();

  • Hi Hector,
    Your post has been assigned to one of our BMS experts.

    Regards,
    David
  • Hi Hector,
    Here is the pseudo code to convert the raw hex bytes to the CC Gain on the bq20z devices:
    mantissa = (number & 0x7FFFFF) * 2.0^-24 + 0.5
    sign = -1 if number & 0x800000 else 1
    exp = ((number>>24) & 0xFF) - 0x80
    raw_value= 9.419/(sign * 2^exp * mantissa)

    But for 0xEF032205 (Converted to hex from 239, 3, 34, 5)
    Mantissa = (0xEF032205 & 0x7FFFFF) * 2.0^-24 + 0.05 = 205317*2^-24+0.05 = 0.01223+0.5 = 0.51223
    Sign = 1
    Exp = 111
    Raw_value = 9.419/(1.33 * 10^33) = 0

    This value does not seem valid.

    I did check on my EVM, and I get the following results that check out:
    80 71 20 5B
    Mantissa = (0x8071205B & 0x7FFFFF) * 2.0^-24 + 0.05 = 7413851*2^-24+0.5 = 0.4419+0.5 = 0.9419
    Sign = 1
    Exp = 0
    Raw Value = 9.419/(1*2^0*0.9149) = 9.419/0.9419 = 10

    80 48 F0 4C
    Mantissa = (0x8048F04C& 0x7FFFFF) * 2.0^-24 + 0.05 = 4780108*2^-24+0.5 = 0.2849+0.5 = 0.7849
    Sign = 1
    Exp = 0
    Raw Value = 9.419/(1*2^0*0.9149) = 9.419/0.7849 = 12

    Can you please check that youare reading the correct SubClassID (It has to be converted to hex) and offset?
    Regards,
    Swami