2017-09-08 06:38 AM
Hello All,
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)
{GPIO_InitTypeDef GPIO_InitStruct;
if(hi2c->Instance==I2C1) { /* 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;HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* Peripheral clock enable */
/* USER CODE BEGIN I2C1_MspInit 1 */__HAL_RCC_I2C1_CLK_ENABLE();
/* USER CODE END I2C1_MspInit 1 */
}}
with this code,
when i put CLOCK_ENABLE before GPIO_ENABLE ,
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??♯♯♯♯♯@@♯♯
#i2c-busy #i2c #mpu60502017-09-09 02:25 PM
Hi!
>>'when i put CLOCK_ENABLE before GPIO_ENABLE'
In my opinion this is irrelevant with issue.
>>'Device is not initializing.(Getting HAL_BUSY flag) when address is not 0x68'
the address of mpu 6050 is 0x68 ORed with AD0 pin (0x01, 0x00).
AD0 pin normaly is connected to ground or VCC.
So the slave address is determined. Is 0x68 or 0x69
Use this determined address only.
>>' 2. I am getting switch interrupt continuously,even if i am not pressing switch.'
>>' 3. when i disable interrupt, still MPU6050 is not working.'
Make a new project with only the relevant with problem code, to have clearer view about the SPI issue.
This switch and interrupt doesn't help to focus to this problem.
Assuming that you use a 3.3v module
Check I2C bus's pullup resistors first.
Check AD0 pin not to be floated.
After I2c initialisation code, call HAL_I2C_Mem_Read(&hi2c, MPU6050_I2C_ADDR<<1, 0x0075, 1, &data, 1, 100). returned data must be 0x68
In case you don't make any progress, Post your .IOC file with main .c and some schematic of your MPU module.