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.

How do I Write the Data Flash of the bq27505?

I'm using the bq27505 Fuel Gauge with an own Evaluation Board.

I can Send Commands and Subcommands and I can read the Flash.

My Problem is, that I can't write the Flash.

There is no internal Error, the Temperature is inside the Ranges, the Voltage is over the Flash Update OK Voltage.

The WAIT_ID Flag is activated. Could this be the failure? What's about the Checksum? Do I have to read out the Checksum?

Could anyone send me an Example how I write the Flash? I'm using following C-Code, existing on a microcontroller:

 

                        /***Activate Flash***/

   i2c_start();                                                               //Send Start Condition

   i2c_write(0xaa);                                                       //Adress from Device, R/W'=0, Writing

   i2c_write(0x61);                                                      //Command to activate Flash

   i2c_write(0x00);                                                      //Command to activate general Flash

   i2c_stop();                                                               //Send Stop Condition

   DelayMs(1);                                                    

                        /***Send Class***/

   i2c_start();                                                               //Send repeated Start

   i2c_write(0xaa);                                                       //Adress from Device, R/W'=0, Writing

   i2c_write(0x3e);                                                      //Command to determine DataFlashClass

   i2c_write(usb_buffer_flwrite[2]);//write specific DataFlashClass

   i2c_stop();                                                               //Send Stop Condition

   DelayMs(1);                                                  

                        /***Send Block Value***/

   i2c_start();                                                               //Send repeated Start

   i2c_write(0xaa);                                                       //Adress from Device, R/W'=0, Writing

   i2c_write(0x3f);                                                       //Command to determine DataFlashBlock

   i2c_write(usb_buffer_flwrite[3]);//write specific DataFlashBlock to BlockData Register

   i2c_stop();                                                               //Send Stop Condition

   DelayMs(1);                                                         

                        /***Access Value in BlockData memory***/

   i2c_start();                                                                           //Send repeated Start

   i2c_write(0xaa);                                                                  //Adress from Device, R/W'=0, Writing

   i2c_write(block_data_flwrite);                      //write DataFlashBlock Offset to Determine Value to be write in BlockData Register

   i2c_stop();                                                                           //Send Stop Condition

   DelayMs(1);                                                         

               /***write Flash Data***/

   i2c_start();                                                                           //Send repeated Start

   i2c_write(0xaa);                                                                  //Adress from Device, R/W'=0, Writing

   i2c_write(usb_buffer_flwrite[6]);       //Write Data to buffer, ACK

   i2c_write(usb_buffer_flwrite[5]);       //Write Data to buffer, NACK

   i2c_stop();                                                                           //Send Stop Condition

 

Thank you and best Regards!

  • While searching my mistake i detected following:

    The Gauge writes the Flash Data to the correct Placeholder in the BlockData(), but he doesn't transfer the new BlockData to the Data Flash.

    I tried to write the correct Checksum of [255-LSByte] to Adress 0x60, but the Gauge doesn't give an ACK. So i think it's a checksum error!?

    Could you please help me?

  • Now I found the answer:

    The problem was the checksum.

    After activating the Flash and determining the correct Block, you have to read out the Checksum and then the Data.

    After that you can write back the Data und write the correct checksum. The correct Checksum is computed as follows:

    old checksum - Differece of LSB old Data and LSB new Data.

     

    May I notice at this point, that the Technical Support of TI wasn't satisfying.

    best regards

  • Glad I found this thread, it gives me a ittle bit of an idea if my I2C code format is correct.  Just started to work with this part.