MAX17201 read problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-23 3:50 AM
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!
Solved! Go to Solution.
- Labels:
-
STM32L4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-23 4:33 AM
@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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-23 4:01 AM
Please use this button to properly post source code:
@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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-23 4:16 AM
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?!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-23 4:33 AM
@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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-23 5:52 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-23 5:56 AM
@LeventF16 wrote:I have to check again the MAX17201 datasheet.
Indeed!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-23 5:59 AM
Maybe I have to program some battery parameters in the fuel gauge chip.
