Jump to content
43oh

Launchpad lm4f120 running I2C


Recommended Posts

Hello, I am having big troubles with running I2C on my stellarpad.

 

I am total noob to this topic so i want to ask if anyone can explain it. I have found that Stellarpad has 4 chanells.

I have got some questions.

 

 

1. How to wire an I2C device properly. Do i need pullup resistors or should i use pinMode on INPUT_PULLUP ?

2. How i can ensure that i connected the device properly ? I tried I2C scanner from arduino webside, but I always recieve message device found on each adress, with nothing connected to board.

 

Here is the I2C scanner code :

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// 
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>


void setup()
{
  Wire.begin(2);

  Serial.begin(9600);
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknow error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

Thanks for help.

Link to post
Share on other sites

I2C has 2 wires, SCL (clock) and SDA (data).

 

Both lines should have 4.7K ohm pullup resistors. The internal pullups enabled with INPUT_PULLUP is probably too weak to drive the protocol.

 

Otherwise, your device needs power, the GND connections must be shared between the stellarpad and the device, and the device's SCL line connects to the stellarpad I2C channel's SCL line and likewise with SDA.

 

Sent from my Galaxy Note II with Tapatalk

 

 

Link to post
Share on other sites

I2C has 2 wires, SCL (clock) and SDA (data).

 

Both lines should have 4.7K ohm pullup resistors. The internal pullups enabled with INPUT_PULLUP is probably too weak to drive the protocol.

 

Otherwise, your device needs power, the GND connections must be shared between the stellarpad and the device, and the device's SCL line connects to the stellarpad I2C channel's SCL line and likewise with SDA.

 

Sent from my Galaxy Note II with Tapatalk

 

Ok, i will try pullup resistors, but do you think it will solve the qestion why i see an I2C device on each address ?

Link to post
Share on other sites

Please, do you have some clear sketch how to wire a correct pullup resistors ?

No drawings, but it's simple; connect SCL and SDA of the stellaris to SCL and SDA of your device, then connect a 4.7Kohm pullup resistor between SCL and +3.3V and another 4.7Kohm pullup resistor between SDA and 3.3V.

 

It might help to use a breadboard for this (i.e. Stellaris SCL to breadboard, device SCL to that same line of pins on the breadboard, ditto with SDA using another line of pins on the breadboard, connect stellaris +3.3V to the red power rail on the breadboard, stellaris GND to the blue power rail, connect device's GND to that same blue power rail, device's Vcc to the red power rail to supply it with power, then install one 4.7Kohm resistor between the SCL pin strip and the red power rail and another 4.7Kohm resistor between SDA pins and the red power rail.)

Link to post
Share on other sites

Here's a quick drawing from my phone: attachicon.gifstellarpad_i2c_pullups.jpg

 

 

Wiring seems to be good, but after running scanner i still receive device on each adress.

I also tried to use the sketch from http://playground.arduino.cc//Main/MPU-6050?action=sourceblock&num=1 with just a little changes like

 
  Wire.begin(2);   //to work on pins  5 and 6
Tried both adresses, which are written on in the sketch.
But i always receive a zero from the device so the output looks like 
MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 0, 0, 0
temperature: 36.506 degrees Celsius
gyro x,y,z : 0, 0, 0,

 

I have no idea how to make it run :/

Link to post
Share on other sites
  • 5 months later...
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...