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.

BQ40Z80: DataFlashAccess issue

Part Number: BQ40Z80

Hi,

I'm trying to access the data flash memory of the BQ40Z80 via SMBus. In order to do so I'm referring to the Technical Reference Manual (rev.C) page 146-147. This is what I've found for the data flash access memory:

I'd want to get information from the register 0x4CE9 (Temperature Threshold), thus I wrote the following code: 

#include <Wire.h>

const uint8_t deviceAddress = 0x0B;
const uint16_t startingAddress = 0x4CE9; // Replace with the desired starting address
const uint8_t manufacturerBlockAccess = 0x44;  // Manufacturer Block Access command

void setup() {
  Wire.begin();        // Initialize SMBus communication
  Serial.begin(9600);  // Initialize serial communication
}

void loop() {
  // Send SMBus block write with ManufacturerBlockAccess() and the starting address
  // Format: ManufacturerBlockAccess() + Starting Address (little endian)
  uint8_t writeData[3];
  writeData[0] = manufacturerBlockAccess;
  writeData[1] = startingAddress & 0xFF;        // Low byte of starting address
  writeData[2] = (startingAddress >> 8) & 0xFF; // High byte of starting address

  // Start the transmission
  Wire.beginTransmission(deviceAddress);

  // Send the write data
  Wire.write(writeData, 3);

  // End the transmission
  Wire.endTransmission();

  // Delay to allow time for the device to process the write operation
  delay(10);

  // Send SMBus block read with ManufacturerBlockAccess()
  // Format: ManufacturerBlockAccess()
  Wire.beginTransmission(deviceAddress);

  // Send the read command
  Wire.write(manufacturerBlockAccess);

  // End the transmission
  Wire.endTransmission();

  // Request data block from the SMBus device (32 bytes)
  Wire.requestFrom(deviceAddress, 34); // Include two extra bytes for the starting address

  // Check if data is available to read
  if (Wire.available() >= 34) {
    // Read and process the received data
    uint8_t receivedData[34];
    for (int i = 0; i < 34; i++) {
      receivedData[i] = Wire.read();
    }

    // Combine the low and high bytes for the starting address (little endian)
    uint16_t receivedStartingAddress = (uint16_t(receivedData[2]) << 8) | receivedData[1];

    Serial.println("Received Data:");
    Serial.print("Starting Address: 0x");
    Serial.println(receivedStartingAddress, HEX);

    // Print the 32 bytes of DF data
    for (int i = 3; i < 33; i++) {
      Serial.print("Data");
      Serial.print(i - 2);
      Serial.print(": 0x");
      Serial.println(receivedData[i], HEX);
    }
  }

  delay(1000); // Wait for a moment before performing the next operation
}
During the writing, the device doesn't acknowledges maybe because I misinterpreted the procedure. Can you please examine the code and tell me if anything is wrong on how I'm asking informations to the BQ40Z80?
  • Hi Luigi,

    We do not read code. Instead please try this sequence. 

    1- SMB_write_block (device address, command, length)

    2- SMB_read_block (device address, command, length)


    Device address = 0x17
    command = 0x44
    length = it depends, for writing 2 bytes. For reading 34 bytes is the whole block.

    See below an example.


    Regards,
    Jose Couso