Skip to main content
Visitor II
May 22, 2024
Solved

SMBus on STM32C031

  • May 22, 2024
  • 1 reply
  • 1634 views

Hi ST tesam,

When I use  HAL_SMBUS_Master_Receive_IT( ) to receive data from device ,I can not got the information directly after the HAL_SMBUS_MasterRxCpltCallback( SMBUS_HandleTypeDef *hsmbus ) was complete.

(I had set a flag when HAL_SMBUS_MasterRxCpltCallback( SMBUS_HandleTypeDef *hsmbus )  done)

I had to wait for a while and then I can read data from register, but what can I do to know when the saving process was complete?

 

Regards,

LSN

    This topic has been closed for replies.
    Best answer by Saket_Om

    Hello @LsnLeeJW 

     

    Could you please try to check the state in the SMBUS handle instead of checking bSMBusRxCpltFlag flag? 

    Please refer to the snippet code below to implement this solution: 

     

     
    HAL_SMBUS_Master_Receive_IT( &hsmbus1, BATTERY_ADD, &ucCalTemp[ 3 ], dataLength + 1 , SMBUS_LAST_FRAME_NO_PEC );
    while (hsmbus1.State == HAL_SMBUS_STATE_MASTER_BUSY_RX);

     

     

    1 reply

    Technical Moderator
    May 22, 2024

    Hello @LsnLeeJW and welcome to the community

    Could you please provide the source code for this implementation?

    LsnLeeJWAuthor
    Visitor II
    May 27, 2024

    Hello,Omar.

    Thank for your reply,I've attached the snippet of the code.

    Here I try to use 'HAL_SMBUS_MasterRxCpltCallback' to notify me whether the data was received,but it don't works.Is there a better way for me to know whether the data has been stored in memory?

    Saket_OmAnswer
    Technical Moderator
    May 27, 2024

    Hello @LsnLeeJW 

     

    Could you please try to check the state in the SMBUS handle instead of checking bSMBusRxCpltFlag flag? 

    Please refer to the snippet code below to implement this solution: 

     

     
    HAL_SMBUS_Master_Receive_IT( &hsmbus1, BATTERY_ADD, &ucCalTemp[ 3 ], dataLength + 1 , SMBUS_LAST_FRAME_NO_PEC );
    while (hsmbus1.State == HAL_SMBUS_STATE_MASTER_BUSY_RX);