cancel
Showing results for 
Search instead for 
Did you mean: 

smbus slave is not receiving the data

suguresh_m
Visitor

Edited by ST moderator to be inline with the community rules especially with the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code.

 

void HAL_SMBUS_ErrorCallback(SMBUS_HandleTypeDef *SMBUSHandle)

{

/** Error_Handler() function is called when error occurs.

* 1- When Slave doesn't acknowledge its address, Master restarts communication.

* 2- When Master doesn't acknowledge the last data transferred, Slave doesn't care in this example.

*/

if (HAL_SMBUS_GetError(SMBUSHandle) != HAL_SMBUS_ERROR_ACKF)

{



printf("failed\r\n");

/* Turn Off LED2 */



}

}



/**

* @brief Slave Address Match callbacks.

* @PAram hsmbus : Pointer to a SMBUS_HandleTypeDef structure that contains

* the configuration information for the specified SMBUS.

* @retval None

*/

void HAL_SMBUS_AddrCallback(SMBUS_HandleTypeDef *hsmbus,uint8_t TransferDirection, uint16_t AddrMatchCode)

{

SlaveAddrMatchCode = (AddrMatchCode << 1);

HAL_SMBUS_EnableListen_IT(&hsmbus1);

uint8_t tx_buff=0x00;

HAL_SMBUS_Slave_Transmit_IT(&hsmbus1, &tx_buff, 1, SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC);

//HAL_SMBUS_Slave_Transmit_IT(&hsmbus1, &aTxBuffer, 1, SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC);

UNUSED(TransferDirection);

}

void HAL_SMBUS_SlaveRxCpltCallback(SMBUS_HandleTypeDef *hsmbus)

{

HAL_SMBUS_Slave_Receive_IT(&hsmbus1,dummy_data, 2, SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC);

}





//

// return 0;

//}

/* USER CODE END 0 */



/**

* @brief The application entry point.

* @retval int

*/

int main(void)

{



/* USER CODE BEGIN 1 */



/* USER CODE END 1 */



/* MCU Configuration--------------------------------------------------------*/



/* Reset of all peripherals, Initializes the Flash interface and the Systick. */

HAL_Init();



/* USER CODE BEGIN Init */



/* USER CODE END Init */



/* Configure the system clock */

SystemClock_Config();



/* USER CODE BEGIN SysInit */



/* USER CODE END SysInit */



/* Initialize all configured peripherals */

MX_GPIO_Init();

MX_USART3_UART_Init();

MX_USART2_UART_Init();

MX_TIM1_Init();

MX_I2C1_SMBUS_Init();

MX_I2C3_SMBUS_Init();

/* USER CODE BEGIN 2 */



/* Enable the Analog SMBUS Filter */

HAL_SMBUS_ConfigAnalogFilter(&hsmbus1,SMBUS_ANALOGFILTER_ENABLE);



/* Enable address Match detect with interrupt */

HAL_SMBUS_EnableListen_IT(&hsmbus1);

/* Wait until address matched */



while(SlaveAddrMatchCode != SMBUS_ADDRESS);







/* USER CODE END 2 */



/* Infinite loop */

/* USER CODE BEGIN WHILE */

while (1)

{

/* USER CODE END WHILE */



/* USER CODE BEGIN 3 */



}

/* USER CODE END 3 */

}

 

 

1 REPLY 1
suguresh_m
Visitor

Please provide me a solution with SMBUS In SLAVE configuration without PEC or with PEC