2016-10-20 11:30 PM
Hi,
I have a STM32F4 which is powered by a smart battery. I would like to read the remaining capacity (AbsoluteStateOfCharge, RelativeStateOfCharge). I am not able to figure out, how I have to configure I2C so that I can communicate with the smart battery. My latest attempt was to read the device name, but I do not know how many bytes I am expecting.hal_status = HAL_I2C_Mem_Read(&hi2c1, 0x0B, 0x21, I2C_MEMADD_SIZE_8BIT, (uint8_t*) my_device_name, 5, 100);
Device Address: 0x0B - SMBus specificationMem Address: 0x21 - Device NameThe I2C interface is configured like this:void MX_I2C1_Init(void){ hi2c1.Instance = I2C1; hi2c1.Init.ClockSpeed = 100000; hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; hi2c1.Init.OwnAddress1 = 0x08; hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; hi2c1.Init.OwnAddress2 = 0; hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; if (HAL_I2C_Init(&hi2c1) != HAL_OK) { Error_Handler(); }}I am not sure, if this is correct at all. Can anyone tell, if I am the right track? Or has anyone a working example? I am really lost, right now.Thanks in advance.2016-10-25 12:58 AM
Can anyone recommend another forum, where this topic is more suitable?
2016-10-25 07:52 AM
what smart battery are you using ?
(the chip I mean!)2016-11-23 05:17 AM
It is a National Power battery. The battery's name is NPC SM203-3.2 (Part Number 3SA72A06111BXSR)
The specification refers to this chip: http://www.ti.com/product/BQ20Z95