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.

Compiler/BQ20Z95: Read Data Flash

Part Number: BQ20Z95
Other Parts Discussed in Thread: EV2400

Tool/software: TI C/C++ Compiler

Hi,

I use a microcontroller (arduino uno) for communicated with BQ20z95.

I would like read Device Name using read data flash, not with Standard SBS Commands. Because after i want change the device name and other data like SubClass 49 (BQ20Z95_DATA_FLASH_SUB_CLASS_CONFIGURATION) accessible only by data flash.

I following the datasheet instruction about how to reading data flash, but i have problems when i want reading the second page, the data are not correct because i don't have name of device and the other data contained in 2nd page.

I reading the 2nd page immediately after have reading the 1st page. But it's strange because when a reading only the 2nd page i have the same data for 2nd page that when i read the both.

Can you send me instruction with more detail for read write data flash ? Or code example in C ?

Read complete SBS Configuration Data subclass (SubclassID =48) into RAM:
· Write Subclass ID
– SMB Slave Address (0x16)
– SMB CMD 0x77 (BQ20Z95_DATA_FLASH_SUB_CLASS_ID) with 0x0030 (BQ20Z95_DATA_FLASH_SUB_CLASS_DATA) as data
· Read Subclass (2 blocks are needed as its over 32 bytes long)
– SMBSlave Address (0x16)
– SMB CMD 0x78 (BQ20Z95_DATA_FLASH_SUB_CLASS_PAGE_1) receiving 32 bytes of data
– SMB CMD 0x79 (BQ20Z95_DATA_FLASH_SUB_CLASS_PAGE_2) receiving 32 bytes of data

My reading program data:

09:58:19.822 -> BQ found
09:58:19.822 -> Unlock Gauge
09:58:19.875 -> Operation Status: 0xC441              => (Read with Standard SBS Commands)
09:58:20.823 -> Device Name:  E013RK                 => (Read with Standard SBS Commands)
09:58:21.827 -> Manufacturer Name:  EONEMOLI => (Read with Standard SBS Commands)
09:58:21.880 -> Voltage: 11320                                  => (Read with Standard SBS Commands)
09:58:21.880 -> Battery Mode: 0x1                             => (Read with Standard SBS Commands)
09:58:21.927 -> Serial Number: 0x650                     => (Read with Standard SBS Commands)
09:58:21.927 -> Battery Status: 1,0xC7                     => (Read with Standard SBS Commands)
09:58:21.980 -> Safety Status: 0x0                             => (Read with Standard SBS Commands)
09:58:22.930 -> Device Name: Page 1:0x20 0x62 0x2B81 0x4F31 0x50 0x5A6C 0x2178 0x4F45
09:58:22.983 ->                            Page 2:0x0 0xFFFFB4B4 0xFFFFB4B4 0xFFFFB4B4 0xFFFFB4B4 0xFFFFB4B4 0xFFFFB4B4 0xFFFFB4B4
09:58:23.084 -> Lock Gauge 
09:58:23.131 -> Operation Status: 0xE441

