2021-06-15 09:46 PM
HAL_I2C_Master_Transmit_IT(&hi2c1,e,&c,1);
HAL_I2C_Slave_Receive(&hi2c2,&d, 1, 1000);
In the above case, it was confirmed that I2C communication works well.
HAL_I2C_Master_Transmit(&hi2c1,e,&c,1,1000);
HAL_I2C_Slave_Receive(&hi2c2,&d, 1, 1000);
However, in the above case, it was confirmed that I2C communication did not work.
HAL_I2C_Transmit is not sending data,
So I debugged
/* if (I2C_WaitOnTXISFlagUntilTimeout(hi2c, Timeout, tickstart) != HAL_OK)
{
return HAL_ERROR;
}*/
HAL_ERROR occurred in this part, so the data was not processed, and it was resolved by commenting out.
Why is this problem happening?
2021-06-17 03:38 AM
Hello MYu.1,
when you are using the transmit function with interrupt (HAL_I2C_Master_Transmit_IT) the peripheral start transmitting and the program continue with with the the receive function. When you are not using the interrupt, the program tries to transmit the the data, but they are not received because the program is still in the HAL_I2C_Master_Transmit function. After some time (timeout) the transmit function return error and program continue with receiving, but also without success.
Please click on Select as Best if my reply fully answered your question. This will help other users with the same problem to find the solution faster!