Unable to read ITG3200 (6DOF) with i2c

I got me a brand new mpu6050. Its a different mpu comapred to ADXL345/ITG3200. mpu6050 has only one i2c address (0x68).

I connected it to my RPi and all i2c commands worked like charm.

When i connected it to spark i faced the same old problem of not writing to the registers.

I see that below code is failing,
while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))

I see that writeTo() -> endTransmission() function is failing me a lot while readFrom() has worked most of the time.

@peekay123: You wrote ’ I am looking at how the Core firmware and Arduino handle a device address to be sure they match’. You have any updates for me if any.

I see that there are many issues with stmf100x i2c. Here are some of the links,

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FSTM32F100%20-%20I2C%20stuck&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=2310

@sanjukul, I can’t comment about those thread but perhaps @satishgn or another Spark engineer can. As a baseline, have you tried the MPU6050 IDE library to test?

Hi @sanjukul

Looking at the data sheet for the MPU6050, it has a maximum i2c clock rate of 100kHz in normal mode and that is Spark’s slowest speed.

Given that you are dealing with a very slow i2c device, you might want to try adding the 100ohm series resistors on the two i2c lines as shown in this diagram from the ST Micro datasheet:

If that doesn’t work, you will likely have to get a bit-banging i2c implementation working to go slow enough.

@bko, some time ago another member was using a Sparkfun MPU6050 with a library I ported and it worked fine with the “old” 100KHz Core firmware:

It should work without problems or the need for the resistors. It may also be hard to put the resistors in as the pull-ups may already be on the board. :smile:

1 Like