Go Down

Topic: Wire and OneWire conflicts? (Read 3115 times) previous topic - next topic

jims

I generally suspect running out of SRAM when combining things makes them fail. All those strings that you Serial.print take SRAM, so those are suspect as well. A cruel twist that the very thing you might use to debug causes the bugs.

I looked back over OneWire now that I have more experience in the Arduino environment. It is probably sensitive to interrupts. I'd wrap the read bit and write bit routines in cli() and sei() calls to disable interrupts in them, but you would also need a tweeked delayMicroseconds because the one in 0007 turns on interrupts as it exits.

Other than that I don't see any resource that would conflict. I suspect SRAM usage.

drd

I got DS1631 behaving both with Wire and software i2c.  Here's the Wire code:

Code: [Select]

#include <Wire.h>
void setup()
{
 Wire.begin();
 Serial.begin(19200);
}

void loop() {
 ds1631();
}

void ds1631() {
 uint8_t ret, dhi, dlo;
 Wire.beginTransmission(0x48);
 Wire.send(0x51);
 Wire.endTransmission();
 delay(750);
 Wire.beginTransmission(0x48);
 Wire.send(0xAA);  // read temperature command...
 Wire.endTransmission();
 Wire.requestFrom(0x48, 2);
 dhi = Wire.receive();
 dlo = Wire.receive();
 Wire.endTransmission();
 int ihi = (int) (dhi);
 int ilo = (int) (dlo);
 int frac =  ihi * 256 + ilo;
 if (dhi > 0x80) frac = frac - 65536;
 int temp = frac/256;
 frac = frac - temp*256;
 Serial.print(" Temp (C) = ");
 Serial.print(temp);
 Serial.print(".");
 if(frac < 100) Serial.print("0");
 if(frac < 10) Serial.print("0");
 Serial.println(frac);
}


Wire has no means to do a repeated start, as the 1631 wants, it won'd send anything unless you do a stop, but it works OK even with the stop.

D.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy