$regfile "m16def.dat" $crystal = 1000000 Config Scl = Porta.7 Config Sda = Porta.6 Config Lcdpin = Pin , Db7 = Porta.5 , Db6 = Porta.4 , Db5 = Porta.3 , Db4 = Porta.2 , Rs = Porta.0 , E = Porta.1 Config Lcd = 16 * 2 Dim Hour As Byte Dim Mine As Byte Dim Seco As Byte Dim Day As Byte Dim Dat As Byte Dim Month As Byte Dim Year As Byte Initlcd Cls Cursor Off Locate 1 , 1 Lcd "LCD1602 Init" Lowerline Lcd "RTC DS1307" Wait 2 Cls Mine = 35 Hour = 16 Day = 28 Month = 2 Year = 16 Seco = Makebcd(seco) I2cstart I2cwbyte &HD0 I2cwbyte 0 I2cwbyte Seco I2cstop Mine = Makebcd(mine) I2cstart I2cwbyte &HD0 I2cwbyte 1 I2cwbyte Mine I2cstop Hour = Makebcd(hour) I2cstart I2cwbyte &HD0 I2cwbyte 2 I2cwbyte Hour I2cstop Day = Makebcd(day) I2cstart I2cwbyte &HD0 I2cwbyte 3 I2cwbyte Day I2cstop Month = Makebcd(month) I2cstart I2cwbyte &HD0 I2cwbyte 5 I2cwbyte Month I2cstop Year = Makebcd(year) I2cstart I2cwbyte &HD0 I2cwbyte 6 I2cwbyte Year I2cstop Cls Lcd "OK" End