Go Down

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


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.


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

Code: [Select]

#include <Wire.h>
void setup()

void loop() {

void ds1631() {
 uint8_t ret, dhi, dlo;
 Wire.send(0xAA);  // read temperature command...
 Wire.requestFrom(0x48, 2);
 dhi = Wire.receive();
 dlo = Wire.receive();
 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) = ");
 if(frac < 100) Serial.print("0");
 if(frac < 10) Serial.print("0");

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.


Go Up