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.

BQ20z80 VB function WriteDataFlashImageFromFile()

Other Parts Discussed in Thread: BQ20Z80

Hello,

I am working on VB code to write data flash Image to my battery. (See slua380 page 220)

2021.slua380-Ap Book BQ20z80.pdf

That function work fine, thanks for your exemple.

During fabrication, my circuit is calibrate so, my question is: Does it possible to modify this vb code to write all data flash Image without calibration data ?

If I skip calibration index I think it will work. Do you have the distribution of all index ?

Regards

  • Unfortunately, you would need to know the physical location of the calibration data to do this and we don't have access to this. I believe the next generation of gauges will allow this to be done, but for the current generation it isn't possible.

  • Ok

    Do you have an other solution to write all data flash Image without calibration data ?

    Maybe I can use bq Evaluation Software function to read and save dataflash into .gg file. Can you provide me that function ?


    Regards

  • This is not an option for the current products because we don't know the physical address of the calibration data.

    The gg file approach will not work because gg file only contain the public data.

    However, you can save the original calibration data , do a DFI programming, follow by rewriting the calibration data.

    To write the calibration data, follow the device TRM, appendix C, to rewrite the calibration data under subclass ID 104

     

  • Hello Jackie

    What is device TRM ?

    And in wich document can I find appendix C ? 

    Do you have VB code exemple to read and write only calibration data ?

    Regards

  • Appendix C can be found in the device Technical Reference Manual (TRM): http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sluu276&fileType=pdf

    You should find an example in this location.

    Regards,

    Viktoriya

  • Thanks

    So DFI programming (from golden pack)  will juste change the original calibration data ?

    Do I need to save more with "calibration Config",  "calibration Temp Model" or  "calibration Current" ?

    Regards

     

  • No, DFI programming will rewrite everything but you can save the original calibration data , do a DFI programming, get the gg file, rewrite calibration data to the gg file, and program the gg file.

    I'm not sure what you mean by saving with "calibration Config",  "calibration Temp Model" or  "calibration Current" but the above method will copy all of the calibration data into the gauge.

    Regards,

    Viktoriya

  • At this time my code reads calibration data, program DFI and rewrites calibration data. It seems to work.

    I am quit sur that calibration function ( current, voltage temperature, offset calibration...) will just change calibration data so I dont need to get the gg file.

    am I right ?

    Regards,

    Dimitri

     

     

     

  • Yes, that is correct.

    If your DFI file already has an updated Qmax, chemistry and configuration, and if your function only updates the calibration data then you will not need to get the gg file.

    Regards,

    Viktoriya

  • Ok thanks,

    Can you provide me "bq80xRW help.zip”. I think it will be helpful for programming in VB.

    Regards

  • Also, I have a big problem for programming the DFI file. I have a few BQ20z95 and BQ20z80 who seems to not working after writing the DFI file. You can see my code above:

    Private Function WriteDataFlashImageFromFileBQ20z80() As Long
    Dim lError As Long
    Dim sFilename As String
    Dim iFileNumber As Integer
    Dim iNumberOfRows As Integer
    Dim iRow As Integer
    Dim iIndex As Integer
    Dim yRowData(32) As Byte
    Dim yDataFlashImage(&H700) As Byte

    'check file
    Start:
    sFilename = frmMainS.CommonDialogCalib.FileName
    If sFilename = "" Then GoTo NoFile

    '// READ THE FLASH IMAGE FROM THE FILE INTO A BYTE ARRAY
    iFileNumber = FreeFile
    Open sFilename For Binary Access Read As #iFileNumber
    Get #iFileNumber, , yDataFlashImage
    Close #iFileNumber
    '// FOR CLARITY, WITHOUT USING CONSTANTS
    '// 0x700 is the data flash size for bq8024-based devices (eg: bq20z80). 0x700 \ 32 = 56 rows
    iNumberOfRows = &H700 \ 32
    '// PUT DEVICE INTO ROM MODE
    lError = modComm.WriteSMBusWord_(&H0, &HF00)
    DoDelayms 10 '10 millisecondes
    '// ERASE AND WRITE EACH ROW
    For iRow = 0 To iNumberOfRows - 1
    '// Set the row to program
    yRowData(0) = iRow
    '// Copy data from the full array to the row array
    For iIndex = 0 To 31
    yRowData(iIndex + 1) = yDataFlashImage((iRow * 32) + iIndex)
    Next iIndex
    '// Erase the row
    lError = WriteSMBusWord_(&H11, iRow)
    DoDelayms 10
    '// Write the row. Length is 33 because the first byte is the row number
    lError = WriteSMBusBlock(&H10, yRowData, 32 + 1)
    DoDelayms 10
    Next iRow
    '// EXECUTE GAS GAUGE PROGRAM
    lError = WriteSMBusCommand(&H8)

    Exit Function

    This code come from slu 380 page 220. I am using it with Bq20z80 demo board and after send the  WriteDataFlashImageFromFileBQ20z80() function, my demo board dont responding to SMbus command. Also I can not send current (FETs are open) So I am totaly stuck. I think the BQ20z80 is in BootROM mode so it can not communicate.

    Before test my code I try to write DFI file with bq Evaluation Software and it works fine.


    I make comparaison between WriteDataFlashImageFromFileBQ20z80()  function and BqEASY. I use a USB spy to see flow of data which pass into EV2300 and It looks like program Dataflash Image with BqEASY send more data before and after send DFI file, so I am wondering what I need to add to my code for avoid the break of BQ20z80. Do you have the code of Evaluation Software?

    Do you have a solution to repair my demo board Bq20z80 and my other BQ20z95 board ?

    Thanks for your Help

  • The extra communication is for the EV2300. It will just resend the command. This code is not in the app note because it applies to the EV2300 and not other forms of communication. If you are using the EV2300 you may need to add the resend into your code.

    Here is a folder that includes the EV2300 example code and help.

    0830.EV2300 Customer Kit.zip

    Regards,

    Viktoriya

  • Thanks,

    I have already a lot of VB code from BQ Tester. In the "VB6p0 Example using the EV2300 v1p0.pdf" they talk about "bq80xRW.ocx" which come from "bq80xRW help.zip", but I do not find it ?

    Also I have an other BQ20z80 demo board who cannot communicate now. I have programmed the DFI file with the EVSW. After programming, all Led was on. (May be bad programming ?)

    It's seems that programming DFI file it's realy not safe for the BQ and must be improved. Or may be I am doing it in the wrong way.  

    I need to use write DFI file function in my production flow, so today I am blocked, and I don't realy know how to resolve this.

  • The bq80xRW.ocx is installed when EV2300 driver is installed. You can find it under windows/TI directory.

     

    First of all, we should confirm the DFI is correctly generated.

    How did you create the DFI file? By bqEASY or with your own software? If it was generated by your software, was there a read verify routine to confirm the DFI was correctly created?

     

    Secondly, we should confirm the DFI is correctly programmed.

    Again, was there a read verify routine to confirm the correctly data was programmed?

    You also have to make sure that the version of the DFI matches with the FW. For example, you cannot program a DFI generated from v1.0 to a device with FW v1.02 in it. Sometimes the device can be recovered from it, but most of the time, the device locks up and it cannot be used anymore.

     

    A stable power source is also required during DFI programming. If the programming is disturbed, you should keep the device in ROM mode (DO NOT turn off power), and re-program.

  • Hello,

    First of all, we should confirm the DFI is correctly generated:

    I created the DFI file with bqEASY from the same BQ20z80 demo board

    Secondly, we should confirm the DFI is correctly programme:

    I think the problem comming from writing,

    I use my own software for writing. It use the function from the app book (slua380a page 220). The code exemple did not containe read verify routine.

    I use a stable power supply

    You can see that thread which speak about the same problem:

    http://e2e.ti.com/support/power_management/battery_management/f/180/p/115023/414139.aspx#414139

    thanks for your time

  • You can refer to the read DFI sample code. To implement the read verify:

    1. After writing the DFI to the device

    2. Keep the device in ROM mode (i.e. Do not send SMB command 0x08)

    3. Refer to the read DFI sample code to read the DFI image from the device

    You can either compare each row you read from the device against the DFI file you used for programming. Or read the entire DFI from the device and then compare against the file you have.

    To write data to flash memory, it needs to be erased first. You can also implement a read verify after you erase each row to make sure the data is 0xFF. This will help you to debug which step is causing a problem.

     

  • ReadSMBusBlock can't read any datas why?

    Public Function ReadSMBusBlock(ByVal ySubCommand As Byte, sResponse As String) As Long
        Dim lerror As Long
        Dim Data(128) As Byte
        Dim nLen As Integer
        Dim SubCmd As Integer
        SubCmd = ySubCommand
        'To call ReadSMBusBlock() we need a pointer to variant containing array of bytes
        'So assign an array of bytes to variant v and use v as argument to the call
        Dim v As Variant
        v = Data
        sResponse = ""
        nLen = 2
        lerror = Form1.Bq80xRW1.ReadSMBusBlock(SubCmd, v, nLen, &H17)
        If lerror = 0 Then  'Stick return data into a string
            Dim X As Integer
            For X = 0 To nLen - 1
                'sResponse = sResponse & Chr(v(X)) This will display actual string for mfg name
                Dim tmpStr As String
                tmpStr = Hex$(v(X))
                If Len(tmpStr) < 2 Then
                    tmpStr = "0" & tmpStr
                End If
                sResponse = sResponse & tmpStr
            Next X
        End If
       
    '    ReportCommErrors lError
        ReadSMBusBlock = lerror
    End Function