Hi Leute.
Ich mach noch mal einen neuen Thread auf. Zwar gleiches Projekt, aber neues Problem.
Ich versuche immer noch einen µC per PC zu steuern. Klappt auch inzwischen wunderbar!!
Da ich allerdings 9 PWM Kanäle benötige, blieb mir keine andere Wahl als Software PWM zu benutzen.
Beides für sich funktioniert auch tadellos. Meine Soft-PWM macht genau das was sie machen soll und meine Uart Empfang macht auch genau das was er machen soll.
Nur wenn ich beides zusammen bringe, kommt es zu Problemen.
Ich schicke per Uart 9 Zahlenwerte für die Led-Helligkeit betrennt durch ein Leerzeichen. Schicke ich einfache Zahlenwerte ( 1 2 3 4 5 6 7 8 9 ) klappt alles.
Sobald ich aber höhere Werte wie ( 100 100 100 100 100 100 100 100 100 ) schicke, kommt es zu Empfangsstörungen.
Ich häng euch mal die Zeilen aus dem Terminal mit dran, damit ihr seht was ich meine:
ZitatAlles anzeigenStart!
1 2 3 4 5 6 7 8 9
Ausgabe: 1 2 3 4 5 6 7 8 9
100 100 100 100 100 100 100 100 100
Ausgabe: 100 100 100 100 100 100 100 100 100
1 2 3 4 ' Hier eigentlich wieder 1 2 3 4 5 6 7 8 9 gesendet!
Ausgabe: 1 2 3 4 100 100 100 100
Ich häng euch auch noch mal meinen Bascom Code mit dran.
Hat irgendwer nen Tipp woran das liegen kann ??
Ps.: Die Timer hab ich auch schon ausgetauscht. Egal ob Timer0 oder Timer2 es kommt der selbe Fehler
Danke für die Hilde und viele Grüße
Philipp
'========================================================================
$regfile = "m16def.dat"
$crystal = 8000000
$hwstack = 100
$swstack = 100
$framesize = 100
$baud = 38400
'Soft PWM -------------------------------------------------
Config Timer2 = Timer , Prescale = 1
On Timer2 Soft_pwm
Enable Timer2
Enable Interrupts
'PWM-Variablen ------------------------------------
Dim Count As Byte
Dim Tcount As Long
Dim T As Byte
T = 0
Dim Spwm1 As Byte , Spwm2 As Byte , Spwm3 As Byte , Spwm4 As Byte , Spwm5 As Byte , Spwm6 As Byte , Spwm7 As Byte , Spwm8 As Byte , Spwm9 As Byte
Spwm1 = 100
Spwm2 = 100
Spwm3 = 0
Spwm4 = 0
Spwm5 = 0
Spwm6 = 0
Spwm7 = 0
Spwm8 = 0
Spwm9 = 0
Config Porta.7 = Output
Config Porta.6 = Output
Config Porta.5 = Output
Config Porta.4 = Output
Config Porta.3 = Output
Config Porta.2 = Output
Config Porta.1 = Output
Config Porta.0 = Output
Config Portc.7 = Output
Softpwm1 Alias Porta.0
Softpwm2 Alias Porta.1
Softpwm3 Alias Porta.2
Softpwm4 Alias Porta.3
Softpwm5 Alias Porta.4
Softpwm6 Alias Porta.5
Softpwm7 Alias Porta.6
Softpwm8 Alias Porta.7
Softpwm9 Alias Portc.7
'Uart Empfang----------------------------
'Globale Variablen
Dim Tmp As Byte
Dim New_command As String * 100
Dim Command_array(9) As String * 3
Dim New_status As Bit
'Prozeduren
Declare Sub Serial0charmatch()
'UART-Buffer
Config Serialin = Buffered , Size = 100 , Bytematch = 13
Enable Interrupts
Print "Start!"
Do
If New_command <> "" Then
'Anweisung aufteilen
Tmp = Split(new_command , Command_array(1) , " ")
Print "Ausgabe: " ; Command_array(1) ; " " ; Command_array(2) ; " " ; Command_array(3) ; " " ; Command_array(4) ; " " ; Command_array(5) ; " " ; Command_array(6) ; " " ; Command_array(7) ; " " ; Command_array(8) ; " " ; Command_array(9)
Print
Spwm1 = Val(command_array(1))
Spwm2 = Val(command_array(2))
Spwm3 = Val(command_array(3))
Spwm4 = Val(command_array(4))
Spwm5 = Val(command_array(5))
Spwm6 = Val(command_array(6))
Spwm7 = Val(command_array(7))
Spwm8 = Val(command_array(8))
Spwm9 = Val(command_array(9))
New_command = ""
End If
Loop
End
'Wird automatisch ausgeführt, wenn CARRIAGE RETURN empfangen wird.
Sub Serial0charmatch()
Input New_command 'Noecho
End Sub
'Soft PWM --------------------------------------------------------
Soft_pwm:
Incr Count
If T = 1 Then Incr Tcount
If Spwm1 > Count Then Softpwm1 = 1 Else Softpwm1 = 0
If Spwm2 > Count Then Softpwm2 = 1 Else Softpwm2 = 0
If Spwm3 > Count Then Softpwm3 = 1 Else Softpwm3 = 0
If Spwm4 > Count Then Softpwm4 = 1 Else Softpwm4 = 0
If Spwm5 > Count Then Softpwm5 = 1 Else Softpwm5 = 0
If Spwm6 > Count Then Softpwm6 = 1 Else Softpwm6 = 0
If Spwm7 > Count Then Softpwm7 = 1 Else Softpwm7 = 0
If Spwm8 > Count Then Softpwm8 = 1 Else Softpwm8 = 0
If Spwm9 > Count Then Softpwm9 = 1 Else Softpwm9 = 0
Return
Alles anzeigen