Zeile
|
Programmcode
|
Beschreibung
|
1
|
$regfile "m8def.dat"
|
Definiert den Atmega als Atmega8 |
2
|
$crystal = 1000000 |
Gibt die Quarzfrequenz an in Herz |
3
|
$hwstack = 32 |
Default use 32 Hardware reservierte Speicher |
4
|
$swstack = 10 |
Default Software resvierung Speicher |
5
|
Ddrc = &B11111111 |
Gesamter Port C als Ausgang setzen |
6
|
Ddrb = &B11111111 |
Port B.7 als Ausgang setzen |
7
|
Ddrd = &B11100011 |
Port D5, D6, D7 als Ausgang setzen |
8
|
Portd = &B00011100 |
Pull Up für Port D2 und D3 und d4setzen |
9
|
Dim Zeitvorgabe As Word |
|
10
|
Dim Zeit As Word |
Variable für Sekundentakt |
11
|
On Timer1 Timer_eins |
|
12
|
Tccr1a = &B00000000 |
|
13
|
Tccr1b = &B00000011 |
|
14
|
Timsk = &B00000100 |
Interrupt für Timerüberlauf einschalten |
15
|
Sreg = &B10000000 |
Interrupt Freigeben |
16
|
Timer1 = 49911 |
Vorgabe |
17
|
Sound Portb.1 , 1000 , 20 |
|
18
|
Do |
|
19
|
If Pind.2 = 0 Then Waitms 20 |
|
20
|
If Pind.2 = 0 Then Zeitvorgabe = Zeitvorgabe -60 |
|
21
|
If Pind.2 = 0 Then Sound Portb.1 , 500 , 20 |
|
22
|
If Pind.3 = 0 Then Waitms 20 |
|
23
|
If Pind.3 = 0 Then Zeitvorgabe = Zeitvorgabe + 60 |
|
24
|
If Pind.3 = 0 Then Sound Portb.1 , 500 , 20 |
|
25
|
If Zeitvorgabe > 59 Then Portc.5 = 1 Else Portc.5 = 0 |
|
26
|
If Zeitvorgabe > 119 Then Portc.4 = 1 Else Portc.4 = 0 |
|
27
|
If Zeitvorgabe > 179 Then Portc.3 = 1 Else Portc.3 = 0 |
|
28
|
If Zeitvorgabe > 239 Then Portc.2 = 1 Else Portc.2 = 0 |
|
29
|
If Zeitvorgabe > 299 Then Portc.1 = 1 Else Portc.1 = 0 |
|
30
|
If Zeitvorgabe > 359 Then Portc.0 = 1 Else Portc.0 = 0 |
|
31
|
If Zeitvorgabe > 419 Then Portb.5 = 1 Else Portb.5 = 0 |
|
32
|
If Zeitvorgabe > 479 Then Portb.4 = 1 Else Portb.4 = 0 |
|
33
|
If Zeitvorgabe > 539 Then Portb.3 = 1 Else Portb.3 = 0 |
|
34
|
If Zeitvorgabe > 599 Then Portb.2 = 1 Else Portb.2 = 0 |
|
35
|
Zeit = Zeitvorgabe |
|
36
|
If Pind.4 = 0 Then Exit Do |
|
37
|
Loop |
|
38
|
Sound Portb.1 , 1000 , 20 |
|
39
|
Do |
|
40
|
Zeitvorgabe = Zeit |
|
41
|
If Zeitvorgabe > 1 Then Portc.5 = 1 Else Portc.5 = 0 |
|
42
|
Waitms 5 |
|
43
|
If Zeitvorgabe > 60 Then Portc.4 = 1 Else Portc.4 = 0 |
|
44
|
Waitms 5 |
|
45
|
If Zeitvorgabe > 120 Then Portc.3 = 1 Else Portc.3 = 0 |
|
46
|
Waitms 5 |
|
47
|
If Zeitvorgabe > 180 Then Portc.2 = 1 Else Portc.2 = 0 |
|
48
|
Waitms 5 |
|
49
|
If Zeitvorgabe > 240 Then Portc.1 = 1 Else Portc.1 = 0 |
|
50
|
Waitms 5 |
|
51
|
If Zeitvorgabe > 300 Then Portc.0 = 1 Else Portc.0 = 0 |
|
52
|
Waitms 5 |
|
53
|
If Zeitvorgabe > 360 Then Portb.5 = 1 Else Portb.5 = 0 |
|
54
|
Waitms 5 |
|
55
|
If Zeitvorgabe > 420 Then Portb.4 = 1 Else Portb.4 = 0 |
|
56
|
Waitms 5 |
|
57
|
If Zeitvorgabe > 480 Then Portb.3 = 1 Else Portb.3 = 0 |
|
58
|
Waitms 5 |
|
59
|
If Zeitvorgabe > 540 Then Portb.2 = 1 Else Portb.2 = 0 |
|
60
|
Waitms 50 |
|
61
|
Portc.5 = 0 |
|
62
|
Waitms 20 |
|
63
|
Portc.4 = 0 |
|
64
|
Waitms 20 |
|
65
|
Portc.3 = 0 |
|
66
|
Waitms 20 |
|
67
|
Portc.2 = 0 |
|
68
|
Waitms 20 |
|
69
|
Portc.1 = 0 |
|
70
|
Waitms 20 |
|
71
|
Portc.0 = 0 |
|
72
|
Waitms 20 |
|
73
|
Portb.5 = 0 |
|
74
|
Waitms 20 |
|
75
|
Portb.4 = 0 |
|
76
|
Waitms 20 |
|
77
|
Portb.3 = 0 |
|
78
|
Waitms 20 |
|
79
|
Portb.2 = 0 |
|
80
|
If Zeit < 1 Then Goto Alarm |
|
81
|
Loop |
|
82
|
Timer_eins: |
Timer 1 Interrupt Routine |
83
|
Timer1 = 49911 |
|
84
|
Zeit = Zeit |
|
85
|
Decr Zeit |
|
86
|
Return |
|
87
|
Alarm: |
A l a r m |
88
|
Do |
|
89
|
Waitms 20 |
|
99
|
Sound Portb.1 , 500 , 50 |
|
100
|
Sound Portb.1 , 500 , 20 |
|
101
|
Portd.7 = 1 |
|
102
|
Waitms 8 |
|
103
|
Portd.7 = 0 |
|
104
|
If Pind.4 = 0 Then Waitms 20 |
|
105
|
If Pind.4 = 0 Then Exit Do |
|
106
|
Loop |
|
107
|
Stop |
|