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.

[BQ77910] Writing Flash data to EEPROM

Other Parts Discussed in Thread: BQ77910A

Hi,

We are using BQ77910 for Protection in one of our projects.

My main query is related to programming/writing the data to EEPROM from the microcontroller.

I followed this flowchart and wrote the code exactly as the flowchart below.

In the below Flowchart, We are reading the data registers for verification 2 times, When i read for the first time i am getting all 10 Bytes of data (with only FIRST Byte missing).

in the second Verification (reading data) I get all random data.

If i reset and read the data, its all 0xFF

The following is the code i am using:

int main(void)
{
	unsigned char UC_NumberOfCells = 0;

    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
    
    // ------------------------------------------------------------------------------------- Fz_Debug
#ifdef DEBUG_MODE
    //ucDCard = MODBUS_DCARD_M; // for testing ModBus
    ucDCard = I2C_DCARD_M;    // for testing I2c
    //ucDCard = UART_DCARD_M;    // for testing UART
#endif // End of Debug Mode
    // ------------------------------------------------------------------------------------- Fz_Debug

    // Initialises the Communication Protocols
    Init_Cards();

    ChangeSOCI2CSpeed(50000); // 50KHz - SOCI2C

    //-------------------------------------BQ77910 Testing--------------------------------------
    char i, BQtest[10] = {0},BQtest2[10] = {0};

    // CHGST and ZEDE Pins on the BQ77910 Need to be HIGH to Write/Read from the IC

	// Enable Ports
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5 ); // Configure CHGST PIN as O/P

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE,GPIO_PIN_3 ); // Configure ZEDE_EN PIN as O/P

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, EEPROM_W_EN ); // Configure EEPROM_W_EN PIN as O/P

	//Set ZEDE and 	CHGST High	(3.3 V ± 5%)
	CHGST_ENABLE_M; // Enable  CHGST PIN
	ZEDE_ENABLE_M; // ENABLE ZEDE_EN

    while (1)
    {
        for (i = 1; i < 0x0B; i++) // Fz !Fz_Mod : z starts from 1
        {
        	//Send I2C commands to set all device configuration registers (0x01–0x0A) to desired values
            Write_SOCI2C_Byte(BQ77910A_ADDRESS, i, bq77910a_data[i-1]); // Fz

            //Wait 10mS
            Delay_ms(10); // Fz
        }

    	// Write 0x62 to EEPROM control register (address 0x0B)
    	Write_SOCI2C_Byte(BQ77910A_ADDRESS, 0x0B,0x62);

    	Delay_ms(10);

    	// Read back and verify all device configuration registers
    	for (i = 1; i < 0x0B; i++)
		{
    		BQtest[i - 1] = Read_SOCI2C_Byte(BQ77910A_ADDRESS, i);

			Delay_ms(10);
		}

    	// Write 0x41 to EEPROM control register (address 0x0B)
    	Write_SOCI2C_Byte(BQ77910A_ADDRESS, 0x0B,0x41);

    	//Wait 1 ms
    	Delay_ms(1);

    	//Set EEPROM pin HIGH
    	EEPROM_W_ENABLE_M;

    	//Wait 16 ms
    	Delay_ms(16);

    	//Set EEPROM pin HIGH
    	EEPROM_W_DISABLE_M;

    	//Wait 1 ms
    	Delay_ms(1);

    	//Write 0x00 to EEPROM control register (address 0x0B)
    	Write_SOCI2C_Byte(BQ77910A_ADDRESS, 0x0B,0x00);

    	// Read back and verify all device configuration registers
    	for (i = 1; i < 0x0B; i++)
		{
    		BQtest2[i - 1] = Read_SOCI2C_Byte(BQ77910A_ADDRESS, i);

			Delay_ms(10);
		}

    	//Set ZEDE and 	CHGST LOW
    	CHGST_DISABLE_M; 	// Disable  CHGST PIN
    	ZEDE_DISABLE_M; 	// Disable ZEDE_EN
    }
}

  • Anyone ?

    Please help me, i am running out of time and have been trying this for 2 days without any improvement.

  • I don't recognize a problem in the code.  if you are reading all FF after reset, it seems you must be initiating the programming. Suggestions:

    Be sure the ground path is good between the microcontroller and bq77910A boards.

    Be sure all IC pins are properly connected, particularly the VSSn, GND, BAT, VREG and the control signals used for programming.  Be sure the VREG capacitor is present

    Look at the I2C signals with an oscilloscope to verify the clock rate is staying < 50kHz and that the device is acking.  Be sure the signals have good edges and levels at the board/IC.

    Be sure CHGST stays high during the process and ZEDE stays high during the communication.

    Be sure the power supply voltage stays high and VREG stays on and stable during the process.

    Be sure the EEPROM voltage goes and stays high (14 +/- 0.5V) during the commanded time and is low (~ 0V)otherwise.

    None of the conditions you describe seem normal: the missing byte on the first read, the random data or the all FF. 

    Try a different part. The part may have been damaged by the unsuccessful attempts, you may need to replace the device.  You might try a much lower I2C clock to see if the results are different.

    If you have the TI EVM and programming adapter, you might make comparative measurements with a scope.  Be aware though that the TI evaluation software may not follow the flowchart exactly.  For example it toggles ZEDE with each communication rather than holding it low for the process.  It also may not read back the data after it is first written.

  • Thank you very much for a very detailed response.

    That was very helpful.

    WM5295 said:

    Be sure the EEPROM voltage goes and stays high (14 +/- 0.5V) during the commanded time and is low (~ 0V)otherwise.

    This happens to be the problem. I checked with the scope if the EEPROM Signal was going High or not, But i didnt check the Voltage level at the BQ side. Now that i have verified, I notice that the Signal on the BQ side is not toggling.

    Corrected now and working as expected.

    However the problem of FIRST Byte missing is still there. its kind of random. Some times it reads correct some times its 00. i tried changing delay, but no luck.

    WM5295 said:

    If you have the TI EVM and programming adapter, you might make comparative measurements with a scope.  Be aware though that the TI evaluation software may not follow the flowchart exactly.  For example it toggles ZEDE with each communication rather than holding it low for the process.  It also may not read back the data after it is first written.

    I do have the Evaluation Board, and i almost wasted the whole day trying to make it work. It just doesnt get detected.

    I am not getting 3.2v at the VREG pin on the Evaluation Board. I replaced the CHIP on the Evaluation board but still not getting the Voltage.

    Once again thank you .

     

  • Glad that helped.  I don't know why reading the first byte would be different.  If you read 00 it must be NACKing and sending data. You do want the first byte to be reliable for your programming.  Timing is the most obvious influence.  The logic should respond in 10's of us, so a 1 ms delay should be adequate.  The command to read delay with USB from the PC and programming adapter are likely much longer than with a microcontroller.  Adding longer delay there seems reasonable.  The 16ms programming time should not likely be adjusted.

    The EVM difficulty is unfortunate.  With power (BAT pin from PACK+ terminal) and CHGST, the VREG should come on.  There is a series resistor between CHGCTL terminal and CHGST pin which makes an 0.91 voltage divider and must usually be supplemented with an external resistor to keep the power down in the resistors. If it is useful to persue the EVM use further you might check that the resistors are not open and the trace is not damaged..