void rtc_setTime()
{
//i2c_Wait();
i2c_start();
i2c_write(0xa2);
i2c_write(0x02);
i2c_write (0x00) ; //set sec
i2c_write( 0x00); //min
i2c_write(0x10); //hou 10:59:00;
i2c_stop();
}
void rtc_getTime()
{
i2c_Wait();
i2c_start ( ) ; //transmit START condition
i2c_write (0xa2) ;
i2c_write (0x02);
i2c_stop();
i2c_start ( ) ;
i2c_write(0xa3);
seconds = i2c_read(1) ;
minutes = i2c_read(1) ;
hours = i2c_read(0);
i2c_stop ( ) ;
seconds=seconds&0x7f;
minutes =minutes &0x7f;
hours = hours &0x3f;
seconds = ((seconds & 0xf0) >> 4)*10 + (seconds & 0x0F); // Transform seconds
minutes = ((minutes & 0xf0) >> 4)*10 + (minutes & 0x0F); // Transform minutes
hours = ((hours & 0xf0) >> 4)*10 + (hours & 0x0F); // Transform hours
hexmin=minutes;
LCDCmd(0xCC);
LCDWriteInt( seconds,2);
LCDCmd(0xCB);
LCDWriteString(":");
LCDCmd(0xC9);
LCDWriteInt( minutes,2);
LCDCmd(0xC8);
LCDWriteString(":");
LCDCmd(0xC6);
LCDWriteInt( hours,2);
}