Skip to main content
Explorer II
February 23, 2024
Solved

MAX17201 read problem.

  • February 23, 2024
  • 2 replies
  • 1955 views

Hello.

We are trying to read measured voltage by MAX17201 chip - register 0x09.

But we are receiving incorrect value - 0x936A when battery voltage is 3.0V?!

We are using I2C communication protocol.

Here is the I2C initialization:

static void MX_I2C1_Init(void)
{

/* USER CODE BEGIN I2C1_Init 0 */

/* USER CODE END I2C1_Init 0 */

/* USER CODE BEGIN I2C1_Init 1 */

/* USER CODE END I2C1_Init 1 */
hi2c1.Instance = I2C1;
hi2c1.Init.Timing = 0x00707CBB;
hi2c1.Init.OwnAddress1 = 216;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
Error_Handler();
}

/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}

/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN I2C1_Init 2 */

/* USER CODE END I2C1_Init 2 */

}

 

And we are reading the fuel gauge chip like this:

uint8_t pFGRData[10]={0};

HAL_I2C_Mem_Read(&hi2c1, 0x6C, 0x09, 1, pFGRData, 2, 1000);

 

Would you please help.

Thank you!

    This topic has been closed for replies.
    Best answer by Andrew Neil

    @LeventF16 wrote:

    0x936A when battery voltage is 3.0V?!



    @LeventF16 wrote:

    For 3.6V we are getting 0xB140?!


    If you get 0x936A at 3.0V, then 0xB140 is to be expected at 3.6V !

    2 replies

    Super User
    February 23, 2024

    Please use this button to properly post source code:

    AndrewNeil_0-1708689497836.png

     


    @LeventF16 wrote:

    we are receiving incorrect value - 0x936A when battery voltage is 3.0V?!ou!


    First thing to check is that the voltage at the ADC input is actually 3.0V.

    You need to check with an oscilloscope to be sure that there's no noise on it.

    If you change the voltage, does the reading change correspondingly?

     

    LeventF16Author
    Explorer II
    February 23, 2024

    Hi Andrew!

    Yes we have 3.0V at ADC input and there isn't noise.

    Also if we change the voltage value of the voltage register changes.

    For 3.6V we are getting 0xB140?!

     

    Super User
    February 23, 2024

    @LeventF16 wrote:

    0x936A when battery voltage is 3.0V?!



    @LeventF16 wrote:

    For 3.6V we are getting 0xB140?!


    If you get 0x936A at 3.0V, then 0xB140 is to be expected at 3.6V !

    LeventF16Author
    Explorer II
    February 23, 2024

    Maybe I have to program some battery parameters in the fuel gauge chip.