DS3231 (by Alex)
hello friends, i have been looking for a way to use ds3231 with ansic generated by ldmicro, i have only found examples based on arduino and others based on time, day, year option, have to say, my whim, what i only want for now is to know how could i use 1hz square wave option from ds3231 to connect via I2C to an external interrupt pin of my 16f877a and increase each second a variable called "seconds" for me is much easier doing like that a clock than configuring time/day/year option, i have it done on my arduino UNO board but just because everything can be found in the internet for arduino plataform. thanks a lot :-)
(no subject) (by Alex)
Hello i have been trying to just enable SQW pin working at exactly 1 hz of DS3231, i have made this code, could you tell me if it is ok?:
i have tested it in real life but it is like out of phase for about 2ms:
//================DS3231================
#define RTC_SDA PIN_C4
#define RTC_SCL PIN_C3
#use i2c(master, sda=RTC_SDA, scl=RTC_SCL)
void ds3231_init(void)
{
i2c_start();
i2c_write(0xD0);// WR to RTC
i2c_write(0x0E);
i2c_write(0xC0);//11000000
i2c_stop();
}