cancel
Showing results for 
Search instead for 
Did you mean: 

nucleo446re and MPU6050 i2c problem

SoHaeng.Lee
Associate II
Posted on September 07, 2016 at 10:46

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 #mpu6050
5 REPLIES 5
Walid FTITI_O
Senior II
Posted on September 07, 2016 at 12:04

Hi sohaeng.lee,

Which versions of CubeMx and STM32CubeF4 are you using ?

-Hannibal-

SoHaeng.Lee
Associate II
Posted on September 07, 2016 at 13:23

Hi, Hannibal

I'm using CubeMx 4.16.0 and STM32CubeF4 1.13.0.

thanks.

The result is

Always HAL_TIMEOUT.

 

Walid FTITI_O
Senior II
Posted on September 08, 2016 at 12:44

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-

SoHaeng.Lee
Associate II
Posted on September 08, 2016 at 14:30

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=false
Walid FTITI_O
Senior II
Posted on September 08, 2016 at 17:03

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-