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.
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 :
Hello,
Your check some seems to be a little off it should look like this:
Best regards,
Thomas Rainey
Hello Thomas, Thank you for your response.
Yes I do know the checksum seems to be the issue. Could you please check the checksum function in the code that I have attached and let me know if there is an issue with the code?
Thanks in advance
Hello,
Could you try using the function in the example code? Located on the product page: https://www.ti.com/product/BQ76952
Best regards,
Thomas Rainey
Hello Thomas,
I went through my code once again and there was a small mistake with the checksum part. I did the changes accordingly and ran the code. But still the data memory parameters aren't being changed
I am attaching the logic analyzer screenshots of the same.
Writing the data memory parameter:
Reading the data memory parameter while in CONFIG_UPDATEMODE :
Reading the data memory parameter after exiting the CONFIG_UPDATEMODE :
Hello,
Your writing data memory looks good.
I noticed when you are reading you are missing this section:
You need to write to address 0x40 before reading.
Best regards,
Thomas Rainey