2016-09-07 01:46 AM
hi..
few days ago i bought a GYRO Sensor that name is MPU6050.It use I2C Comm.I was try to connect using I2C.why 'HAL_I2C_IsDeviceReady' is always 'BUSY'?using board : Nucleo-F446RE , MPU6050
Library : HAL
----------------------------------------------HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_TIM2_Init();
MX_TIM3_Init();
MX_USART2_UART_Init();
MX_I2C1_Init();
/* USER CODE BEGIN 2 */
while
(HAL_UART_Receive_IT(&huart2, Rx_Data2, 1)!=HAL_OK
);// Activate TIMER Interrupt
while
(HAL_TIM_Base_Start_IT(&htim2)!=HAL_OK
);while
(HAL_TIM_Base_Start_IT(&htim3)!=HAL_OK
);// i2c1 setting
uint8_t
whoAmI[2];// whoAmI[0] = RA_PWR_ADDR;
// whoAmI[1] = RA_PWR_MGMT_1;
uint8_t
pdata=0x00;while(HAL_I2C_IsDeviceReady(&hi2c1,MPU6050,10,1000)!=HAL_OK);
HAL_I2C_Master_Transmit_DMA(&hi2c1,MPU6050,&pdata,1);
HAL_I2C_Mem_Write_DMA(&hi2c1,MPU6050>>1,RA_PWR_ADDR,1,&pdata,1);
HAL_UART_Transmit(&huart2, (
uint8_t
*)''\r\n11111!!!!!\r\n''
, 14,1000); #i2c #dma #mpu60502016-09-07 03:04 AM
Hi sohaeng.lee,
Which versions of CubeMx and STM32CubeF4 are you using ? -Hannibal-2016-09-07 04:23 AM
Hi, Hannibal
I'm using CubeMx 4.16.0 and STM32CubeF4 1.13.0.thanks.The result isAlways HAL_TIMEOUT.
2016-09-08 03:44 AM
Hi sohaeng.lee,
To try to help you in this , share you .ioc file to sse how the I2C and GPIO are configured. Also, would you mention if any hardware connection are done?-Hannibal-2016-09-08 05:30 AM
ok, Hannibal
my Project file Attach here. And photos. thank you kindness. ________________ Attachments : NucleoF446RE_PROJ.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I15O&d=%2Fa%2F0X0000000bi6%2FzLuAQOUrMJ4s9f3jbkyO1XQUnFnMP0qTbDdYvFJTOd8&asPdf=false2016-09-08 08:03 AM
Hi sohaeng.lee,
Let's begin first with the hardware side; you need to pull-down the AD0 pin to ground for giving the mpu6050 correct addressing (0x68) -Hannibal-