A little help on how to manage SQW pin of DS3231

Hello all, I start saying that this is my first project with arduino. I bought this http://www.icstation.com/product_info.php?products_id=2416#.U3upsyjYGSo and i'm using the included library to handle it. But i'm trying to understand if I can use the SQW pin to receive an interrupt on aprecise time. The library seems to don't handle such things. Any ideas?

Any ideas?

Yeah, click on the GIANT DOWNLOAD BUTTON and down load the zip file and read the datasheet.

thank you to suggest to me a thing that i've just done. If I ask help, is because I still don't understand. So, i'm sorry to be stupid...

It’s on page 9,13,14, & 15

How about giving us a little more information You specify what frequency you want on the SQW pin.

http://www.robot-electronics.co.uk/acatalog/I2C_Tutorial.html

  /*
  1 Hz Test
  Copyright 2012, all rights reserved.
  James M. Eli
  1/9/2012
 
  project parts:
    (1) arduino 16MHz
    (1) ChronoDot RTC (DS3231SN)
    (1) breadboard
    (1) 10 ohm resister (pullup)
    (7) wires
 
  DS3231SN TXCO RTC (ChronoDot) pin outs:
  CD - Arduino - Port
  SQW - D2  - Port D2 (tied thru 10K resister to VCC)
  GND - GND - Ground
  VCC - VCC - 5V
*/
#include <Wire.h>
 
//millisecond counter
volatile unsigned long my_timer0_millis;
//ms counters for arduino & TXC0
volatile unsigned long us_t, us_a;
//boolean flag
volatile bool flag;
 
//this interrupt is called on a TCXO RTC 1Hz SQW
ISR(INT0_vect) {  //PD2 or D2 pin
  unsigned long m;
  uint8_t t;
 
  //assumptions here: arduino 168/328 running @ 16MHz
  m = my_timer0_millis;
  t = TCNT0;
  if ((TIFR0 & _BV(TOV0)) && (t < 249))
    m++;
  //save current microsecond [us] count
  us_a = ((m*250) + t)*(64/clockCyclesPerMicrosecond());
  //set flag
  flag = true;
}
 
//timer0 interrupt handler
ISR(TIMER0_COMPA_vect) {
  //incremented every 1ms by arduino timer0
  my_timer0_millis++;
}
 
//returns current millis count
unsigned long myMillis(void) {
  unsigned long m;
  uint8_t oldSREG;
 
  oldSREG = SREG;
  cli();
  m = my_timer0_millis;
  SREG = oldSREG;
  return m;
}
 
void setup(void) {
  //init various
  us_t = 0;
  flag = false;
  //turn off interrupts
  cli();
 
  //replace arduino timer0 code with our timer
  my_timer0_millis = 0;
  //16Mhz/64 prescale/250 counts = 16000000/64/250 = 1000us (1ms)
  TCCR0A = 0;
  TCCR0A |= (1<<WGM01); //CTC mode, top=OCR0A, TOV0 set@max, update immediate
  TCCR0B = 0;
  TCCR0B |= (1<<CS01) | (1<<CS00); //Fcpu/64
  TIMSK0 |= (1<<OCIE0A); //enable CTC A interrupt
  OCR0A = 249; //249 results in a 250 count rollover
  TCNT0 = 0;
 
  //setup digital #2 external interrupt
  EICRA |= (1<<ISC00) | (1<<ISC01);  
  EIMSK |= (1<<INT0);
 
  //enable interrupts
  sei();
 
  //init wire & serial
  Wire.begin();
  Serial.begin(9600);
  //setup square wavew at choice of 0=1Hz/8=1024Hz/16=4096Hz/24=8192Hz  <==READ THIS ! ! ! 
  Wire.beginTransmission(104);  
  //select control register
  Wire.send(0x0e);
  //set square wave @ 1 Hz  (setup square wavew at choice of 0=1Hz/8=1024Hz/16=4096Hz/24=8192Hz)
  // code shows 1 Hz selection ; 
  Wire.send(0);    // <======(code shows 1 Hz selection ; )(change value to "8" for 1khz)
  Wire.endTransmission();
}
 
void loop(void) {
  Serial.println("# Starting Test");
 
  while(1) {  //endless loop
    if (flag) {
      if (us_t == 0)
        us_t = us_a;
      else
        us_t += 1000000;
      Serial.print(us_t/1000000);
      Serial.print(", ");
      Serial.println(us_a - us_t);
      flag = false;
    } //if
  }   //while
 
}     //loop

You will need to connect the SQW output to the appropriate pin on the Arduino, run some code to turn on the SQW output at the correct frequency (see the DS3231 data sheet) and then use an external or pin change interrupt to process the signal from SQW. There are a few examples on the web for how to do this. Here is one: http://timewitharduino.blogspot.com/2011/12/wise-clock-4-using-rtc-1hz-heartbeat.html