Oh... mir ist gerade aufgefallen das es nur in meinem beispielprogramm funktioniert. Da wo ich es eigentlich gebraucht hätte gehts nicht. Ich wollte einen Schrittmotor ansteuern und über die variabe die position übergeben die er anfahren soll. Ich hab jetzt bemerkt das im simulator ständig "Stack pointer and software stack overlap" in der statuszeile steht. Egal was ich bei softwarestack oder bei frame eintrage, es geht nicht. Die Variable wird im simulator unter locals als 255 ausgewiesen, wenn ich im quelltext mit der maus drüberfahre sagt er 20 wie ich es eigentlich haben wollte. Das ist total verwirrend. Hier mal der code den ich eigentlich nicht posten wollte weil er auf den ersten blick etwas verwirrend aussieht![]()
Würde mich freuen wenn mir jemand weiterhelfen kann, ich hab keine ahnung was daran falsch sein soll.Code:$regfile = "m8def.dat" $crystal = 3686400 $baud = 9600 Config Int0 = Rising Dim I As Byte Dim Servo_pos As Byte Dim Servo_byte As Byte On Int0 Null Enable Int0 Enable Interrupts Declare Sub Servo(byval I As Byte) Servo_byte = 2 Servo_pos = 0 Do Loop Sub Servo(byval I As Byte) Print I If Servo_pos > I Then 'ist i kleiner als die aktuelle position, dann links rum drehen If Servo_byte = 1 Then Goto A1 'wo stand der motor als letztes? dort weitermachen If Servo_byte = 3 Then Goto A3 If Servo_byte = 4 Then Goto A4 Do Portb = &B00001000 Servo_byte = 4 'motor stnadpukt verändern Decr Servo_pos 'position -1 If Servo_pos = I Then Goto Fertig 'wenn position = i dann ende Waitms 50 A4: Portb = &B00000100 Servo_byte = 3 Decr Servo_pos If Servo_pos = I Then Goto Fertig Waitms 50 A3: Portb = &B00000001 Servo_byte = 1 Decr Servo_pos If Servo_pos = I Then Goto Fertig Waitms 50 A1: Portb = &B00000010 Servo_byte = 4 Decr Servo_pos If Servo_pos = I Then Goto Fertig Waitms 50 Loop Else 'oder rechts rum drehen If Servo_byte = 1 Then Goto B1 'gleiches spiel wie oben nur umgekehrt If Servo_byte = 3 Then Goto B3 If Servo_byte = 4 Then Goto B4 Do Portb = &B00000001 Servo_byte = 4 Incr Servo_pos If Servo_pos = I Then Goto Fertig Waitms 50 B1: Portb = &B00000100 Servo_byte = 3 Incr Servo_pos If Servo_pos = I Then Goto Fertig Waitms 50 B3: Portb = &B00001000 Servo_byte = 1 Incr Servo_pos If Servo_pos = I Then Goto Fertig Waitms 50 B4: Portb = &B00000010 Servo_byte = 4 Incr Servo_pos If Servo_pos = I Then Goto Fertig Waitms 50 Loop End If Fertig: Portb = &B00000000 End Sub Null: I = 20 Call Servo(i) Return End
*edit
mir ist auch noch aufgefallen das sich die variable aus dem ersten, einfachen programm nur mit [print var] ausdrucken lässt. wenn ich [print "variable:" ; var] eingebe dann ist sie wieder 255?! Was soll das??? Ich bin am verzweifeln.







Zitieren

Lesezeichen