Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.
 
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
 
Can you post the schematic... Do a screen shot for me...
18f8720_zpsfotzdag9.jpg
 
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

 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top