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();
    WriteI2C(0xD0); // addresses the chip
    IdleI2C();
    WriteI2C(address); // write register address
    IdleI2C();
    WriteI2C(w_data); // write register address
    IdleI2C();
    StopI2C(); // Stop condition I2C on bus
}
and is working fine to update the time.
 
Do you have a pull-up resistor, as the output if open-collector, so won't work without a pull-up.
 
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
 
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!!!
 
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

 
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..
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…