1

Any example code available to implement smbus(master and slave) interrupt mode on stm32f091rc ? Tried using the HAL functions was not successful?

In Master mode to transmit I use

while(1) { while(HAL_SMBUS_Master_Transmit_IT(hsmbus,sladd ,command_code,THREE_BYTE,SMBUS_LAST_FRAME_NO_PEC)!= HAL_OK); HAL_SMBUS_Master_Transmit_IT(hsmbus, sladd, command_code , THREE_BYTE,SMBUS_LAST_FRAME_NO_PEC); } sladd is slave address. command code is 3 byte array.

In Slave Mode to receive on 2nd MCU(same as master controller ) Also I am calling HAL_SMBUS_EnableListen_IT(&hsmbus1); to set the state in listening mode,because the Interrupt would only be enabled if smbus state was in listening mode, again this is not very clear in HAL user manual. while(1) { while(HAL_SMBUS_Slave_Receive_IT(&hsmbus1, receive_buffer, 3, SMBUS_FIRST_AND_LAST_FRAME_NO_PEC )!= HAL_OK); HAL_SMBUS_Slave_Receive_IT(&hsmbus1, receive_buffer, 3, SMBUS_FIRST_AND_LAST_FRAME_NO_PEC ); } Actually I am not sure about where to call transmit and receive function(in while(1) or outside) since it is interrupt based we shouldn't be calling function in while(1) let me know if I am right or wrong? Also wanted to know the procedure to receive and transmit messages in Smbus on stm32f091rc?(using HAL libraries)

vinay
  • 11
  • 3
  • Welcome to electronics.stackexchange.com. Would you mind formatting your question such that the code is displayed in a better readable format? – Codo Apr 03 '21 at 08:30
  • Check out my question. Maybe you can implement it for STM32F0. [STM32G0 Stuck on SMBUS Slave](https://electronics.stackexchange.com/questions/634776/stm32g0-stuck-on-smbus-slave) – devscg Sep 15 '22 at 21:51

0 Answers0