2010-12-28 02:06 AM
Interfacing with an ITG3200
2011-05-17 05:19 AM
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.2011-05-17 05:19 AM
I connected pull-up resistors (2x 4k7) but nothing changed.
2011-05-17 05:19 AM
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:
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
2011-05-17 05:19 AM
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.2011-05-17 05:19 AM
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 - I found this sequence in this forum.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.
2011-05-17 05:19 AM
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 likeThanks
2011-05-17 05:19 AM
I'll post my code when it is OK with correct error handling
2011-05-17 05:19 AM
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.