I am trying to interface DS1307 RTC with the MCU mentioned. I want to make a lifetime timer which tells the time this project has worked in field, and display this timer on an LCD.
I am new to microcontrollers but using LCD and I2C libraries already built-in in the MikroC pro for PIC compiler will I hope save me from low-level programming.
Now if I understand correctly, the steps to write or read something from the RTC would be:
1) I2C_Start(); 2) I2C_Write(DS1307_Address); 3) I2C_Write(Register Address); 4) I2C_Write(Data to be written); 5) I2C_Stop();
and for reading:
1) I2C_Start(); 2) I2C_Write(DS1307_Address); 3) I2C_Write(Register Address); 4) I2C_Repeated_Start(); 5) I2C_Write(DS1307_Address); 6) I2C_Rd(); 7) I2C_Stop();
My issue is that what will the
DS1307_Address be, if it is the only device on the Bus?
My approach will be to set the BIT7 of 00h or
CH bit of the DS1307 low whenever the device is running, and set it high just before shutting down. I do not want the RTC to count the project off time as well. Is this approach feasible?
My schematic is as following: