Mikrocontroller und Digitale Elektronik
›
Thread
$hwstack $swstack $framesize falsch dimensioniert??
Hallo!
Der ein oder andere hat vielleicht meinen Thread
Beitrag "Bascom ATmega8a - Problem aus Powerdown aufwecken"
verfolgt.
Hier geht es um das selbe Programm.
Ich habe das Problem, dass der Programmablauf nicht so funktioniert. Der
Code springt nach dem Setzen von Status = 3 an eine undefinierte Stelle
und macht dort weiter.
Ich denke das hat mit dem $hwstack zu tun. Habe dazu auch schon etliche
Beiträge gelesen, werde aber nicht ganz schlau daraus.
Ich habe auch alle drei Werte schon weiter nach oben gesetzt, dann
springt der Code an eine andere undefinierte Stelle.
Bitte könnt ihr mir helfen?
Ggf. anhand meines Codes erklären wie ich die drei Werte feststellen
kann?
Kann man mit der Simulation in der Hinsicht was anfangen?
1 $regfile = "m8adef.dat"
2 $crystal = 1000000
3 $hwstack = 300
4 $swstack = 8
5 $framesize = 24
6
7
8
9
10 Ddrb = &B00000100
11 Portb = &B11111011
12 Ddrc = &B00111111
13 Portc = &B11000000
14 Ddrd = &B10000000
15 Portd = &B01111111
16
17 Config Pinb.0 = Input
18 Portb.0 = 1
19 Config Pinb.1 = Input
20 Portb.1 = 1
21 Config Pinb.2 = Output
22 Config Pind.7 = Output
23 Config Pind.2 = Input
24 Portd.2 = 1
25
26 Config Lcd = 16 * 2
27 Config Lcdpin = Pin , Db7 = Portc.5 , Db6 = Portc.4 , Db5 = Portc.3 , Db4 = Portc.2 , E = Portc.1 , Rs = Portc.0
28
29 Config Int0 = Low Level
30
31 Config Timer1 = Timer , Prescale = 8
32 Enable Timer1
33 On Timer1 Isr_timer
34
35 Enable Interrupts
36
37
38 Taster1 Alias Pinb.1
39 Taster2 Alias Pind.2
40 Beleuchtung Alias Portd.7
41 Cursor Off Noblink
42
43 Beleuchtung = 1
44
45
46 '---------------------------------------------
47 'Deklarationen
48
49 Dim Frage As String * 16
50 Frage = ""
51
52 Dim Antwort As String * 16
53 Antwort = ""
54
55 Dim Frageout As String * 16
56 Frageout = ""
57
58 Dim Abschaltzeit As Word
59 Abschaltzeit = 0
60
61 Dim Status As Byte
62
63 Dim Wert_timer As Word
64 Wert_timer = 0
65
66 Dim X As Byte
67 X = 0
68
69 Cls
70
71 'Beginn Main
72
73
74
75 Do
76 Select Case Status
77 Case 0:
78 Beleuchtung = 1
79 Disable Int0
80 Lcd "Hallo!"
81 Wait 3
82 Cls
83 Status = 1
84 Case 1:
85 Locate 1 , 1
86 Lcd "Druecke 1 um zu"
87 Locate 2 , 1
88 Lcd "beginnen!"
89 If Taster2 = 0 Then
90 Abschaltzeit = 0
91 Goto Anweisung
92 End If
93 Case 2:
94 Goto Aufforderung_eingabe
95 Case 3:
96 Locate 1 , 1
97 Lcd "Deine Eingabe:"
98 Debounce Taster1 , 0 , Schreibe_0 , Sub
99 Debounce Taster2 , 0 , Schreibe_1 , Sub
100 If Len(antwort) = 16 Then
101 If Frage = Antwort Then
102 Gosub Antwort_richtig
103 Else
104 Cls
105 Lcd "Leider falsch..."
106 Locate 2 , 1
107 Lcd "2 min. warten ;)"
108 Wait 30
109 Cls
110 Antwort = ""
111 Frage = ""
112 Frageout = ""
113 Status = 1
114 End If
115 End If
116 End Select
117
118 If Abschaltzeit > 150 Then
119 Cls
120 Beleuchtung = 0
121 Status = 0
122 Enable Int0
123 Config Powermode = Powerdown
124 End If
125 Loop
126
127
128
129 Anweisung:
130
131 Wert_timer = Timer1
132 Frage = Bin(wert_timer)
133 Cls
134
135 Lcd "Merke dir diese"
136 Locate 2 , 1
137 Lcd "Zahlenfolge:"
138 Wait 3
139 Cls
140
141 Lcd "Die Zahlenfolge:"
142 Wait 2
143
144 For X = 1 To 16
145 Locate 2 , 1
146 Lcd Space(16)
147 Frageout = Frageout + Mid(frage , X , 1)
148 Locate 2 , 1
149 Lcd Frageout
150 Waitms 500
151 Next X
152
153 Wait 3
154
155 Cls
156
157 Status = 2
158
159 Return
160
161
162
163 Aufforderung_eingabe:
164 Locate 1 , 1
165 Lcd "Nun bist du"
166 Locate 2 , 1
167 Lcd "an der Reihe!"
168 Wait 3
169 Cls
170 Status = 3
171 Return
172
173
174
175 Schreibe_0:
176 Locate 2 , 1
177 Antwort = Antwort + "0"
178 Lcd Antwort
179 Abschaltzeit = 0
180 Return
181
182
183 Schreibe_1:
184 Locate 2 , 1
185 Antwort = Antwort + "1"
186 Lcd Antwort
187 Abschaltzeit = 0
188 Return
189
190
191 Isr_timer:
192 Abschaltzeit = Abschaltzeit + 1
193 Return
194
195
196 Antwort_richtig:
197 Cls
198 Lcd "Herzlichen"
199 Locate 2 , 1
200 Lcd "Glueckwunsch!"
201 Wait 2
202 Portb.2 = 1
203 Wait 3
204 Portb.2 = 0
205 Wait 10
206 Cls
207 Beleuchtung = 0
208 Status = 0
209 Enable Int0
210 Config Powermode = Powerdown
211 Return
M
mue_c
Gast
28.06.2015 17:14
#4181198
Das hat eher was damit zu tun, dass du die Gotos aus der Hauptschleife
zu einem Label springen, wo am Ende ein Return steht. Da dann keine
Rücksprüngadresse auf dem Stack liegt, geht's ins Nirwana.
Ich habe mir nicht den ganzen Code angesehen, aber kannst du anstelle
der Gotos nicht Gosubs nehmen?
Oh mein Gott....
Da bin ich ja mal so richtig auf der Leitung gestanden...
Danke!
↑ Nach oben
← Zurück zu Mikrocontroller und Digitale Elektronik
Antwort schreiben