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
}
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...
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...