Gut, also ich hab es so versucht, aber die CharMatch-Routine wird auch nicht angesprungen. Hier der neuste Kot - ähm Code:
Code:
$regfile = "m8def.dat"
$crystal = 14745600
$baud = 115200
$hwstack = 200
$swstack = 200
$framesize = 200
Config Serialin = Buffered , Size = 20 , Bytematch = 65
Config Timer0 = Timer , Prescale = 1 'Timer0 für 100 Hz
Config Portb = Output
Config Portc = Output
Dim Tmp_b As Byte 'Temp-Register für die Outputs (schneller beschreibbar)
Dim Tmp_c As Byte
Dim Pointer As Byte 'debug
Dim Pwm_cnt As Byte 'Zähler für PWM-Intervall
Dim Pwms(12) As Byte 'Array mit PWM-Werten
Dim Tmp_pwms(12) As Byte 'temporäres pwm-array
Dim Incoming As Byte 'Byte welches über UART gekommen ist
Dim Mybytes As Byte 'wieviele signifikante bytes hab ich empfangen
'Dim Bytecnt As Integer 'Wieviele Bytes wurden empfangen?
Dim Receiveflag As Bit
Mybytes = 0
Receiveflag = 0
Const Slaveid = 0 'Slave-IDs (von 0 bis 24)
Const Timervorgabe = 112 'Timerstartwert für korrektes Timing
Pwms(1) = 200 'Farbwerte zuweisen (debug)
Pwms(2) = 10
Pwms(3) = 10
Pwms(4) = 10
Pwms(5) = 10
Pwms(6) = 10
Pwms(7) = 10
Pwms(8) = 10
Pwms(9) = 10
Pwms(10) = 10
Pwms(11) = 10
Pwms(12) = 10
Waitms 500
Portb.1 = 1 'Takt testen (debug)
Waitms 500
Portb.1 = 0
Waitms 500
Portb.1 = 1
Waitms 500
Portb.1 = 0
Waitms 500
Portb.1 = 1
Waitms 500
Portb.1 = 0
Waitms 500
Print 'Debugmessage
Print "RGB-Slave...started"
Print "Slave-ID..." ; Slaveid
Print "Communication...OK"
Print
On Timer0 Timer_irq 'interruptvektor fuer timer0-interrupt
Enable Timer0 'timer0 anschalten
Enable Interrupts
Timer0 = Timervorgabe
'Main:
Do
If Receiveflag = 1 Then 'Wenn flag gesetzt ist
If Ischarwaiting() = 1 Then 'Test ob neues Zeichen im Buffer
Pwms(mybytes) = Inkey() 'Zeichen in PWM-Array
Incr Mybytes 'Habe 1 Byte mehr
If Mybytes = 12 Then 'wenn ich 12 Bytes habe
Receiveflag = 0 'bereit fuer Empfang des naechsten Startsymbols
Mybytes = 0 'Mybytes auf 0
End If
End If
End If
Loop
'Getit:
Serial0charmatch:
Clear Serialin 'buffer loeschen damit platz fuer relevante zeichen ist
Receiveflag = 1 'hab startsymbol empfangen
Pwms(12) = 200 'debug
Return
Timer_irq:
Timer0 = Timervorgabe
Tmp_b = 0
Tmp_c = 0
If Pwms(1) > Pwm_cnt Then Tmp_c = Tmp_c Or 8 'R1 (PORTC.3)
If Pwms(2) > Pwm_cnt Then Tmp_c = Tmp_c Or 16 'G1 (PORTC.4)
If Pwms(3) > Pwm_cnt Then Tmp_c = Tmp_c Or 32 'B1 (PORTC.1)
If Pwms(4) > Pwm_cnt Then Tmp_c = Tmp_c Or 1 'R2 (PORTC.0)
If Pwms(5) > Pwm_cnt Then Tmp_c = Tmp_c Or 2 'G2 (PORTC.1)
If Pwms(6) > Pwm_cnt Then Tmp_c = Tmp_c Or 4 'B2 (PORTC.2)
If Pwms(7) > Pwm_cnt Then Tmp_b = Tmp_b Or 8 'R3 (PORTB.3)
If Pwms(8) > Pwm_cnt Then Tmp_b = Tmp_b Or 16 'G3 (PORTB.4)
If Pwms(9) > Pwm_cnt Then Tmp_b = Tmp_b Or 32 'B3 (PORTB.5)
If Pwms(10) > Pwm_cnt Then Tmp_b = Tmp_b Or 1 'R4 (PORTB.0)
If Pwms(11) > Pwm_cnt Then Tmp_b = Tmp_b Or 2 'R3 (PORTB.1)
If Pwms(12) > Pwm_cnt Then Tmp_b = Tmp_b Or 4 'R3 (PORTB.2)
Portc = Tmp_c
Portb = Tmp_b
Incr Pwm_cnt 'Pwm_cnt incrementieren und lustig überlaufen lassen
Return
Hab zu debug-Zwecken in die Interrup-Routine für den Charmatch mal ne PWM-Wert-Änderung eingebaut. Aber nichts tut sich. Wenn ich den Timer0-Interrupt ausmache geht es.
Lesezeichen