I am using STM32F100 MCU for MPU6050 sensor interfacing.
I am using I2C.
when i generate code , i get it
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
/* USER CODE BEGIN I2C1_MspInit 0 */
/* USER CODE END I2C1_MspInit 0 */
/**I2C1 GPIO Configuration
PB6 ------> I2C1_SCL
PB7 ------> I2C1_SDA
GPIO_InitStruct.Pin = MPU6050_SCL_Pin|MPU6050_SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
/* Peripheral clock enable */
/* USER CODE BEGIN I2C1_MspInit 1 */
/* USER CODE END I2C1_MspInit 1 */
with this code,
- i am not getting Device address as 0x68/69 everytime.1 out of 15 times, i get 0x68 .
- Device is not initializing.(Getting HAL_BUSY flag) when address is not 0x68.
- when i get 0x68(it is very rare) , MPU is working and i get correct steps count from my code of MPU6050
when i put CLOCK_ENABLE before GPIO_ENABLE ,
- i got device address correctly every time(15 out of 15).
- but I am getting 2 issues
1. functionality of MPU is not working. step count is not working
2. I am getting switch interrupt continuously,even if i am not pressing switch.
3. when i disable interrupt, still MPU6050 is not working.
Please help me to resolve this.
why I2C is not giving correct address??#####@@##