cancel
Showing results for 
Search instead for 
Did you mean: 

X-CUBE-SMBUS Does not work with CubeMX (STM32F072RB)

Mike Panetta
Associate II
Posted on October 06, 2017 at 22:22

I've tried everything I can think of, but I can't get the library to work at all.  I see on my oscilloscope where it tries to get data from the device (I am using STM32F072RB as SMBUS SLAVE), but it never gets what I try to send.  Attaching my code below.

Are there any examples of how to get SMBUS working with CubeMX software? 

I put some prints in the lib code and here is what I get... Why does it think I want SMBUS QUICK transfer?  I am not sending a quick, I am sending a read byte request with command....

The following is 2 attempted transfers:

SMBUS_Slave_ISR

SMBUS_FLAG_ADDR

Call HAL_SMBUS_AddrCallback()

HAL_SMBUS_AddrCallback()

Call STACK_SMBUS_AddrAccpt()

STACK_SMBUS_AddrAccpt()

MATCH? 44:44

MATCH

Complete, ret: SUCCESS

ELSE

WRITE

Complete...

SMBUS_Slave_ISR

SMBUS_FLAG_ADDR

Call HAL_SMBUS_AddrCallback()

HAL_SMBUS_AddrCallback()

Call STACK_SMBUS_AddrAccpt()

STACK_SMBUS_AddrAccpt()

MATCH? 44:44

MATCH

Complete, ret: SUCCESS

ELSE

READ

Call STACK_SMBUS_ExecuteCommand() Where does this go?

:(

STACK_SMBUS_ExecuteCommand(0x20003fa8) Time to make the donuts!

context: 0x20003fa8, Buffer: 0x20003fcb, piobuf: 0, CurrentCommand: 0, state: 4a

SMBUS_FLAG_STOPF

HAL_SMBUS_ListenCpltCallback()

Call HAL_SMBUS_ExecuteCommand() FOR SMBUS_SMS_QUICK_CMD_W

STACK_SMBUS_ExecuteCommand(0x20003fa8) Time to make the donuts!

context: 0x20003fa8, Buffer: 0x20003fcb, piobuf: 0, CurrentCommand: 1, state: 1

Got command 0x01

HAL_SMBUS_ListenCpltCallback() - COMPLETE

Complete...

SMBUS_Slave_ISR

Complete...

SMBUS_Slave_ISR

SMBUS_FLAG_ADDR

Call HAL_SMBUS_AddrCallback()

HAL_SMBUS_AddrCallback()

Call STACK_SMBUS_AddrAccpt()

STACK_SMBUS_AddrAccpt()

MATCH? 44:44

MATCH

Complete, ret: SUCCESS

ELSE

WRITE

Complete...

SMBUS_Slave_ISR

SMBUS_FLAG_ADDR

Call HAL_SMBUS_AddrCallback()

HAL_SMBUS_AddrCallback()

Call STACK_SMBUS_AddrAccpt()

STACK_SMBUS_AddrAccpt()

MATCH? 44:44

MATCH

Complete, ret: SUCCESS

ELSE

READ

Call STACK_SMBUS_ExecuteCommand() Where does this go?

:(

STACK_SMBUS_ExecuteCommand(0x20003fa8) Time to make the donuts!

context: 0x20003fa8, Buffer: 0x20003fcb, piobuf: 0, CurrentCommand: 1, state: 4a

Got command 0x01

SMBUS_FLAG_STOPF

HAL_SMBUS_ListenCpltCallback()

Call HAL_SMBUS_ExecuteCommand() FOR SMBUS_SMS_QUICK_CMD_W

STACK_SMBUS_ExecuteCommand(0x20003fa8) Time to make the donuts!

context: 0x20003fa8, Buffer: 0x20003fcb, piobuf: 0, CurrentCommand: 1, state: 1

Got command 0x01

HAL_SMBUS_ListenCpltCallback() - COMPLETE

Complete...

SMBUS_Slave_ISR

Complete...

Attached is my code in zip form.

Thanks for any help!

Mike

#x-cube-smbus
2 REPLIES 2
JGurl
Associate

Hi Mike,

I realize this post is over a year old. It doesn't look like anyone monitors this much.

I'm having a similar problem with the SMBus HAL. I'm trying to make an SMBus slave device. I'm using the SMBus Stack and the STM32F0 HAL version 1.7. Did you ever get this resolved?

The issues seems to be the "LISTEN" state. After the first bytes from the host <addr+w><cmd>, then <addr+r> The Stack needs to be able to transmit, but it can't because the HAL is still in the listen state, likely because of the <addr+r> that just happened. So, the HAL it skips right over the code in SLAVE_TRANSMIT_IT because it is still in the "LISTEN" | "RX" state. Right now, there is no code that can switch gears from "LISTEN|RX" to "TX"

The slave portion of the SMBus HAL just seems to be broken. The SMBus_Stack as implemented by ST seems to be written well and handles many cases. Master(Host) mode may work ok, but I have no need for that.

Thoughts?

Best Regards,

Jason

Mike Panetta
Associate II

I ended up using plain I2C mode. SMBus mode was not working correctly.

Thanks,

Mike