2024-09-19 01:12 AM
Hi everybody !! i have an issue on I2C with a STM32 issue. i thought this was a code issue but in the main i also make LEDs blinking and it works, only the I2C doesn't work but... i noticed that my lines both rise to 3.3V but never fall down it just stay high. i guess it might be because i have a clock issue. Im using internal clock for some reasons, no external crystal. The HAL-delay function work with the SYSCLK but my I2C clock doesn't. Thx for your future answers. Best regards.
2024-09-21 07:20 AM
i tried to leave all my function and only put one I2C function in the main like this :
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(GPIOA, LED_1_Pin);
HAL_Delay(2000);
HAL_GPIO_TogglePin(GPIOA, LED_5_Pin);
HAL_Delay(2000);
HAL_I2C_IsDeviceReady(&hi2c1, 0xD0, 1, 1000);
}
/* USER CODE END 3 */
}
but this is the same, i just have 3.3V on I2C lines. I guess i was right and it might be an I2C settings issue. Im using the internal clock of STM32 could it be the problem ?
i show you the I2C code auto generated by CubeIDE
static 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.Timing = 0x40000A0B;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
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 */
}
2024-09-21 08:38 AM
It isn't clear how you're seeing 3.3V, so are you using a oscilloscope to see if there is data activity and not just using a DMM?
Is this a custom board or a Nucleo/Discovery and MPU6050 board? Which STM32F4xx?
In either case, show how the MPU6050 is connected to the STM32 with pull-ups and values.
Upload your IOC file or better yet, upload the project.
2024-09-21 01:25 PM
I see that with an oscilloscope. I will try to show you my IOC file. But i just notice that my I2C lines are tied to 3.3V even if i disable I2C in IOC file ^^' i guess this is a hardware problem i will check that.