hi sihe:
Code:
$regfile = "m48def.dat"
$crystal = 4000000
Dim Segment_zahl(10) As Byte
Dim Segment_anzeige(8) As Byte
Dim Zeit(4) As Byte
Dim Eezeit(4) As Eram Byte
Dim Z As Byte
Dim I As Word
Dim Timerpreset As Word
Dim Taste1 As Bit
Dim Taste2 As Bit
Dim Taste3 As Bit
Dim Taste4 As Bit
Taste4 = 1
Declare Sub Zeiteinstellung
Declare Sub Vorgabe
Declare Sub Sound
Declare Sub Sound1
Config Portd.0 = Output 'A
Config Portd.1 = Output 'B
Config Portd.2 = Output 'C
Config Portd.3 = Output 'D
Config Portd.4 = Output 'E
Config Portd.5 = Output 'F
Config Portd.6 = Output 'G
Config Portb.1 = Output 'Digi 1
Config Portb.2 = Output 'Digi 2
Config Portb.3 = Output 'Digi 3
Config Portb.4 = Output 'Digi 4
Config Portc.2 = Output 'Dezimalpunkt = Sek_blink Gegen +
Config Portc.1 = Output 'Relais
Config Portc.0 = Output 'Peeper Gegen -
Config Portc.3 = Input ' Start/ Stop Taster
Config Portc.4 = Input 'Minuten Taster
Config Portc.5 = Input 'Sekunden Taster
Portd.0 = 1
Portd.1 = 1
Portd.2 = 1
Portd.3 = 1
Portd.4 = 1
Portd.5 = 1
Portd.6 = 1
Portb.1 = 1
Portb.2 = 1
Portb.3 = 1
Portb.4 = 1
Portc.2 = 1
Portc.1 = 0
Portc.0 = 0
Portc.3 = 1
Portc.4 = 1
Portc.5 = 1
Code:
On Timer1 Ontimer1
Config Timer1 = Timer , Prescale = 64
'Parameter für 7Segment um diese Zahl Anzuzeigen über die Ausgänge
Segment_zahl(1) = &H79
Segment_zahl(2) = &H24
Segment_zahl(3) = &H30
Segment_zahl(4) = &H19
Segment_zahl(5) = &H12
Segment_zahl(6) = &H2
Segment_zahl(7) = &H78
Segment_zahl(8) = &H0
Segment_zahl(9) = &H10
Segment_zahl(10) = &H40
'Parameter für Aktives Segment,immer nur eins kann an sein
Segment_anzeige(1) = &B00000010
Segment_anzeige(2) = &B00000100
Segment_anzeige(3) = &B00001000
Segment_anzeige(4) = &B00010000
Segment_anzeige(5) = &B00100010
Segment_anzeige(6) = &B00100100
Segment_anzeige(7) = &B00101000
Segment_anzeige(8) = &B00110000
'--- Sekunden-Punkt darf in diesem Fall nicht in der Multiplexroutine stehen ---
Dezimalpunkt Alias Portc.2 'dezimalpunkt blinkt im halbsekunden takt
Dim Sek_blink As Bit
'Zeit Voreinstellung laden aus EEProm
Call Zeiteinstellung
Timerpreset = 3036
Enable Timer1
Stop Timer1
Timer1 = Timerpreset
Enable Interrupts
'*******************************************************************************
Main:
For Z = 1 To 4
Dezimalpunkt = Sek_blink
I = I + 1
If I = 600 Then
Sek_blink = 0
I = 0
End If
If Zeit(z) = 0 Then
Portd = Segment_zahl(10) 'eine "0" in 7segment anzeigen
Else
Portd = Segment_zahl(zeit(z)) 'zahl aus Variable in 7segment anzeigen
End If
If Tccr1b = 0 Then 'wenn timer gestoppt, ist Relais aus
Portb = Segment_anzeige(z + 4) 'einzelnen segmente ansteuern
Else
Portb = Segment_anzeige(z) 'wenn timer läuft relais an
End If
Waitms 1
'----------------- Start/Stop und wenn geändert EEPROM-werte Schreiben ---------
If Pinc.3 = 0 And Taste4 = 0 Then
Eezeit(1) = Zeit(1)
Eezeit(2) = Zeit(2)
Eezeit(3) = Zeit(3)
Eezeit(4) = Zeit(4)
Taste4 = 1
End If
'----------------- Reine Start/Stop Routien ------------------------------------
If Pinc.3 = 0 And Taste3 = 0 Then
Taste3 = 1
If Tccr1b = 0 Then
Start Timer1
Call Zeiteinstellung
I = 0
Portc.1 = 1
Else
Stop Timer1
Call Zeiteinstellung
I = 0
Portc.1 = 0
End If
End If
If Pinc.3 = 1 Then
Taste3 = 0
End If
'----------------- Minuten um 1 erhöhen Taster ---------------------------------
If Pinc.4 = 0 And Taste2 = 0 And Tccr1b = 0 Then
Taste2 = 1
Taste4 = 0
Incr Zeit(2)
If Zeit(2) = 10 Then
Zeit(2) = 0
Incr Zeit(1)
If Zeit(1) = 10 Then Zeit(1) = 0
End If
End If
If Pinc.4 = 1 Then
Taste2 = 0
End If
'------------Sekunde und Minuten = Null setzen ---------------------------------
If Pinc.4 = 0 And Tccr1b = 0 And Pinc.5 = 0 Then
Taste4 = 0
Zeit(1) = 0
Zeit(2) = 0
Zeit(3) = 0
Zeit(4) = 0
End If
If Pinc.4 = 1 And Pinc.5 = 1 Then
End If
Next Z
'******************************************************************************
'----------------- Sekunden um 1 erhöhen Taster --------------------------------
If Pinc.5 = 0 And Taste1 = 0 And Tccr1b = 0 Then
Taste1 = 1
Taste4 = 0
Incr Zeit(4)
If Zeit(4) = 10 Then
Zeit(4) = 0
Incr Zeit(3)
If Zeit(3) = 6 Then Zeit(3) = 0
End If
End If
If Pinc.5 = 1 Then
Taste1 = 0
End If
Goto Main
'******************************************************************************
Ontimer1:
Timer1 = Timer1 + Timerpreset
Decr Zeit(4)
Sek_blink = 1
I = 0
If Zeit(1) = 0 And Zeit(2) = 0 And Zeit(3) = 0 And Zeit(4) = 0 Then
Stop Timer1
Call Zeiteinstellung
I = 0
Portc.1 = 0
Call Sound
End If
If Zeit(4) = 255 Then
Zeit(4) = 9
Decr Zeit(3)
If Zeit(3) = 255 Then
Zeit(3) = 5
Decr Zeit(2)
If Zeit(2) = 255 Then
Zeit(2) = 9
Decr Zeit(1)
End If
End If
End If
Return
'----------- gespeicherte Timerwerte aus EEPROM laden --------------------------
Sub Zeiteinstellung
Zeit(1) = Eezeit(1) 'Minuten Zehner
Zeit(2) = Eezeit(2) 'Minuten Einer
Zeit(3) = Eezeit(3) 'Sekunden zehner
Zeit(4) = Eezeit(4) 'Sekunden Einer
End Sub
Sub Sound
Portb.1 = 1
Portb.2 = 1
Portb.3 = 1
Portb.4 = 1
Sound Portc.0 , 400 , 100
Portb.1 = 0
Portb.2 = 0
Portb.3 = 0
Portb.4 = 0
Waitms 100
Portb.1 = 1
Portb.2 = 1
Portb.3 = 1
Portb.4 = 1
Sound Portc.0 , 400 , 100
Waitms 100
Portb.1 = 0
Portb.2 = 0
Portb.3 = 0
Portb.4 = 0
Sound Portc.0 , 400 , 100
Portb.1 = 1
Portb.2 = 1
Portb.3 = 1
Portb.4 = 1
End Sub
Lesezeichen