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.

BQ34Z100-G1: 1st byte is always zero while reading the dataclass

Part Number: BQ34Z100-G1
Other Parts Discussed in Thread: BQ34Z100

Hi Team,

I am working on BQ34Z100-G1 EVM board interfaced iver an I2C with STM32 uC. In the code of read dataclass I am finding a problem. The 1st byte is coming as '0' always. The same I also observed on the physical layer over oscilloscope.

Following is the code of read dataclass,

#define BQ34Z100_ADDR 0xAA

#define SET_CFGUPDATE 0x0013
#define CFGUPD 0x0010

#define CMD_BLK_DATA_CNTRL 0x61
#define CMD_DATA_FLASH_CLASS 0x3E
#define CMD_DATA_FLASH_BLOCK 0x3F
#define CMD_BLOCK_DATA 0x40
#define CMD_CHECK_SUM 0x60
#define CMD_FLAGS 0x06

static int bq34z100_read_data_class(unsigned char nDataClass, unsigned char *pData, unsigned char nLength)
{
unsigned char nRemainder = nLength;
unsigned char nDataBlock = 0x00;

if (nLength < 1) return 0;

do
{
nLength = nRemainder;
if (nLength > 32)
{
nRemainder = nLength - 32;
nLength = 32;
}
else nRemainder = 0;

//nData = (nDataBlock << 8) | nDataClass;
bq34z100_cmd_write(CMD_BLK_DATA_CNTRL, 0x00U); //Enable Flash x’fer command
bq34z100_cmd_write(CMD_DATA_FLASH_CLASS, nDataClass); //SubClass address
bq34z100_cmd_write(CMD_DATA_FLASH_BLOCK, nDataBlock); //Enable General Purpose Block and its pages
osDelay(200);

if(I2c3_Read(BQ34Z100_ADDR,CMD_BLOCK_DATA, 1,pData, nLength) != 0x01U) // RD or WR Operation OK
return -1;
osDelay(200);
pData += nLength;
nDataBlock++;
} while (nRemainder > 0);

return 0;
}

static unsigned int bq34z100_cmd_write(unsigned char nCmd, unsigned int nData)
{
unsigned char pData[2];

pData[0] = nData & 0xFF;
pData[1] = (nData >> 8) & 0xFF;

return I2c3_Write(BQ34Z100_ADDR, nCmd, 1, pData, 2);
}