RTC x1226

Your source for all things Atmel.

Moderator: phalanx

Post Reply
Maksim_maksim
Posts: 1
Joined: Wed Sep 16, 2015 9:34 am

RTC x1226

Post by Maksim_maksim » Wed Sep 16, 2015 9:42 am

Hi all. I wrote code for RTC x1226, bun dosn't work (((

Code: Select all

#include <Wire.h>
#include <avr/interrupt.h>
byte seconds, hours, minutes, date, months, years, statusReg;

byte a0,a1,a2,a3,a4,a5,a6,a7,a8,i;
byte a[64];


void setup () {
  
  Serial.begin(9600);
  Wire.begin();
  
  Wire.beginTransmission(0x6F); 
  Wire.write(0xde);
//  Wire.write(0x00);
  Wire.write(0x3f); //Int Register
  Wire.write(0x02);
  Wire.endTransmission();
  
   Wire.beginTransmission(0x6F); 
  Wire.write(0xde);
 // Wire.write(0x00);
  Wire.write(0x3f); //Int Register
  Wire.write(0x06);
  Wire.endTransmission();
  
  Wire.beginTransmission(0x6F); 
  Wire.write(0xde);
//  Wire.write(0x00);
  Wire.write(0x11); //Int Register
  Wire.write(0x08);
  Wire.endTransmission();
  
  delay(10);
  
   Wire.beginTransmission(0x6F); 
  Wire.write(0xde);
  Wire.write(0x00);
 Wire.write(0x3f); //Int Register
  Wire.write(0x00);
  Wire.endTransmission();
}


void loop () {
    
  Wire.beginTransmission(0x6F); 
  Wire.write(0xae);
//  Wire.write(0x00);
  Wire.write(0x00);
  Wire.write(0x00);
  Wire.write(55);  
  Wire.endTransmission();
  
  
    Wire.beginTransmission(0x6F); 
  Wire.write(0xaf);
//  Wire.write(0x00);
  Wire.write(0x00);
  Wire.write(0x00);
//  Wire.write(55);  

 Serial.println(Wire.read());
  Serial.println("------"); 
  
//  Wire.requestFrom(0x6f,1); // now get the byte of data...


  for (i=0; i<=8; i++){
  a[i]=Wire.read();
    Serial.print(a[i]);
    Serial.print(",");
  }
  
 Wire.endTransmission();        
 // Serial.println(statusReg);
 Serial.println("------"); 
  delay(1000);
  
 }
 
 byte readStatusReg(byte val){

  Wire.beginTransmission(0x6f);
  Wire.write(0x3f); // read status reg to clr bits
  Wire.endTransmission();
  Wire.requestFrom(0x6f,1); // now get the byte of data...
  statusReg=Wire.read();
  return(statusReg);

}
SPI-scaner find this RTC on adress 0x6F

User avatar
phalanx
Non-SFE Guru
Posts: 1981
Joined: Sun Nov 30, 2003 8:57 am
Location: Candia, NH

Re: RTC x1226

Post by phalanx » Wed Sep 16, 2015 12:53 pm

I'm not so sure I saw a question anywhere in your post.

-Bill

Post Reply