The DS1307 is a well known SRTC and it operates with a backup battery. If yours is not, this must be because either the battery is dead or it's too low voltage (get a new 3V one), excluding any defect to the chip.
>> Just wondering if there is any line of code I have to add to initialize the chip start up...
No. If it is not keeping time between Vbat and Vcc swaps there's nothing you can do other than setting the time as tabstop suggests above. This is how you will do it (taken a long time ago from some PIC blog I don't really remember anymore):
Code:
void set_rtc(unsigned short addr, unsigned short data) {
I2C_Start(); // Start signal. Obligatory!
I2C_Wr(0xD0); // I2C send byte: device address(0xD) + Write (0))
I2C_Wr(addr); // send byte
I2C_Wr(data); // send data
I2C_Stop(); // Stop signal. Obligatory!
}
// Set the NOW time (my local time)
set_rtc(0,0x80); // 0 second reset and stop oscillator
set_rtc(1,0x15); // 15 minutes
set_rtc(2,0x18); // 18 hours
set_rtc(3,0x02); // Monday
set_rtc(4,0x01); // Day 1
set_rtc(5,0x08); // Month 8th
set_rtc(6,0x11); // Year 2011
set_rtc(7,0x10); // Control. Always the same.
set_rtc(0,0x00); // Start oscillator