Nabend zusammen,
folgendes Programm:
1 | $regfile = "m8def.dat"
|
2 | $framesize = 48
|
3 | $swstack = 64
|
4 | $hwstack = 64
|
5 | $crystal = 8000000
|
6 | $baud = 9600
|
7 |
|
8 |
|
9 | Dim Empfangen As String * 3
|
10 | Dim X As Bit , Y As Bit , Z As Bit
|
11 | Dim Ansteuerung As Byte , Wecksound As Byte
|
12 | Dim Ansteuerung2 As Integer
|
13 |
|
14 | X = 0
|
15 | Y = 0
|
16 | Z = 0
|
17 | Wecker = 0
|
18 |
|
19 | Config Portb = Output
|
20 |
|
21 | Config Portc = Output
|
22 |
|
23 | Config Portd.4 = Output
|
24 | Config Portd.3 = Output
|
25 | Summer Alias Portd.4
|
26 | Pc Alias Portd.3
|
27 |
|
28 | On Urxc Onrxd
|
29 | Enable Urxc
|
30 | Enable Interrupts
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | Do
|
37 | If Len(empfangen) > 2 Then
|
38 | Ansteuerung2 = Val(empfangen)
|
39 | Select Case Ansteuerung2
|
40 | Case 400
|
41 | Pc = 1
|
42 | Empfangen = ""
|
43 | Case 401
|
44 | Pc = 0
|
45 | Empfangen = ""
|
46 | Case Is < 256
|
47 | Gosub Ansteuern
|
48 | End Select
|
49 | End If
|
50 | Loop
|
51 | End
|
52 |
|
53 | Ansteuern:
|
54 | Ansteuerung = Ansteuerung2
|
55 | Portb = Ansteuerung
|
56 | Gosub Stehlampe
|
57 | Gosub Leuchtkugel
|
58 | Gosub Lichterkette
|
59 | Empfangen = ""
|
60 | Return
|
61 |
|
62 | Lichterkette:
|
63 | If Portb.4 = 1 Then : If X = 0 Then : Portc = &B00000000 : Portc.1 = 1 : X = 1 : Waitms 500 : Portc = &B00000000 : End If : End If
|
64 | If Portb.4 = 0 Then : If X = 1 Then : Portc = &B00000000 : Portc.0 = 1 : X = 0 : Waitms 500 : Portc = &B00000000 : End If : End If
|
65 | Return
|
66 |
|
67 | Stehlampe:
|
68 | If Portb.6 = 1 Then : If Y = 0 Then : Portc = &B00000000 : Portc.3 = 1 : Y = 1 : Waitms 500 : Portc = &B00000000 : End If : End If
|
69 | If Portb.6 = 0 Then : If Y = 1 Then : Portc = &B00000000 : Portc.2 = 1 : Y = 0 : Waitms 500 : Portc = &B00000000 : End If : End If
|
70 | Return
|
71 |
|
72 | Leuchtkugel:
|
73 | If Portb.7 = 1 Then : If Z = 0 Then : Portc = &B00000000 : Portc.5 = 1 : Z = 1 : Waitms 500 : Portc = &B00000000 : End If : End If
|
74 | If Portb.7 = 0 Then : If Z = 1 Then : Portc = &B00000000 : Portc.4 = 1 : Z = 0 : Waitms 500 : Portc = &B00000000 : End If : End If
|
75 | Return
|
76 |
|
77 | Onrxd:
|
78 | Empfangen = Empfangen + Chr(udr)
|
79 | Return
|
Problem ist: Der Portb wird nicht richtig gesetzt. Nachdem die
"Ansteuern" Schleife ausgeführt wurde, messe ich jeden Port von b durch
aber keiner ist "1". Deshalb funktionieren auch die Schleifen
Lichterkette, Leuchtkugel und Stehlampe nicht. Ist da irgendwas falsch?
(Der µC läuft über (Mhz Interner Takt)