Pages: 1 [2]   Go Down
Author Topic: Wire and OneWire conflicts?  (Read 2335 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
#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.
Logged

Pages: 1 [2]   Go Up
Jump to: