cancel
Showing results for 
Search instead for 
Did you mean: 

read mp6050 sensor with dma i2c

SDall
Associate II

i'm trying to read the mpu6050 data with the i2c, if i

run with the normal function without dma HAL_I2C_Mem_Read (& hi2c1,

((uint16_t *) (0x68 << 1)), 0x43, 1, data, 6,1000) reads regularly in

the loop;

the problem is when I use the dma HAL_I2C_Mem_Read_DMA (& hi2c1,

((uint16_t *) (0x68 << 1)), 0x43, 1, data, 6) it executes the reading

once then it doesn't execute it anymore

and stops here:

 / * Clear ADDR flag * /

   __HAL_I2C_CLEAR_ADDRFLAG (hi2c);

   / * Generate Stop * /

   SET_BIT (hi2c-> Instance-> CR1, I2C_CR1_STOP);

   hi2c-> State = HAL_I2C_STATE_READY;

   / * Process Unlocked * /

   __HAL_UNLOCK (hi2c);

  }

  return HAL_OK;

 }

 else

 {

  return HAL_BUSY;

 }

}

the function return not HAL_OK but HAL_BUSY .....

I tried to read other sensors with the same DMA function and everything works fine!

where can the problem be, thanks !!!

2 REPLIES 2
SDall
Associate II

please someone answer me!

Not sure there are a lot of resources to be had here. Not sure what STM32 is involved, and most people don't have your combination of hardware anyhow.

If the error codes are not helpful honestly you're going to have to stick a logic analyzer on the bus and dig through the failure/issue yourself. If you can identify the point/instant of failure you could raise a GPIO to trigger the analyzer.

What you might want to check for is if the speed is too high, either for the MPU6050 or whatever else you have attached to the bus.

Need to check the signalling, things like the pull-ups, where on the bus they are situated, if the SCL or SDA are sticking low. Perhaps there is some clock stretching? Perhaps another device is recognizing it's address on the bus? Or some other pattern sensitivity. Perhaps one of the devices gets into a weird state and needs clocking out or resetting.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..