cancel
Showing results for 
Search instead for 
Did you mean: 

SMBus on STM32C031

LsnLeeJW
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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);

 

 

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

View solution in original post

4 REPLIES 4
Saket_Om
ST Employee

Hello @LsnLeeJW and welcome to the community

Could you please provide the source code for this implementation?

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

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?

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);

 

 

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

It works , thanks for your help.