cancel
Showing results for 
Search instead for 
Did you mean: 

MAX17201 read problem.

LeventF16
Associate II

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!

1 ACCEPTED SOLUTION

Accepted Solutions

@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 !

View solution in original post

6 REPLIES 6
Andrew Neil
Evangelist III

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?

 

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?!

 


@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 !

Yes the ratio between values and voltages are the same :)

I expected to receive for 3.0 volts 0xBB8 (3000 decimal).

I have to check again the MAX17201 datasheet.

 


@LeventF16 wrote:

I have to check again the MAX17201 datasheet.


Indeed!

LeventF16
Associate II

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