I mean I2C3 has no problem.
It just have I2C1 Initialize problem.
When i call HAL_I2C_Master_Transmit(), HAL_I2C_Master_Receive() functions goes to HAL Busy Flag in Debug mode.
and I temporarily fixed it.
When I use HAL_I2C_Master_Transmit, it goes HAL Busy Flag because of It's not in HAL_I2C_STATE_READY.
so i add like above code. then it works.
if(HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)DevAddress, tx_buf, Size+1, 2) != HAL_OK)
{
MX_I2C1_Init();
HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)DevAddress, tx_buf, Size+1, 10);
}
However, this method is only temporary, and I don't know what the fundamental problem is.
I have already proceeded with I2C1 Initialize as a project to be created through CUBEIDE, and the code is written in the Main statement.
Even if you debug by changing the MX_I2C1_Init() code up and down the Main statement, the same phenomenon occurs.
The configuration of I2C1 is as follows. This appears to be correct code.
100KHz polling I2C Initialize.
/* I2C1 init function */
void MX_I2C1_Init(void)
{
/* USER CODE BEGIN I2C1_Init 0 */
/* USER CODE END I2C1_Init 0 */
/* USER CODE BEGIN I2C1_Init 1 */
/* USER CODE END I2C1_Init 1 */
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 100000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN I2C1_Init 2 */
/* USER CODE END I2C1_Init 2 */
}