cancel
Showing results for 
Search instead for 
Did you mean: 

SMBUS communication with Smart Battery

sivaram
Associate III

We are designing a system where stm32f7xx will communicate with smart battery via SMBUS protocol, The code is as follows

if (HAL_SMBUS_Init(&hsmbus1) != HAL_OK){
      Error_Handler();
   }
 
 if (HAL_SMBUS_Init(&hsmbus1) != HAL_OK)   {
    Error_Handler();
    }
 
   if (HAL_SMBUS_IsDeviceReady(&hsmbus1, (uint16_t)DEV_ADDRESS<<1, 2, 2) != HAL_OK){
      Error_Handler();
   }
 
   uint8_t buffertx[2] = {0,0};
 
   uint8_t bufferrx[10] = {0x0};
 
   buffertx[0] = 0x21;
 
   ret = HAL_SMBUS_Master_Transmit_IT(&hsmbus1, (uint16_t)DEV_ADDRESS << 1, &buffertx[0], 1, SMBUS_OTHER_FRAME_NO_PEC);
 
   if (ret != HAL_OK)   {
      Error_Handler();
   }
 
   uint32_t test;
   do{
      test = HAL_SMBUS_GetState(&hsmbus1);
   }while(test != HAL_SMBUS_STATE_READY);
 
   ret = HAL_SMBUS_Master_Receive_IT(&hsmbus1,(uint16_t)DEV_ADDRESS<<1, &bufferrx[1], 7, SMBUS_LAST_FRAME_NO_PEC);
 
   if(ret != HAL_OK){
      Error_Handler();
   }
 
 
   uint32_t retval;
   do{
   retval =   HAL_SMBUS_GetState(&hsmbus1);
   }while(retval != HAL_SMBUS_STATE_READY);
 

we observed that HAL_SMBUS_Master_Receive_IT receives data correctly, but after reception

the HAL_SMBUS_GetState is always busy(i.e 0x34).

what could be the issue?

also would like to know that the transfer options we are using are correct?

2 REPLIES 2
RAnde.2
Associate

I have the exact same problem. No matter what I do the HAL is always busy after a master transmit

BThar.1
Associate II

could somebody let me know how to read a slave through smbus . i am working on STM32F0xx + BQ79350-R1 .