cancel
Showing results for 
Search instead for 
Did you mean: 

SMBUS

A3
Associate III

I am using STM32F779NI for my project. The end device works on SMBUS. Does using I2C HAL for driver development instead of SMBUS HAL will work??

If not, are there any example code for SMBUS, share a link if there is any?

  •  

3 REPLIES 3
Bob S
Principal

Why would you want to use the I2C HAL driver instead of the SMBus HAL driver? Or am I mis-reading your post? If you start with the I2C driver, you will need to add the SMBus-specific register settings, which the SMBus HAL driver already does.

There is also app note AN4502 that attempts to provide the entire SMBus host and slave framework. It works, mostly. I'm working through what appear to be a couple of issues with the code. The drawback (for my application) is that, like all the other ST HAL code, everything happens in the interrupt routines. If you need to stretch the clock to delay an ACK/NAK while you do something time consuming, you hold off further interrupts (of equal or lesser priority).

A3
Associate III

Thanks for the reply @Bob S​ 

There are two other I2C devices on the same bus i.e. I2C3. And I want to connect this SMBUS device on I2C3 as well.

Bob S
Principal

I am running an I2C device on the same SMBus as the SMBus devices, and some of my SMBus devices also support (require) I2C style commands to access some registers (fuel gauge ICs). Using the ST AN4502 SMBUS STACK functions, it is possible to get *SOME* I2C traffic. So far all I've done is I2C read/write byte or read/write word. And it takes a little effort to make it work. I haven't figured out (or needed, yet) how to do longer I2C write operations (other than breaking them up into a series of "word" transactions).

The SMBUS STACK stucture contains a pointer to the lower-level stm32XXX_smbus structure and I2C port, so you might be able to kludge I2C calls using that lower-level structure. However, the SMBUS STACK code implements all of the I2C/SMBus interrupt callbacks so you will likely have to modify them to allow normal I2C stuff.

All of this is with the disclaimer that I haven't done an exhaustive dive into the AN4502 code. Just enough to get my proof-of-concept system up and running. So there may be better ways to mix SMBus and I2C. Or not. Depending on what kind of data you need to transfer via I2C protocol, you may be better off rolling your own driver on top of either the stm32xxx_hal_i2c or stm32xxx_hal_smbus drivers, or the I2C LL driver, or your own bare metal/CMSIS based driver.