Thanks.

  • Hi, Jeremy

    Below is my I2C command sequence to read the data from sbs configuration data in subclass ID 0x30, the commands just work fine as expected. Please try to capture the I2C transaction at your side see what actually has been sent by the host

  • Where is your "I2C command sequence to read the data from sbs configuration data in subclass ID 0x30" ?

    It's my code for read a page (32bytes block):

    First i call my function : writeWord16bits(0x77, 0x30);

    After i call my function : readNBytes(0x78, data_page1, 32);

    Finish i recall my function : readNBytes(0x79, data_page2, 32);

    bool BQ20Z95::writeWord16bits(uint8_t aFunction, uint16_t aValue)
    {
        Wire.beginTransmission(i2cAddress);
        Wire.write(aFunction);
        Wire.write(aValue & 0xFF);
        Wire.write((aValue >> 8) & 0xFF);
        if(Wire.endTransmission()== 0){
          return true;
        }else {
          return false;
        }   
    }

    bool BQ20Z95::readNBytes(uint8_t cmdAddress, uint8_t *value, uint16_t length)
    {
      bool state = false;
      Wire.beginTransmission(i2cAddress);
      Wire.write(cmdAddress);
      if (Wire.endTransmission() == 0)
      {
          Wire.requestFrom(i2cAddress, length);
          if (Wire.available() >= length)
          {
              for (int i = 0; i < length; i++)
              {
                  value[i] = Wire.read();
              }
              state = true;
          }
      }
      return state;
    }

    I resend you my data result, i have trying to read a other subclass but it didn't work. It's very strange, i get the 1st page of subclass 48 without problem, but i don't get the other page.

    14:51:10.130 -> BQ found
    14:51:10.130 -> Unlock Gauge 1,
    14:51:10.183 -> Operation Status: 1,0xC441
    14:51:11.131 -> Device Name: 1, E013RK
    14:51:12.133 -> Manufacturer Name: 1, EONEMOLI
    14:51:12.186 -> Voltage: 1, 11317
    14:51:12.186 -> Battery Mode: 1,0x1
    14:51:12.233 -> Serial Number: 1,0x650
    14:51:12.233 -> Battery Status: 1,0xC7
    14:51:12.286 -> Safety Status: 1,0x0
    14:51:13.236 -> Subclass 48: 1,
    14:51:13.289 -> Page 1: ,0x20 0x362 0xA 0x81 0x2B5C 0x31 0x4F8A 0x650 0x1 0x1B6C 0x5A64 0x1E78 0x21D2 0x845 0x4F4E 0x454D
    14:51:13.390 -> Page 2: ,0xEBC 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4
    14:51:14.440 -> Subclass 49: 1,
    14:51:14.493 -> Page 1: ,0xEBC 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4 0xB4B4
    14:51:14.740 -> Lock Gauge 1,
    14:51:14.794 -> Operation Status: 1,0xE441

  • Hi, Jeremy

        There might be something wrong with copy paste function for picture, I copy the text information below for your reference:

    # Total Phase Data Center(tm) v6.73
    # (c) 2005-2017 Total Phase, Inc.
    # www.totalphase.com
    #
    #
    #
    # Level,Index,m:s.ms.us,Dur,Len,Err,S/P,Addr,Record,Data,ASCII
    0,0,0:00.000.000,,,,,,Capture started,[08/28/20 14:59:55],
    0,1,0:11.262.480,589.200 us,4 B,,SP,0B,Write Transaction,77 30 00 9B,w0..
    0,2,0:15.831.115,258.000 us,1 B,,S,0B,Write Transaction,78,x
    0,3,0:15.831.373,4.223.400 ms,34 B,,SP,0B,Read Transaction,20 02 94 01 DB 00 0F 00 81 1C 20 00 31 50 BB 04 D2 00 00 14 A0 5A 64 19 C8 12 90 04 61 61 61 61 73 88*, ......... .1P.......Zd.
    0,4,0:22.081.056,257.800 us,1 B,,S,0B,Write Transaction,79,y
    0,5,0:22.081.314,4.203.100 ms,34 B,,SP,0B,Read Transaction,20 20 49 6E 73 74 72 75 6D 65 6E 74 73 20 20 20 04 62 62 62 62 37 30 50 20 20 20 20 20 20 20 20 20 4F*,  Instruments   .bbbb70P
    0,6,0:56.978.829,,,,,,Capture stopped,[08/28/20 15:00:52],

       Please can you capture your I2C transaction with oscilloscope or logic analyzer or protocol analyzer like beagle, and compare if the content of I2C transactions aligns with above sequence

  • Now I can read 1st page and 2nd page because i write 0x9B after 0x77 0x30 0x00. What is the value 0x9B ? Because it's not indicated in datasheet...

    I sniff a frame from another subclass and this value is different. How do I know what is the value for each subclass?

    Thanks

  • Do you have the same example but for write data flash ?

    Thanks.

  • Hi,

    I try to write the new value for subclass 48 (2nd pages for device name) but it doesn't work. It's an obligation to calculate the PEC (CRC-8) and send it at the final of frame ?

    Can you send me a example with details ?

    I send you a excel with frame when I change the device name with a EV2400 and with my microcontroller.BQ20Z95_I2C_SMBus_Write_Parameter_1.xlsx

  • Hi, Jeremy

        PEC should be able to disabled by setting HPE bit to 0, have you tried to do so see if this works?

        For details and example of the usage of PEC, you can refer to SMBUS protocol