cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing with an ITG3200

zexx86
Associate II
Posted on December 28, 2010 at 11:06

Interfacing with an ITG3200

8 REPLIES 8
Posted on May 17, 2011 at 14:19

I am not sure about pull-up resistors. ITG3200 is powered with 3.3V too and with Arduino board it works pretty good without these.

The I2C bus is going to need pull up resistors somewhere, it's driven open drain/collector, so it isn't going to go high without them.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
zexx86
Associate II
Posted on May 17, 2011 at 14:19

I connected pull-up resistors (2x 4k7) but nothing changed.

zexx86
Associate II
Posted on May 17, 2011 at 14:19

I resolved my problem !

There was only wrong device address, it should be one bit bigger in address (so it needs 8 bits instead 7). Correct address is 0xd0 or 0xd2 for ADR=1

Now I can write a data to i2c device without any problem 🙂

For now, there is a next problem with reading.

Here is my code: 

http://pastebin.com/tu9DsbQZ

http://pastebin.com/tu9DsbQZ

and it seems it hangs in loop: 

while

 

(

n

)

 

{ ...;

After reset, I cant even write to device, it ends in BUSY state.

Any idea ?

Thanks

Posted on May 17, 2011 at 14:19

Not sure that would stop the I2C clock from clocking.

I'd look at it some more, but your software is incomplete, and your hardware arrangement/connectivity isn't entirely clear.

What I can see of the software seems to be Ok. The while() loops really need timeouts, and error handling.

I2C devices don't reset with the STM32, If they get stuck in a odd condition you may need to clock them out.

The low order address bit usually defines a read vs write.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
zexx86
Associate II
Posted on May 17, 2011 at 14:19

Thank you

I know my code is not so good, it is just for testing.

I think there is a problem with acknowledges.

When I changed position of enabling/disabling, it works and I can receive data now.

But it is not so clear solution too, there is a same result after reading ends - it stucks in BUSY state.

My current code seems like

http://pastebin.com/1VaKTX4J

 - I found this sequence in this forum.

http://pastebin.com/1VaKTX4J

It is really weird code from ST's examples dont working properly.

I think HW is OK - it is development board and my ITG board working for long time with arduino without one issue.

zexx86
Associate II
Posted on May 17, 2011 at 14:19

I fixed my last problem too !

Problem was in incorrect i2c sequence - I check datasheet of the ITG3200 and fixed a problem.

But there is small issue again - I need small delay in two ''sections''

I have to add a loop for checking an I2C state, but I am not sure which one flag I should test.

This helps:

unsigned short t = 0xfff;

while (t --);

Now read function looks like 

http://pastebin.com/Ptm9dMU6

Thanks

zexx86
Associate II
Posted on May 17, 2011 at 14:19

I'll post my code when it is OK with correct error handling

Posted on May 17, 2011 at 14:19

I know my code is not so good, it is just for testing.

I realize this, but it will help if people can actually compile your code. Doesn't have to be *all* your code, but if your code can stand up by itself, and includes all the #define's it helps.

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