void Write_DS1307(void)
{
unsigned char i, hour_format;
// Make sure we enable the Oscillator control bit CH=0 on Register 0x00
ds1307_addr[0]=ds1307_addr[0] & 0x7F;
// Start the I2C Write Transmission
i2c_start(DS1307_ID,DS1307_ADDR,TW_WRITE);
// Start from Address 0x00
i2c_write(0x00);
// Write the data to the DS1307 address start at 0x00
// DS1307 automatically will increase the Address.
ds1307_addr[0] = '0';
i2c_write(dec2bcd(ds1307_addr[0]));//second
_delay_ms(10);
ds1307_addr[1] = '1';
i2c_write(dec2bcd(ds1307_addr[1]));//minute
_delay_ms(10);
ds1307_addr[2] = '16';
i2c_write(dec2bcd(ds1307_addr[2]));//hour
_delay_ms(10);
ds1307_addr[3] = '0';
i2c_write(dec2bcd(ds1307_addr[3]));//day of the week
_delay_ms(10);
ds1307_addr[4] = '2';
i2c_write(dec2bcd(ds1307_addr[4]));//day of the month
_delay_ms(10);
ds1307_addr[5] = '6';
i2c_write(dec2bcd(ds1307_addr[5]));//month
_delay_ms(10);
ds1307_addr[6] = '13';
i2c_write(dec2bcd(ds1307_addr[6]));//year
}