2020-01-10 01:45 AM
my implementation purpose is,
i have a battery charger module having i2c as communication type and a fuel gauge module having SMBus as communication type. so i need to simultaneously communicate with both the module. so my question is how can i use the same i2c port for both the purpose(use as i2c and SMbus), is that possible or it makes any issues ?
thank you
2020-01-10 08:37 AM
If you are using the ST AN4502 SMBus firmware, then yes, kind of. As long as you limit your I2C-mode transfers to 2 bytes each, the SMBus ReadWord and WriteWord protocols match the I2C ReadData and WriteData sequences, but you have to get the SMBus firmware to put the I2C "memory address" byte in the SMBUs "Command code" field. You cannot do longer I2C transfers like ones where you send an address and then keep writing or reading as much data as you want. That is because the SMBus WriteBlock and ReadBlock formats require a "byte count" parameter that the I2C format doesn't have.
So if you do all of your I2C style access to the battery charger reading/writing 16 bits per transaction, it will work. That is how I manage things in my system.
Another way to deal with this is to use two I2C ports connected to the same bus, one configured as SMBus and one as plain I2C. DIsclaimer - this should work, but I haven't tried it.
2020-01-13 12:38 AM
is this possible with stm32f4 discovery. i downloaded the ST AN4502 SMBus firmware but they tells like they were tested it over few boards and stm32f4 is not in their list.?
2020-01-13 08:39 AM
The AN4502 code uses the standard stm32XXX_hal_smbus and stm32XXX_hal_i2c files, so it *SHOULD* work. However, I don't recall how (or if) the F4xx I2C ports differ from the L4xx I2C ports (I am running on an L476). Try it and find out.