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.

BQ76952: Unable to change the values of the Data memory

Part Number: BQ76952
Other Parts Discussed in Thread: BQ34Z100, MSP430FR2155

Tool/software:

Hello TI experts!

I am working on a custom designed PCB consisting of MSP430FR2155, BQ76952 and BQ34Z100. I am trying to access the data memory registers, where I am Bale to read the data from the registers but when i try to write to the registers it is not working. I took the code from the BQ799x2 example codes on TI website. I have followed the steps as mentioned in the BQ76952 TRM for accessing the data memory in the section 13.1. I will upload the codes that I am using and the screenshots of the logic analyzer as well. Could you please guide me with what could be done here? 

Thanks in advance! Have a great day :)

    // main program
    CommandSubcommands(SET_CFGUPDATE);
    BQ76952_write(monitor, EnabledProtectionsA, 0x8C, 1);
    delayUS(50000);
    rx_arr = BQ76952_readDMA(monitor, EnabledProtectionsA, 1);
    tx_arr[6] = rx_arr[0];
    tx_arr[7] = rx_arr[1];
    CommandSubcommands(EXIT_CFGUPDATE);
    
    // source code
    int BQ76952_write(unsigned char Slave_address, uint16_t reg_addr, uint16_t data, int len)
{
    unsigned int sentbyte = 0;
        uint8_t TX_Buffer[3] = {0x00, 0x00, 0x00};
        uint8_t TX_RegData[7] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
       TX_RegData[0] = 0x3E;
       TX_RegData[1] = reg_addr & 0xff;
       TX_RegData[2] = (reg_addr >> 8) & 0xff;
       TX_RegData[3] = data & 0xff; //1st byte of data
       switch(len)
       {
           case 1: //1 byte datalength
               I2CSendBytes(Slave_address, TX_RegData, 4, &sentbyte);
               delayUS(2000);
               TX_Buffer[0] = 0x60;
               TX_Buffer[1] = Checksum(TX_RegData, 4);
               TX_Buffer[2] = 0x06; //combined length of register address and data
               I2CSendBytes(Slave_address, TX_Buffer, 3, &sentbyte); // Write the checksum and length
               delayUS(2000);
               break;
           case 2: //2 byte datalength
               TX_RegData[4] = (data >> 8) & 0xff;
               I2CSendBytes(Slave_address, TX_RegData, 5, &sentbyte);
               delayUS(2000);
               TX_Buffer[0] = 0x60;
               TX_Buffer[1] = Checksum(TX_RegData, 5);
               TX_Buffer[2] = 0x07; //combined length of register address and data
               I2CSendBytes(Slave_address, TX_Buffer, 3, &sentbyte); // Write the checksum and length
               delayUS(2000);
               break;
       }
       return 0;
}

unsigned char* BQ76952_readDMA(unsigned char Slave_address, uint16_t reg_addr, int len)
{
       unsigned int sentbyte = 0;
       unsigned int count = 0;
       static unsigned char RX_Buffer[3] = {0x00, 0x00, 0x00};
       uint8_t TX_RegData[7] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
       TX_RegData[0] = 0x3E;
       TX_RegData[1] = reg_addr & 0xff;
       TX_RegData[2] = (reg_addr >> 8) & 0xff;
       switch(len)
       {
           case 1: //1 byte datalength
               I2CSendBytes(Slave_address, TX_RegData, 3, &sentbyte);
               delayUS(2000);
               I2CReadBytes(Slave_address, RX_Buffer, len, &count);
               delayUS(2000);
               break;
           case 2: //2 byte datalength
               I2CSendBytes(Slave_address, TX_RegData, 3, &sentbyte);
               delayUS(2000);
               I2CReadBytes(Slave_address, RX_Buffer, len, &count);
               delayUS(2000);
               break;
       }
       return RX_Buffer;
}

unsigned char Checksum(unsigned char *ptr, unsigned char len)
// Calculates the checksum when writing to a RAM register. The checksum is the inverse of the sum of the bytes.
{
    unsigned char i;
    unsigned char checksum = 0;

    for(i=0; i<len; i++)
        checksum += ptr[i];

    checksum = 0xff & ~checksum;

    return(checksum);
}

entering CONFIG_UPDATE mode: 

Data write : 

Checksum : 

Data read : 

exit config_update :