# SQW output of DS1307

Status
Not open for further replies.

#### johnl69

##### Member
Im trying to use the SQW output from a ds1307 to trigger a interrupt routine but I cant get the chip to produce the signal.

According to the datasheet the SQW is enabled by setting it 4 of register 07h which I have done with;

C:
write_ds1307(0x00, 0x00);   // Clock enabled
write_ds1307(0x07, 0b00010000);   // SQW output ON 1hz signal
But I cant get a signal generated. I know the pin and ISR are configured correctly as I can get the ISR to work with a switch connected.

The write_ds1307() routine is;
C:
void write_ds1307(unsigned short address, unsigned short w_data) //call this function to write date and time
//to the date and time registers.
{

StartI2C(); // Start condition I2C on bus
IdleI2C();
IdleI2C();
IdleI2C();
IdleI2C();
StopI2C(); // Stop condition I2C on bus
}
and is working fine to update the time.

#### Nigel Goodwin

##### Super Moderator
Do you have a pull-up resistor, as the output if open-collector, so won't work without a pull-up.

#### johnl69

##### Member
Yes, im only simulating in proteus at the minute but its got the digital "pull up" resistor on it.

#### Nigel Goodwin

##### Super Moderator
Yes, im only simulating in proteus at the minute but its got the digital "pull up" resistor on it.
Do it in real life, what's the point of 'hoping' that a computer simulation works correctly?.

#### johnl69

##### Member
Do it in real life, what's the point of 'hoping' that a computer simulation works correctly?.
I dont have a board yet to put 18f8720 on to a breadboard yet so proteus is the only option I have

#### johnl69

##### Member
OK so can get the program to run and produce a 1hz signal on a 18f4550 simulation and on a breadboard but it still refuses to work on a simulated 18f8720

#### Ian Rogers

##### User Extraordinaire
Forum Supporter
You are correct.... There is an issue with the output from the DS1307 ... It seems to generate an AC square wave +2.5v to -2.5v... I will ring David in the morning and ask...

Rubbish or what!!!

#### johnl69

##### Member
You are correct.... There is an issue with the output from the DS1307 ... It seems to generate an AC square wave +2.5v to -2.5v... I will ring David in the morning and ask...

Rubbish or what!!!
but it works on a different chip, not the best of square waves but its enough to test my routine

#### johnl69

##### Member
Apparently... I had the DC, AC, GND and OFF switched to AC..

There was a fault on the pic18f8720 but it's resolved in the latest build..
Thanks for that. Ive got around it by using the signal generator to produce the 1hz pulse,

Status
Not open for further replies.