Stalker V2 Help!! Set the time? RFID Logger

The plot thickens. The RTC behaves itself when using the RX8025 library. Here is a very stripped down version of the example source code linked in the Stalker wiki page.

#include "RX8025.h"
#include <Wire.h>

unsigned char hour=0;
unsigned char minute=0;
unsigned char second=0;
unsigned char week=0;
unsigned char year=0;
unsigned char month=0;
unsigned char date=0;

unsigned char RX8025_time[7]=
{
0x00,0x54,0x09,0x03,0x10,0x11,0x10 //second, minute, hour, week, date, month, year, BCD format
};

//======================================
void setup(void)
{
Serial.begin(9600);
RX8025_init();
}
//======================================
void loop(void)
{
getRtcTime();
print_RX8025_time();
Serial.println("--------------next--data---------------");
delay(2000);
}

//==============================================
void print_RX8025_time(void)
{
Serial.print(year,DEC);
Serial.print("/");
Serial.print(month,DEC);
Serial.print("/");
Serial.print(date,DEC);
switch(week)
{
case 0x00:
{
Serial.print("/Sunday ");
break;
}
case 0x01:
{
Serial.print("/Monday ");
break;
}
case 0x02:
{
Serial.print("/Tuesday ");
break;
}
case 0x03:
{
Serial.print("/Wednesday ");
break;
}
case 0x04:
{
Serial.print("/Thursday ");
break;
}
case 0x05:
{
Serial.print("/Friday ");
break;
}
case 0x06:
{
Serial.print("/Saturday ");
break;
}
}
Serial.print(hour,DEC);
Serial.print(":");
Serial.print(minute,DEC);
Serial.print(":");
Serial.println(second,DEC);
}

Pressing the reset button with this code loaded does not reset the RTC, unlike in the case of the DS1307RTC and Time libs, used in the "TimeRTCSet" example. Reading through the code of the RX8025 and DS1307RTC libs, I cannot for the life of me figure out what the offending difference might be. Even worse, I 'd have thought DS1307RTC shouldn't work at all since it seems to think the address of the RTC is 0x68 (#define DS1307_CTRL_ID 0x68 in DS1307RTC.cpp below) whereas the RX8025 suggests the RTC lives at number 0x32 (#define RX8025_address 0x32 RX8025.cpp below).

DS1307RTC has what looks like a constructor whose only statement is to fire up the Wire comms:

DS1307RTC::DS1307RTC()
{
  Wire.begin();
}

whereas RX8025 has function RX8025_init() which both fires up Wire comms as well as sending 0xe0 to the RTC, followed by 0x20 and 0x00. I don't know what these characters are actually doing but, for some reason, DS1307RTC seems to be communicating OK with something, even if it's at another address than whatever RX8025 is talking to and without having sent these characters.

When it comes to reading time, both seem to be doing similar things. They send 0x00 and ask for some chars. However, notice a difference, in function void DS1307RTC::read( tmElements_t &tm), DS1307RTC seemingly asks for 7 values (assuming tmNbrFields == 7 as the comment suggests) whereas in function void getRtcTime(void) RX8025 asks for 8 values and discards the first one! WTF? Full code of RX8025.cpp and DS1307RTC follow.

RX8025.cpp:

#include <Wire.h>
#include "RX8025.h"
//********************************************************************

//===============================================
#define RX8025_address 0x32

unsigned char RX8025_Control[2]=
{
0x20,0x00
};

//===============================================
void setRtcTime(void)
{
Wire.beginTransmission(RX8025_address);
Wire.send(0x00);
for(unsigned char i=0; i<7; i++)
{
Wire.send(RX8025_time*);*

  • }*
  • Wire.endTransmission();*
    }
    //===============================================
    uint8_t bcd2bin (uint8_t val)
    {
    _ return val - 6 * (val >> 4);_
    }
    uint8_t bin2bcd (uint8_t val)
    {
    _ return val + 6 * (val / 10);_
    }
    //===============================================
    void getRtcTime(void)
    {
  • unsigned char i=0;*
  • Wire.beginTransmission(RX8025_address);*
  • Wire.send(0x00);*
  • Wire.endTransmission();//*
  • Wire.requestFrom(RX8025_address,8);*
    RX8025_time*= Wire.receive();//not use*
    * while(Wire.available())*
    * {*
    RX8025_time*= Wire.receive();
    _ i++;
    }
    Wire.endTransmission();//_
    year = bcd2bin(RX8025_time[6]&0xff);
    month = bcd2bin(RX8025_time[5]&0x1f);
    date = bcd2bin(RX8025_time[4]&0x3f);
    week = bcd2bin(RX8025_time[3]&0x07);
    hour = bcd2bin(RX8025_time[2]&0x3f);
    minute = bcd2bin(RX8025_time[1]&0x7f);
    second = bcd2bin(RX8025_time[0]&0x7f);
    _}
    //===============================================
    void RX8025_init(void)
    {
    Wire.begin();_
    Wire.beginTransmission(RX8025_address);//clear power on reset flag, set to 24hr format*

    * Wire.send(0xe0);*
    * for(unsigned char i=0; i<2; i++)*
    * {*
    Wire.send(RX8025_Control*);
    _ }
    Wire.endTransmission();
    //setRtcTime();
    }
    [/quote]*_