rycco1426459928 0 Posted July 7, 2013 Share Posted July 7, 2013 Hi, i am having problem with running I2C on stellaris launchpad. I am using this code but i get message device found from each adress, can someone explain me how it works and how should i connect it ? Thanks. Here is the 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(); Wire.setModule(2); pinMode(5,INPUT_PULLUP); pinMode(6,INPUT_PULLUP); 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 } Quote Link to post Share on other sites
Rei Vilo 695 Posted July 7, 2013 Share Posted July 7, 2013 Have you tried using real pull-up resistors? 10kΩ are fine. Quote Link to post Share on other sites
rycco1426459928 0 Posted July 7, 2013 Author Share Posted July 7, 2013 Have you tried using real pull-up resistors? 10kΩ are fine. But it still does not answers the question why i see I2C device on every adress when nothing is wired ? Quote Link to post Share on other sites
igor 163 Posted July 8, 2013 Share Posted July 8, 2013 But it still does not answers the question why i see I2C device on every adress when nothing is wired ? If the pull up on SDA is not adequate then it might look like getting an ACK (0 on SDA) at every address. (just a guess at what might be happening) Quote Link to post Share on other sites
OzGrant 22 Posted December 15, 2013 Share Posted December 15, 2013 G'day, Has anyone solved this problem. I get the same result (or should I say too many results) of I2c addresses found with nothing connected. Note: Connected the two external pullups. My cro showed zip activity on the two lines. Am further confused that wire.ccp and wire.h keep using TwoWire for the functions, where the sketch uses Wire. Grant Quote Link to post Share on other sites
superbrew 0 Posted January 3, 2014 Share Posted January 3, 2014 I am also not able to get this to work. I have an MPU6050 that I am trying to use with my Tiva Launchpad. When I run this code, I get a device found at every address. I have run the Arduino version on my Arduino and the MPU6050 shows up at address 0x68 or 0x69, depending on the AD0 pin. I have the SCL on pin PE4 and the SDA on pin PE5, which should be I2C 2 according to the LM4F123 datasheet. I have tried adding pullups, but this does not make a difference. Do I have the MPU connected properly? Quote Link to post Share on other sites
OzGrant 22 Posted January 3, 2014 Share Posted January 3, 2014 Superbrew, Got It to work with the following code Wire.begin(0); Wire.setModule(0); Hope it works for you. Grant Quote Link to post Share on other sites
superbrew 0 Posted January 4, 2014 Share Posted January 4, 2014 It does not work for me. I am not sure if it is the MPU6050 board that I am using though. It is a no-name one from ebay. It works on the Arduino, which is running at 5V. I also tried to get it running using CCS, so I think there is some hardware issue. I may get a better breakout for the MPU, like from Sparkfun or something. Quote Link to post Share on other sites
chicken 630 Posted January 5, 2014 Share Posted January 5, 2014 @@superbrew how did you hook up power to the board? and do you have a schematic of the board itself? Quote Link to post Share on other sites
superbrew 0 Posted January 6, 2014 Share Posted January 6, 2014 I have the power coming from the 3.3V of the Launchpad. I have tried connecting it to all of the combinations of I2C pins (PB2-3, PA6-7, PE4-5, PD0-1). I do not have a schematic for the board, unfortunately. This appears to be the same as the one I have: http://www.ebay.com/itm/NEW-MPU6050-Module-3-axis-Gyro-Acceleration-Sensor-6-Axis-Attitude-Gradient-/221204742480?pt=LH_DefaultDomain_0&hash=item3380d48150 Quote Link to post Share on other sites
chicken 630 Posted January 7, 2014 Share Posted January 7, 2014 Ask the seller, often they will send you a link to a schematic. Doing some reverse engineering: As the MPU6050 is 3.3V but the module is designed to be operated on an Arduino-friendly 5V, there's a voltage regulator (LDO) between VCC and the IC. When you only feed 3.3V into the LDO, that's not sufficient.Looking at the pictures I guessed that the LDO is the part marked with 662K. And searching for LDO 662K brings up the CYSTech LM6206N3 (datasheet). So yes, it does have an LDO, and according to the datasheet it needs at least .1V above 3.3V to operate. So it MIGHT work if the LaunchPad's voltage is slightly higher than 3.3V. I'd check with a multimeter if there's 3.3V on pin 2 of the LDO / the positive side of the yellow tantalum cap. If yes, we're good and the issue is not power. If there's no power, you'd need to solder a wire from the LaunchPad's 3.3V to that point. Quote Link to post Share on other sites
5rm 0 Posted January 8, 2014 Share Posted January 8, 2014 I am trying to use I2C LCD display on my Tiva C Launchpad.: Display uses the YwRobot LMC1602 IIC V1 adapter with address 27 like this one: http://arduino-info.wikispaces.com/LCD-Blue-I2C I have tried different libraries, but have not managed to get it work. In Arduino the display is working OK with this sketch: //Hello World #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x20 for a 16 chars and 2 line display void setup() { lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); lcd.print("Hello, world!"); } void loop() { } 1.Does Energia need some more definitions to the above sketch for I2C to work? 2. How do I define which I2C pinns I use in Tiva C as there are I2C0...I2C3? 3. Can someone give a link to a working library? Quote Link to post Share on other sites
superbrew 0 Posted January 9, 2014 Share Posted January 9, 2014 Thanks for the help Chicken, but it is still not working. My DMM is nowhere to be found, so I can not check the voltage. I did try using the 5V from the Arduino as a supply for MPU, but it made no difference. I then hooked it back up to the Arduino's I2C and it worked fine. I am just a hobbyist who is experimenting, so if this does not work with this MPU board, I will wait until I buy one from a known good source. 1.Does Energia need some more definitions to the above sketch for I2C to work? 2. How do I define which I2C pinns I use in Tiva C as there are I2C0...I2C3? 3. Can someone give a link to a working library? I can help a little with 2. You can use Wire.setmodule(x) to set the I2C that you are using. The datasheet for the TM4C123GH6PM gives the pins that each I2C module uses in the I2C section. Take this info with a grain of salt, because I have not been able to get this working with Energia either. Quote Link to post Share on other sites
5rm 0 Posted January 9, 2014 Share Posted January 9, 2014 Thanks superbrew for the info on point 2. As the SDA and SCL lines are bidirectional, is it correct/enough to pinMode(pin, INPUT_PULLUP);? Quote Link to post Share on other sites
anandjm 0 Posted January 10, 2014 Share Posted January 10, 2014 Well I had similar problems with my ADXL345 module (with 5v to 3.3v regulator). Both with SPI and I2C. First I wrongly connected the 5v supply to the 3.3v rail. So I ended up replacing the IC on the module using solder paste and hot air gun. Then I was not sure if the solder was good or not. After wasting two days with both SPI and I2C, I verified it on my Raspberry Pi and it was detected without any problem. Next I tried it out on my MSP430 board with I2C. No issues there. I've discovered that "Wire.endTransmission()" always returns a zero both on the MSP430 and the Stellaris launchpads. Apparently this is also an issue with some arduino like boards (like the teensy). With the Stellaris launchpad I had issues with using I2C(0). It would intermittently read data and garbage for multibyte reads (which is necessary for the ADXL345). Single byte reads did not exhibit this problem. I was able to get it working on I2C(3) and I2C(2) but with the following sequence Wire.begin(3); Wire.setModule(3); Wire.begin(); If I omitted the first or the last line, the i2c port would only return zeros. I hope this helps. Also I found there was no need for pullups as my module already had them. But your experience would probably differ. I think energia on the Stellaris has a lot of bugs and would not as of now recommend it for serious work. But it is people like us who have to contribute to making it work. energia 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.