Shop OBEX P1 Docs P2 Docs Learn Events
Troubleshooting I2C module — Parallax Forums

Troubleshooting I2C module

teganburnsteganburns Posts: 134
edited 2013-07-26 18:26 in Propeller 1
:confused: Hey all I'm having a lot of problems interfacing my MPU-9150 module links for PDF's here -->>(http://www.invensense.com/mems/gyro/mpu9150.html)

This is my first time writing a program that communicates using I2C bus. I tried using a few different I2C drivers from obex but with no prevail. Power should be fine(3.3v from the Quickstart board), Checked my wiring (only 2 wires so that shouldn't be an issue).
And i understand I2C communication protocol. (@DavidJames posted this a while back, thank you) http://www.nxp.com/documents/user_manual/UM10204.pdf

My code is a edited version of Jason Dorie's "ITG-3200" (Gyro Module). My guess is that the problem is in the timing...

If anyone wants to try and troubleshoot the code or give suggestions that would appreciated. :thumb:

My edited code-->> https://raw.github.com/teganburns/Mpu-9150.spin/master/README.md

Comments

  • average joeaverage joe Posts: 795
    edited 2013-07-26 02:48
    Are you using pull-ups on both i2c lines? (sda & scl) I've made this mistake before. What is the problem exactly?
  • Clive WakehamClive Wakeham Posts: 152
    edited 2013-07-26 03:05
    So basically you should have 4 wires running from the Quickstart board to the MPU-9150. Power, Gnd, SDA and SCL.

    Double check the model number of the "MPU-9150". I once spent two days trying to get a "Real Time Clock" I2C chip to communicate with a Prop to no avail. I nearly gave up then I pulled out a magnifying glass and realised that I had the wrong chip and its commands were completely different. Then it took me half an hour to put together an object for it.
  • teganburnsteganburns Posts: 134
    edited 2013-07-26 03:56
    @average joe The chip is on a board from sparkfun.com so it has resistors included.

    My problem is in the code... i have spent weeks trying to figure out what's wrong. :/

    @Clive Wakeham i can't make out what it says on the chip but i don't think sparkfun would make the mistake of using the wrong chip (I should have mentioned that its on a board) https://www.sparkfun.com/products/11486
  • Clive WakehamClive Wakeham Posts: 152
    edited 2013-07-26 05:19
    Have you downloaded the Basic I2C Driver?

    One of the James Extra bits is a method of calling a I2C address and getting a response from it.

    Check it out to confirm that the module you got is on the I2C bus and responding to its 7 bit address.

    This the first thing I do now (after the issue with the RTC chip) to ensure the I2C device is connected correctly to the Prop.

    All you need to do is write a simple program that queries the address of the module and prints OK on the screen using Parallax Serial Terminal etc.
  • TrapperBobTrapperBob Posts: 142
    edited 2013-07-26 05:53
    Please check the 7-bit address is correct
  • ChrisGaddChrisGadd Posts: 310
    edited 2013-07-26 08:24
    I think Clive and TrapperBob have it. The device ID is indeed %0110_1000, but it needs to be shifted left one bit and a write(0) or read(1) bit shifted in. Your WriteByte methods should use %1101_0000, and your reads should use %1101_0001.
    The datasheet also describes clock-stretching by slave devices, though it's not clear if the MPU-9150 makes use of it.
  • teganburnsteganburns Posts: 134
    edited 2013-07-26 09:36
    Yepp It was the Device Address Thanks!!

    Funny how how i wrote the internal register preliminary configuration correctly but got the device address wrong.. :P
  • Clive WakehamClive Wakeham Posts: 152
    edited 2013-07-26 18:26
    If that is the problem then its an easy fix.

    In my last post I forgot to mention that I quickly wrote a short spin program that used the Basic I2C driver "extra bits" to cycle through all the 7 bit addresses to find where the I2C device is at.

    There is an assembly language version of the I2C driver on OBEX which runs at a faster speed to the spin version.
Sign In or Register to comment.