I2C1 & I2C2 Difference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-21 11:32 PM
Hello, this is DK.
I am working on a project using stm32f429IIt6.
I'm currently having an I2C problem at the end of my project.
I2C1 uses PF 0, 1 / I2C2 uses PB 6, 7. The HW PCB completed, and the HW I2C pull up is the same.
In I2C1 HAL code, the entire initialization does not work, and if I2C2 is used with the same code, it works well.
I am using various Pheripherals such as TIM Interrupt. Is there any conflict?
Is there any difference between I2C1 and I2C2?
In the TIMER part, it appears to share APB1.
Solved! Go to Solution.
- Labels:
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-23 4:28 PM
I also use I2C3 in another IC(gyro sensor).
Error in I2C1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-23 4:31 PM
But your original question is just about I2C1 & I2C2.
Are you saying you also get problems with I2C3 in conjunction with I2C1 and/or I2C2?
Does each one work separately on its own?
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-23 6:20 PM - edited ‎2025-01-23 6:21 PM
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 */
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-24 1:27 AM
Again, is that just with I2C1 on its own - no other code, and no other I2C in use?
A complex system designed from scratch never works and cannot be patched up to make it work.

- « Previous
-
- 1
- 2
- Next »