Ich poste mal ein paar Ausschnitte.
Evtl fehlen ein paar Variablen und Sub Declarationen, oder sind zuviel...
Code:
$regfile = "m644def.dat"
$crystal = 16000000
Config Graphlcd = 240 * 64 , Dataport = Porta , Controlport = Portc , Ce = 2 , Cd = 3 , Wr = 0 , Rd = 1 , Reset = 4 , Mode = 6 ', Fs = 5 , Mode = 6
Config Dcf77 = Pind.7 , Timer = 1 , Inverted = 0 , Check = 1 , Update = 0 , Debug = 0 , Gosub = Sectic ', Timer1sec = 1
'Port A0-7: Display Dataport
'Port B0: +5V für DCF Empfänger
'Port B1:
'Port B2-3: I2C für DS1307
'Port B4-7: Externe Tasten
'Port C0-4: Display Kontrollport
'Port C5: High, wenn Uhrzeit gesendet wird. an 2313 D.2
'Port C6: Anforderung Beleuchtung
'Port C7: Ansteuerung Beleuchtung
'Port D0: Seriell Empfangen an 2313 B.1
'Port D1: Seriell Senden an 2313 B.0
'Port D2-4: Tasten für Funkuhrbedienung
'Port D5-6: Relais 1-2
'Port D7: Eingang DCF Empfänger
$baud = 38400 ' use baud rate
$hwstack = 128 ' default use 32 for the hardware stack
$swstack = 128 ' default use 10 for the SW stack
$framesize = 128 ' default use 40 for the frame space
Declare Sub Sekuendlich()
Declare Sub Sbtimers()
Dim Zeit_d As String * 8
Dim Datum_d As String * 8
Dim Suhrzeit As String * 1
Dim Zahl As String * 5
Dim Szeile(8) As String * 40
Dim Szeile5 As String * 5
Dim Stoppds As Byte
Dim Stoppdcf As Byte
Dim Stream As Byte
Dim Timers As Byte
Dim Takt As Integer
Dim Rprozalt As Byte
Dim Zeile As Byte
Dim Buhrzeit As Byte
Dim Ii As String * 5
Dim Belzeit As Byte
Dim Infozeit As Byte
Dim Sekalt As Byte
Dim Sekaltd As Byte
Dim Sein As String * 50
Dim Iein As Integer
Dim Pcmodus As Bit
Dim Bolinfo As Bit
Dim Modus As Byte
Dim Hh As Byte
Dim H As String * 2
Dim Mm As Byte
Dim M As String * 2
Dim Ss As Byte
Dim S As String * 2
Dim Wachhund As Byte
Dim Wachsek As Byte
Dim Wdatum As String * 8
Dim Wzeit As String * 8
Dim Wdatum1 As String * 8
Dim Wzeit1 As String * 8
Dim Wdatum2 As String * 8
Dim Wzeit2 As String * 8
Dim Empfangszeit As Integer ' Minutenzähler für den DCF Power
Dim Pcproz As Integer
Dim I As Byte
Dim X As Byte , Y As Byte
Dim Secalt As Byte
Dim A As Byte
Config Date = Dmy , Separator = . ' Deutsches-Format
Dim Zaehler As Byte
Dim Strzif As String * 1
Dim Zgross1 As Byte
Dim Zgross2 As Byte
Dim Zgross3 As Byte
Dim Zgross4 As Byte
Dim Zgross5 As Byte
Dim Zgross6 As Byte
Dim Zgross7 As Byte
Dim _dsday As Byte
Dim _dsmonth As Byte
Dim _dsyear As Byte
Dim _dssec As Byte
Dim _dsmin As Byte
Dim _dshour As Byte
Dim Wochentag As String * 11
Dim Eingang As String * 1
Dim B As Byte
Dim Nm As String * 8
Dim Uhrzeit As String * 8
Dim Mybaud As Long
Dim Einmod As Byte
Dim _dayofweek As Byte
Dim Bdatum As Bit
Dim Punkt As String * 1
Dim Byzif As Byte
Dim Zuletztgestellt As String * 17
Dcfpower Alias Portb.0
Taste1 Alias Pind.2
Taste2 Alias Pind.3
Taste3 Alias Pind.4
Relais1 Alias Portd.5
Relais2 Alias Portd.6
Sendezeit Alias Portc.5
Belan Alias Pinc.6
Beleuchtung Alias Portc.7
Set Dcfpower
Portb.1 = 1
Portb.4 = 1
Portb.5 = 1
Portb.6 = 1
Portb.7 = 1
Portc.6 = 1
Portd.2 = 1
Portd.3 = 1
Portd.4 = 1
Code:
Dim _dsday As Byte
Dim _dsmonth As Byte
Dim _dsyear As Byte
Dim _dssec As Byte
Dim _dsmin As Byte
Dim _dshour As Byte
Code:
'configure the scl and sda pins
Config Sda = Portb.3
Config Scl = Portb.2
'address of ds1307
Const Ds1307w = &HD0 ' Addresses of Ds1307 clock
Const Ds1307r = &HD1
Dim Weekday As Byte
Stoppds = 0
Stoppdcf = 0
Takt = 0
Mybaud = 19200
Zeile = 0
Enable Interrupts
Start Watchdog
Do
Reset Watchdog
Call Anzeigen
If Secalt = 1 Then
Secalt = 2
Call Sekuendlich
Call Sbtimers
Call Schalten
Secalt = 0
End If
Loop
End
Code:
Sectic:
Secalt = 1
Return
Sub Sekuendlich
If Stoppds = 0 Then
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 0 ' start address in 1307
I2cstart ' Generate start code
I2cwbyte Ds1307r ' send address
I2crbyte _dssec , Ack
I2crbyte _dsmin , Ack ' MINUTES
I2crbyte _dshour , Ack ' Hours
I2crbyte Weekday , Ack ' Day of Week
I2crbyte _dsday , Ack ' Day of Month
I2crbyte _dsmonth , Ack ' Month of Year
I2crbyte _dsyear , Nack ' Year
I2cstop
'_dayofweek = Makedec(weekday)
_sec = Makedec(_dssec) : _min = Makedec(_dsmin) : _hour = Makedec(_dshour)
_day = Makedec(_dsday) : _month = Makedec(_dsmonth) : _year = Makedec(_dsyear)
End If
If Dcfpower = 0 Then
If Wachhund = 5 Then
Time$ = Wzeit
Date$ = Wdatum
Gosub Settime
Set Dcfpower
Dcf_status.7 = 0
Empfangszeit = 0
Wachhund = 0
End If
If Wachsek = _sec Then
Wachhund = Wachhund + 1
Else
Wzeit = Wzeit1
Wdatum = Wdatum1
Wzeit1 = Wzeit2
Wdatum1 = Wdatum2
Wzeit2 = Time$
Wdatum2 = Date$
Wachsek = _sec
Wachhund = 0
End If
End If
End Sub
Sub Sbtimers()
If _min = 57 Then
If _sec > 30 Then
Set Dcfpower
Dcf_status.7 = 0
Empfangszeit = 0
End If
End If
If _min = 27 Then
Set Dcfpower
Dcf_status.7 = 0
Empfangszeit = 0
End If
If Empfangszeit < 634 Then
Empfangszeit = Empfangszeit + 1
End If
If Empfangszeit = 634 Then
Empfangszeit = 635
Wachhund = 0
Reset Dcfpower
End If
If Empfangszeit > 635 Then
Empfangszeit = 635
End If
End Sub
Code:
Pause:
Waitms 1
Return
Getdatetime:
Return
Setdate:
Stoppds = 1
If _day < 32 Then
If _month < 13 Then
If _year < 100 Then
_dsday = Makebcd(_day) : _dsmonth = Makebcd(_month) : _dsyear = Makebcd(_year)
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 4 ' starting address in 1307
I2cwbyte _dsday ' Send Data to SECONDS
I2cwbyte _dsmonth ' MINUTES
I2cwbyte _dsyear ' Hours
I2cstop
End If
End If
End If
Stoppds = 0
Return
Settime:
Dim Gestellt As Bit
Gestellt = 0
Stoppds = 1
Waitms 125
If _sec < 60 Then
If _min < 60 Then
If _hour < 24 Then
If _day < 32 Then
If _month < 13 Then
If _year < 100 Then
Gestellt = 1
_dssec = Makebcd(_sec ) : _dsmin = Makebcd(_min) : _dshour = Makebcd(_hour)
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 0 ' starting address in 1307
I2cwbyte _dssec ' Send Data to SECONDS
I2cwbyte _dsmin ' MINUTES
I2cwbyte _dshour ' Hours
I2cstop
_dsday = Makebcd(_day) : _dsmonth = Makebcd(_month) : _dsyear = Makebcd(_year)
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 4 ' starting address in 1307
I2cwbyte _dsday ' Send Data to SECONDS
I2cwbyte _dsmonth ' MINUTES
I2cwbyte _dsyear ' Hours
I2cstop
Zuletztgestellt = Date$ + "," + Time$
Reset Dcfpower
Wachhund = 0
End If
End If
End If
End If
End If
End If
If Gestellt = 0 Then
Dcf_status.7 = 0
Empfangszeit = 0
End If
Stoppds = 0
Return
In der DCF77.lib
Code:
Getdatetime:
Setdate:
Settime:
Ret
auskommentieren.
Code:
;Getdatetime:
;Setdate:
;Settime:
;Ret
ansonsten mal deinen Code hier posten.
Lesezeichen