dfskGT 0 Posted July 7, 2014 Share Posted July 7, 2014 Hello, I just received a TM4C1294XL connected launchpad. I'm trying to get it working with L3G4200D gyroscope (it's a module from Parallax with pull-ups). The program runs as expected for a while and then freezes and I have to long press the reset button to get it working again. By importing the Energia sketch into CCSv6, I was able to find the program hangs at the Wire.endtrsmission(), in particular at line //Wait for any previous transaction to complete while(ROM_I2CMasterBusBusy(MASTER_BASE)); in the Wire library. I tried with another sensor and experience the same problem. Could somebody help me out? The related code is attached below (sorry for not knowing how to format the code in the post): void setup() { // Start the Ethernet and UDP Ethernet.begin(mac,ip); udp.begin(localPort); // Start I2C Wire.setModule(0); Wire.begin(); // Initilize the L3G4200D gyro gyro.init(); } void loop() { currentTime = millis(); interval = currentTime - lastTime; if (currentTime - lastTime >= 100) { // Serial.println(interval); lastTime = currentTime; // Get sensor data gyro.getRawData(); compseTxPacket(); IPAddress remoteIP(192,168,1,10); uint16_t remoteLocalPort = 13000; udp.beginPacket(remoteIP, remoteLocalPort); udp.write(txPacketBuffer, TX_PACKET_SIZE); udp.endPacket(); } } void L3G4200D::getRawData() { while((i2cReadReg(L3G4200D_REGISTER_STATUS_REG) & 0x08) == 0); Wire.beginTransmission(L3G4200D_ADDRESS); Wire.write(L3G4200D_REGISTER_OUT_X_INC); // first register to start read from Wire.endTransmission(); Wire.requestFrom(L3G4200D_ADDRESS, 6); while(Wire.available() < 6); byte raw_low; byte raw_high; raw_low = Wire.read(); raw_high = Wire.read(); data.xRawDPS = (raw_high << 8) | raw_low; raw_low = Wire.read(); raw_high = Wire.read(); data.yRawDPS = (raw_high << 8) | raw_low; raw_low = Wire.read(); raw_high = Wire.read(); data.zRawDPS = (raw_high << 8) | raw_low; } Quote Link to post Share on other sites
Mr.Cruz 0 Posted July 8, 2014 Share Posted July 8, 2014 I hope you're not the same person as @@vim505. See this response. Quote Link to post Share on other sites
dfskGT 0 Posted July 8, 2014 Author Share Posted July 8, 2014 It's a different question. Happens to have a similar title. Mine works for a while. It's a breakout board with pull-ups ready, shouldn't be hardware problem. Quote Link to post Share on other sites
L.R.A 78 Posted July 8, 2014 Share Posted July 8, 2014 you could add a timeout in the while with milis(); i can't realy advise in the specific sensor but other thing i did was specific for srf08 : before i did a resquest i made sure the sensor was not busy. i kept requesting the software revision and when it answered then it would be not busy, like so: int teste=255; do{ Wire.beginTransmission(113); Wire.write(byte(0x00)); Wire.endTransmission(); Wire.requestFrom(113, 1); if(1 <= Wire.available()) teste = Wire.read(); }while(teste==255); 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.