Trying to get an ATtiny85 talking to a DS3231 RTC and I thought all was well since the data being returned looks good, but when I check the return status from endTransmission() I find that it's returning
#define USI_TWI_MISSING_STOP_CON 0x04 // Generated Stop Condition not detected on bus
Wondering if anyone else has encountered/corrected this.
//Read the time from a DS3231 with ATtiny85 @ 8MHz
//Arduino 1.0.5 with Arduino-Tiny core
//Jack Christensen 10Aug2013
#include <SoftwareSerial.h>
#include <TinyWireM.h> //http://playground.arduino.cc/Code/USIi2c
const uint8_t RTC_ADDR = 0x68;
const unsigned long READ_INTERVAL = 1000; //milliseconds
SoftwareSerial Debug = SoftwareSerial(3, 4);
void setup(void)
{
Debug.begin(19200);
}
void loop(void)
{
static unsigned long msLast;
unsigned long ms = millis();
if (ms - msLast >= READ_INTERVAL) {
msLast = ms;
//read seconds, minutes, hours registers from the rtc
TinyWireM.begin();
TinyWireM.beginTransmission(RTC_ADDR);
TinyWireM.send(0x00);
uint8_t txStatus = TinyWireM.endTransmission();
TinyWireM.requestFrom(RTC_ADDR, 3);
uint8_t s = TinyWireM.receive();
uint8_t m = TinyWireM.receive();
uint8_t h = TinyWireM.receive();
//print the i2c status and the time from the rtc
Debug.print(txStatus, DEC);
Debug.print(' ');
Debug.print(h, HEX);
Debug.print('h');
Debug.print(m, HEX);
Debug.print('m');
Debug.print(s, HEX);
Debug.println('s');
Debug.end();
}
}
Output seems fine, except for the error code:
4 11h11m10s
4 11h11m11s
4 11h11m12s
4 11h11m13s
4 11h11m14s
4 11h11m15s
Schematic attached.