$regfile = "8535def.dat" $crystal = 7372800 $baud = 9600 Config Lcd = 16 * 2 Config Lcdpin = Pin , Db4 = Pinc.3 , Db5 = Pinc.2 , Db6 = Pinc.1 , Db7 = Pinc.0 , E = Pinc.5 , Rs = Pinc.4 Config Sda = Porta.0 Config Scl = Porta.7 Const Adresw1 = 160 'write of 8535 - Slaveaddresse, &HA0 Const Adresr1 = 161 'read address of 8535 - Slaveaddresse, &HA1 Config Timer0 = Timer , Prescale = 1024 ' Timer0 Als Timer , Vorteiler = 1024 Dim Hours1 As Byte , Hh As Byte Dim Minutes1 As Byte , Mm As Byte Dim Seconds1 As Byte , Ss As Byte Dim Days1 As Byte , Dd As Byte Dim Months1 As Byte , Mo As Byte Declare Sub Clock_read Declare Sub Lcd_clock Declare Sub Werte_srampcf8583_speichern 'Ddra.3 = 1 On Timer0 Oninterrupt ' beiTimer0 -interrupt Enable Interrupts Enable Timer0 ' FreigabeTimerinterrupt Do 'Endlosschleife Nop Loop End ' EndeProgramm 'Call Clock_read 'Um die Zeit aus den PCF-Registern auszulesen Sub Clock_read 'I2cstart 'Liest die Sekunden aus der Addresse &H02 'I2cwbyte Adresw1 'I2cwbyte &H02 'I2cstart 'I2cwbyte Adresr1 'I2crbyte Seconds1 , Ack 'I2crbyte Minutes1 , Ack 'I2crbyte Hours1 , Ack 'I2crbyte Days1 , Ack 'I2crbyte Months1 , Nack 'I2cstop I2cstart 'Liest die Stunden aus der Addresse &H04 I2cwbyte Adresw1 I2cwbyte &H04 I2cstart I2cwbyte Adresr1 I2crbyte Hours1 , Nack I2cstop I2cstart 'Liest die Minuten aus der Addresse &H03 I2cwbyte Adresw1 I2cwbyte &H03 I2cstart I2cwbyte Adresr1 I2crbyte Minutes1 , Nack I2cstop I2cstart I2cwbyte Adresw1 I2cwbyte &H02 I2cstart I2cwbyte Adresr1 I2crbyte Seconds1 , Nack I2cstop I2cstart 'Liest die Tage aus der Addresse &H05 I2cwbyte Adresw1 I2cwbyte &H05 I2cstart I2cwbyte Adresr1 I2crbyte Days1 , Nack I2cstop I2cstart 'Read address h06 of die Echtzeituhr - Die month I2cwbyte Adresw1 I2cwbyte &H06 I2cstart I2cwbyte Adresr1 I2crbyte Months1 , Nack I2cstop 'Call Lcd_clock End Sub Sub Lcd_clock 'Routine um die Uhr an der LCD anzuzeigen Cls Cursor Off Locate 1 , 1 Lcd Bcd(hours1) Locate 1 , 3 Lcd ":" Locate 1 , 4 Lcd Bcd(minutes1) Locate 1 , 6 Lcd ":" Locate 1 , 7 Lcd Bcd(seconds1) Locate 2 , 1 Lcd Bcd(days1) Locate 2 , 3 Lcd "." Locate 2 , 4 Lcd Bcd(months1) 'Call Clock_read End Sub Sub Werte_srampcf8583_speichern 'Speichert die Werte der Uhr in SRAM der Uhr; Freier Speicher &H0F - &HFF Ss = Seconds1 Mm = Minutes1 Hh = Hours1 Dd = Days1 Mo = Months1 I2cstart I2cwbyte Adresw1 I2cwbyte 16 I2cwbyte Ss 'speichere die Sekunden an Address 16(&H10) in SRAM I2cwbyte Mm 'speichere die Minuten an Address 17 in SRAM I2cwbyte Hh 'speichere die Stunden an Address 18 in SRAM I2cwbyte Dd 'speichere die Tage an Address 19 in SRAM I2cwbyte Mo 'speichere die Monate an Address 20 in SRAM I2cstop End Sub Oninterrupt: Waitms 80 Call Clock_read Call Lcd_clock Call Werte_srampcf8583_speichern 'Toggle Ddra.3 Return