Skip to main content
sivaram
Associate III
January 17, 2019
Question

SMBUS communication with Smart Battery

  • January 17, 2019
  • 2 replies
  • 1546 views

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?

This topic has been closed for replies.

2 replies

RAnde.2
Associate
February 13, 2019

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

BThar.1
Visitor II
March 1, 2020

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