DS3234 RTC Square wave output problem

I am using DS3234 SparkFun DeadOn RTC Breakout board. I have interfaced DS3234 with my Arduino UNO and tested the example sketch given by sparkfun. The code works fine but I am not able to get the square wave output from SQW pin. I used a pull up resistor as instructed by data sheet but SQW pin is continuously giving 5 Volts.
I made some minor changes in code to use SQW output as interrupt whose code is given below so it has to print “count” value in serial monitor on the rising edge of the square wave but nothing prints since the pin’s output stays at 5 Volts.

#include <SPI.h>

const int  cs=8; //chip select
const byte interruptPin = 2;
volatile int count = 0;
 

void setup() {

  Serial.begin(9600);
  pinMode(interruptPin, INPUT);
  attachInterrupt(digitalPinToInterrupt(interruptPin), blink, RISING);

  RTC_init();

  //day(1-31), month(1-12), year(0-99), hour(0-23), minute(0-59), second(0-59)

  SetTimeDate(11,12,13,14,15,16);

}

 

void loop() {

  Serial.println(ReadTimeDate());

  delay(1000);

}

//=====================================

int RTC_init(){

      pinMode(cs,OUTPUT); // chip select

      // start the SPI library:

      SPI.begin();

      SPI.setBitOrder(MSBFIRST);

      SPI.setDataMode(SPI_MODE3); // both mode 1 & 3 should work

      //set control register

      digitalWrite(cs, LOW); 

      SPI.transfer(0x8E);

      SPI.transfer(0x60); //60= disable Osciallator and Battery SQ wave @1hz, temp compensation, Alarms disabled

      digitalWrite(cs, HIGH);

     delay(10);

}

//=====================================

int SetTimeDate(int d, int mo, int y, int h, int mi, int s){

    int TimeDate [7]={s,mi,h,0,d,mo,y};

    for(int i=0; i<=6;i++){

        if(i==3)

            i++;

        int b= TimeDate[i]/10;

        int a= TimeDate[i]-b*10;

        if(i==2){

            if (b==2)

                b=B00000010;

            else if (b==1)

                b=B00000001;

        }  

        TimeDate[i]= a+(b<<4);

           

        digitalWrite(cs, LOW);

        SPI.transfer(i+0x80);

        SPI.transfer(TimeDate[i]);       

        digitalWrite(cs, HIGH);

  }

}

//=====================================

String ReadTimeDate(){

    String temp;

    int TimeDate [7]; //second,minute,hour,null,day,month,year     

    for(int i=0; i<=6;i++){

        if(i==3)

            i++;

        digitalWrite(cs, LOW);

      SPI.transfer(i+0x00);

        unsigned int n = SPI.transfer(0x00);       

        digitalWrite(cs, HIGH);

        int a=n & B00001111;   

        if(i==2){  

            int b=(n & B00110000)>>4; //24 hour mode

            if(b==B00000010)

                b=20;       

            else if(b==B00000001)

                b=10;

            TimeDate[i]=a+b;

        }

        else if(i==4){

            int b=(n & B00110000)>>4;

            TimeDate[i]=a+b*10;

        }

        else if(i==5){
            int b=(n & B00010000)>>4;

            TimeDate[i]=a+b*10;

        }

        else if(i==6){

            int b=(n & B11110000)>>4;

            TimeDate[i]=a+b*10;

        }

       else{  

            int b=(n & B01110000)>>4;

            TimeDate[i]=a+b*10;

            }

    }

    temp.concat(TimeDate[4]);

   temp.concat("/") ;

    temp.concat(TimeDate[5]);

    temp.concat("/") ;

    temp.concat(TimeDate[6]);

    temp.concat("     ") ;

    temp.concat(TimeDate[2]);

    temp.concat(":") ;

    temp.concat(TimeDate[1]);

    temp.concat(":") ;

    temp.concat(TimeDate[0]);

  return(temp);

}

void blink() {
  Serial.println(count); 
}

You should never use serial inside an ISR. How do you know that the pin stays at 5V? Did you measure it, or are you depending on the serial print of “count” to tell?

I have measured it with voltmeter which reads 5V and also serial monitor is showing nothing.

Try changing this...

SPI.transfer(0x60); //60= disable Osciallator and Battery SQ wave @1hz, temp compensation, Alarms disabled

to 0x00 and see what happens. What value resistors are you using for pullup?

No I tried 0x00 not working… And pull up resistor i tried are 3.7K and 18K

It has an onboard 10k pullup resistor.

Perhaps unrelated, but here's some code that does nothing:

           if (b==2)

                b=B00000010;

            else if (b==1)

                b=B00000001;

Why?

According to data sheet SQW required external pull up resistor.. https://www.sparkfun.com/datasheets/BreakoutBoards/DS3234.pdf Page number 8

hasanusama: According to data sheet SQW required external pull up resistor.. https://www.sparkfun.com/datasheets/BreakoutBoards/DS3234.pdf Page number 8

That's the IC. The PCB has a pullup resistor installed. Look at the schematic.

In RTC_init() try this

 SPI.setDataMode(SPI_MODE1);

and this

    SPI.transfer(0x8E);
    SPI.transfer(0x00);

together.

Pete