2020-11-17 11:30 AM
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 !!!
2020-11-21 03:52 PM
please someone answer me!
2020-11-21 06:56 PM
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.