; *********************************************************************************************** ; * 27-KANAL-DMX-DIMMER - V 2.0 - 08.09.2010 * ; * * ; * by Pesi & McGyver für ledstyles.de - Public Domain unter Nennung des Autors * ; * Grundgerüst größtenteils Programmiert von Pesi (ledstyles.de) * ; * BCM, Lookup-table und BCM-Datenumrechnung von McGyver (ledstyles.de) * ; * für die DMX-Empfangsroutine wurden Code-Teile von Hendrik Hoelscher verwendet * ; * * ; * für ATmega32 - Hardware siehe unter http://www.ledstyles.de/ftopic9259.html * ; * * ; *********************************************************************************************** ; ------------------------------------------------------------------------------------------------ ; DMX-Startadresse ; ------------------------------------------------------------------------------------------------ .equ DMX_Adresse = 1 ; 1 - 485 ; ------------------------------------------------------------------------------------------------ ; Standalone-Farben ; ------------------------------------------------------------------------------------------------ .equ SA_R = 255 ; Rot bei Standalone .equ SA_G = 222 ; Grün bei Standalone .equ SA_B = 76 ; Blau bei Standalone ; ================================================================================================ .include "m32def.inc" ; ================================================================================================ ; Register etc. definieren ; ------------------------------------------------------------------------------------------------ .def SREGbuf = R0 ; Puffer für Status-Register .def PWM_Count = R1 ; Zähler für SW-PWM .def DMX_Base_L = R2 ; Low-Byte DMX-Startadresse .def DMX_Base_H = R3 ; High-Byte DMX-Startadresse .def temp_ZL = R4 ; Temp für Z-Pointer L .def temp_ZH = R5 ; Temp für Z-Pointer H .def tempR = R8 ; Tempregister für die 12-Bit .def tempRh = R9 ; Farbwerte bei der Berechnung .def tempG = R10 ; der BCM-Daten .def tempGh = R11 .def tempB = R12 .def tempBh = R13 .def BCMstate = R16 ; Verwaltungsbyte für die BCM: ; 7. Bit: Flag für neuberechnung der BCM-Daten ; 0. - 2. Bit: Status der BCM (First-, Mid- oder Last-Tick) .def temp0 = R17 ; Mehrzweck-Temp-Register .def temp1 = R18 ; Mehrzweck-Temp-Register .def OutA = R19 ; Temp-Register für Kanäle PortA .def OutB = R20 ; Temp-Register für Kanäle PortB .def OutC = R21 ; Temp-Register für Kanäle PortC .def OutD = R22 ; Temp-Register für Kanäle PortD .def Blink = R24 ; Zähler für Blink-Takt Status-LED/DMX-Timeout .def DMXstate = R25 ; Flag für DMX-Routine ; X-Pointer für DMX-Routine reserviert R31, R30 ; Y-Pointer für BCM-Routine reserviert R29, R28 ; Z-Pointer für DMX-BCM-umwandlung und SA-Daten R27, R26 ; ------------------------------------------------------------------------------------------------ .equ XTAL = 16000000 ; Prozessortakt 16 MHz (Bitte 16 MHz Quarz benutzen!) .equ DMX_Daten = 0x60 ; Startadresse DMX Array im RAM .equ DMX_Kanaele = 27 ; Zahl der DMX-Kanäle .equ BCM_Daten = 0x80 ; Startadresse für die BCM-Daten (4x12 werte) .equ DIP_Port = PortB ; Port für DIP-Schalter .equ DIP_Pin = PinB ; IN-Port für DIP-Schalter .equ DIP_DDR = DDRB ; DDR für DIP-Port .equ DIP_Clk = 0 ; Port-Pin für Schieberegister-Takt .equ DIP_9 = 1 ; Port-Pin für DIP9 .equ DIP_Port_Pl_In = PortA .equ DIP_Pin_Pl_In = PinA .equ DIP_DDR_Pl_In = DDRA .equ DIP_Pl = 0 ; Port-Pin für Schieberegister-Poll .equ DIP_In = 1 ; Port-Pin für Schieberegister-Ausgang ; ================================================================================================ ; Interrupt-Vektor-Tabelle Mega32 ; ------------------------------------------------------------------------------------------------ .CSEG .org 0x000 rjmp Start ; Reset Handler .org 0x002 reti ; External Interrupt Request 0 .org 0x004 reti ; External Interrupt Request 1 .org 0x006 reti ; External Interrupt Request 2 .org 0x008 reti ; Timer/Counter2 Compare Match .org 0x00A reti ; Timer/Counter2 Overflow .org 0x00C reti ; Timer/Counter1 Capture Event .org 0x00E rjmp BCM_start ; Timer/Counter1 Compare Match A --> BCM-Routine .org 0x010 reti ; Timer/Counter1 Compare Match B .org 0x012 reti ; Timer/Counter1 Overflow .org 0x014 reti ; Timer/Counter0 Compare Match .org 0x016 reti ; Timer/Counter0 Overflow .org 0x018 reti ; Serial Transfer Complete .org 0x01A rjmp DMX_Byte_Received ; Rx Complete --> Byte empfangen .org 0x01C reti ; Data Register Empty .org 0x01E reti ; Tx Complete .org 0x020 reti ; ADC Complete .org 0x022 reti ; EEPROM Ready .org 0x024 reti ; Analog Comparator .org 0x026 reti ; Two-Wire Serial Interface .org 0x028 reti ; Store Program Memory Ready ; ================================================================================================ ; Startup, Stackpointer und Ports setzen, etc. ; ------------------------------------------------------------------------------------------------ .org 0x030 Start: ldi temp0, LOW(RAMEND) ; LOW-Byte der obersten RAM-Adresse out SPL, temp0 ldi temp0, HIGH(RAMEND) ; HIGH-Byte der obersten RAM-Adresse out SPH, temp0 ser temp0 ; BCM-Ports auf Ausgang out DDRC, temp0 ldi temp0, 0b11111110 out DDRD, temp0 ldi temp0, 0b11111100 out DDRA, temp0 out DDRB, temp0 sbi DIP_DDR, DIP_Clk ; Ausgang für Clock sbi DIP_DDR_Pl_In, DIP_Pl ; Ausgang für Poll cbi DIP_DDR_Pl_In, DIP_In ; Eingang SR-Daten cbi DIP_DDR, DIP_9 ; Eingang DIP9 sbi DIP_Port, DIP_9 ; Pullup für DIP9 ; ------------------------------------------------------------------------------------------------ ; *** feste DMX-Startadresse einstellen *** ; ------------------------------------------------------------------------------------------------ ldi temp0, low(DMX_Adresse) mov DMX_Base_L, temp0 ldi temp0, high(DMX_Adresse) mov DMX_Base_H, temp0 ; ------------------------------------------------------------------------------------------------ rcall Get_DIP ; DIP-Schalter abfragen rcall DMX_Init ; DMX initialisieren rcall init_BCM_timer1 ; Timer1 für BCM initialisieren rcall BCM_calc_data ; BCM-Daten das erste mal berechnen sei ; Interrupts aktivieren ; ================================================================================================ ; Hauptschleife, macht nur Standalone, Rest passiert alles per ISR ; ------------------------------------------------------------------------------------------------ Main: sbrc BCMstate, 7 ; neuberecnung der BCM-Daten gefordert? rcall BCM_calc_data ; JA: springen. NEIN: rcall überspringen cpi Blink, 245 ; DMX-Timeout erreicht (245 = 1 Sek.)? brlo Main ; nein, nichts machen, ansonsten: ; ------------------------------------------------------------------------------------------------ ; Standalone-Routine, DMX-Puffer mit Farben füllen ; ------------------------------------------------------------------------------------------------ ldi ZH, high(DMX_Daten) ldi ZL, low(DMX_Daten) ldi temp0, (DMX_Kanaele/3) write_SA_Colour: ldi temp1, SA_R st Z+,temp1 ldi temp1, SA_G st Z+,temp1 ldi temp1, SA_B st Z+,temp1 dec temp0 brne write_SA_Colour rjmp Main ; ================================================================================================ ; ISR für BCM-Routiene ; ------------------------------------------------------------------------------------------------ BCM_start: in SREGbuf, SREG ; Register sichern push temp1 push temp0 sbrc BCMstate, 0 ; BCM Status bit 0 gesetzt? rjmp BCM_first_tick ; Ja: erster Tick ; Nein: rjmp überspringen sbrc BCMstate, 1 rjmp BCM_mid_ticks sbrc BCMstate, 2 rjmp BCM_last_tick BCM_first_tick: ; Hier wird der 1., 2. und der 3. Tick ausgegeben ; bevor das Interrupt wieder verlassen wird out PortA, OutA ; Neue Bitbelegung an den out PortB, OutB ; Ports ausgeben (dauert 4 Takte) out PortC, OutC out PortD, OutD ldi temp0, 0b01110000 ; Frühzeitig Ziel für das CompareMatch setzten: clr temp1 ; (16+32+64) = 112 Takte dauern die 1. 3 Ticks out OCR1AH, temp1 ; (dauert 4 Takte) out OCR1AL, temp0 ld OutA, Y+ ; Bitbelegung für den 2. Tick laden (dauert 8 Takte) ld OutB, Y+ ld OutC, Y+ ld OutD, Y+ out PortA, OutA ; Nach 16 Takten Bitbelegung für 2. Tick am port ausgeben out PortB, OutB out PortC, OutC out PortD, OutD ld OutA, Y+ ; Bitbelegung für den 3. Tick laden (dauert 8 Takte) ld OutB, Y+ ld OutC, Y+ ld OutD, Y+ andi BCMstate, 0b01110000 ; BCM status weitersetzten (1. Bit löschen, ori BCMstate, 0b00000010 ; 2. Bit setzten) (dauert 2 Takte) ;warten (18 Takte) nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop out PortA, OutA ; Nach 32 Takten Bitbelegung für out PortB, OutB ; 3. Tick am port ausgeben out PortC, OutC out PortD, OutD ld OutA, Y+ ; Bitbelegung für den 4. Tick vorladen ld OutB, Y+ ; (dauert 8 Takte) ld OutC, Y+ ld OutD, Y+ rjmp BCM_finish ; Interrupt verlassen BCM_mid_ticks: out PortA, OutA ; Neue Bitbelegung an den Ports ausgeben out PortB, OutB out PortC, OutC out PortD, OutD ; Ziel für das CompareMatch setzten: links-shift des output compare registers ; fals noch "112" als CompareMatch steht: 64 draus machen (Bit 0-5 löschen) in temp0, OCR1AL in temp1, OCR1AH andi temp0, 0b11000000 ; Bit 0-5 vorm rotieren löschen lsl temp0 rol temp1 out OCR1AH, temp1 out OCR1AL, temp0 ld OutA, Y+ ; Bitbelegung für den nächsten Tick laden ld OutB, Y+ ld OutC, Y+ ld OutD, Y+ sbrs temp1, 6 ; Ist dieser der vorletzte Tick? (16384 schritte, OCR1AH = 0x40) rjmp BCM_finish ; NEIN: fertig. JA: andi BCMstate, 0b11110000 ; BCM status weitersetzten ori BCMstate, 0b00000100 ; 1. Bit löschen, 2. Bit setzten rjmp BCM_finish BCM_last_tick: out PortA, OutA ; Neue Bitbelegung an den Ports ausgeben out PortB, OutB out PortC, OutC out PortD, OutD clr temp0 ; Ziel für das CompareMatch setzten: ldi temp1, 0x80 ; 12. Tick: 32768 als Ziel für das Compare-Match out OCR1AH, temp1 out OCR1AL, temp0 ori BCMstate, 0b10000000 ; BCM-daten in der Main-schleife neu berechnen ldi YH, high(BCM_Daten) ; Startadresse für die BCM-Daten laden ldi YL, low(BCM_Daten) ld OutA, Y+ ; Bitbelegung für den 1. Tick vorladen ld OutB, Y+ ld OutC, Y+ ld OutD, Y+ andi BCMstate, 0b10000000 ; BCM status auf "First Tick" setzten ori BCMstate, 0b00000001 cpi Blink,255 ; Timeout schon maximal? breq BCM_finish ; ja, nicht mehr weiterzählen inc Blink ; nein, Zeit hochzählen rjmp BCM_finish BCM_finish: pop temp0 pop temp1 out SREG, SREGbuf reti ; ================================================================================================ ; Hilfsroutiene für die BCM ; ------------------------------------------------------------------------------------------------ BCM_calc_data: ; Neue Daten berechnen und in den RAM schreiben ; passiert in dem größten tick, außerhalb des interrupts ;1. LED ; Zur verfügung stehen über 32000 Takte ldi ZH, high(DMX_Daten) ldi ZL, low(DMX_Daten) ld tempR, Z+ ld tempG, Z+ ld tempB, Z+ rcall Dimmerkurve ; läd die 12bit für R, G und B (65 Takte) ldi ZH, high(BCM_Daten) ldi ZL, low(BCM_Daten) ; 1. Tick (13. Takte) adiw Z, 0x01 ; PortA überspringen ld temp0, Z ; Alten wert laden andi temp0, 0b00011111 ; zielbits leeren sbrc tempR, 0 ori temp0, 0b10000000 ; zielbits spezifisch setzten sbrc tempG, 0 ori temp0, 0b01000000 sbrc tempB, 0 ori temp0, 0b00100000 st Z, temp0 ; in PortB speichern ; 2. Tick adiw Z, 0x04 ; 4 Weiter zählen (wieder port B) ld temp0, Z ; Alten wert laden andi temp0, 0b00011111 ; zielbits leeren sbrc tempR, 1 ori temp0, 0b10000000 ; zielbits spezifisch setzten sbrc tempG, 1 ori temp0, 0b01000000 sbrc tempB, 1 ori temp0, 0b00100000 st Z, temp0 ; in PortB speichern ; 3. Tick adiw Z, 0x04 ; 4 Weiter zählen (wieder port B) ld temp0, Z ; Alten wert laden andi temp0, 0b00011111 ; zielbits leeren sbrc tempR, 2 ori temp0, 0b10000000 ; zielbits spezifisch setzten sbrc tempG, 2 ori temp0, 0b01000000 sbrc tempB, 2 ori temp0, 0b00100000 st Z, temp0 ; in PortB speichern ;4. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 3 ori temp0, 0b10000000 sbrc tempG, 3 ori temp0, 0b01000000 sbrc tempB, 3 ori temp0, 0b00100000 st Z, temp0 ;5. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 4 ori temp0, 0b10000000 sbrc tempG, 4 ori temp0, 0b01000000 sbrc tempB, 4 ori temp0, 0b00100000 st Z, temp0 ;6. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 5 ori temp0, 0b10000000 sbrc tempG, 5 ori temp0, 0b01000000 sbrc tempB, 5 ori temp0, 0b00100000 st Z, temp0 ;7. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 6 ori temp0, 0b10000000 sbrc tempG, 6 ori temp0, 0b01000000 sbrc tempB, 6 ori temp0, 0b00100000 st Z, temp0 ;8. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 7 ori temp0, 0b10000000 sbrc tempG, 7 ori temp0, 0b01000000 sbrc tempB, 7 ori temp0, 0b00100000 st Z, temp0 ;9. Tick (ab jetzt die high-byte-temps) adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 0 ori temp0, 0b10000000 sbrc tempGh, 0 ori temp0, 0b01000000 sbrc tempBh, 0 ori temp0, 0b00100000 st Z, temp0 ;10. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 1 ori temp0, 0b10000000 sbrc tempGh, 1 ori temp0, 0b01000000 sbrc tempBh, 1 ori temp0, 0b00100000 st Z, temp0 ;11. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 2 ori temp0, 0b10000000 sbrc tempGh, 2 ori temp0, 0b01000000 sbrc tempBh, 2 ori temp0, 0b00100000 st Z, temp0 ;12. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 3 ori temp0, 0b10000000 sbrc tempGh, 3 ori temp0, 0b01000000 sbrc tempBh, 3 ori temp0, 0b00100000 st Z, temp0 ;2. LED ldi ZH, high(DMX_Daten+3) ldi ZL, low(DMX_Daten+3) ld tempR, Z+ ld tempG, Z+ ld tempB, Z+ rcall Dimmerkurve ldi ZH, high(BCM_Daten) ldi ZL, low(BCM_Daten) ;1. Tick (13. Takte) adiw Z, 0x01 ;PortA überspringen ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 0 ori temp0, 0b00010000 sbrc tempG, 0 ori temp0, 0b00001000 sbrc tempB, 0 ori temp0, 0b00000100 st Z, temp0 ;2. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 1 ori temp0, 0b00010000 sbrc tempG, 1 ori temp0, 0b00001000 sbrc tempB, 1 ori temp0, 0b00000100 st Z, temp0 ;3. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 2 ori temp0, 0b00010000 sbrc tempG, 2 ori temp0, 0b00001000 sbrc tempB, 2 ori temp0, 0b00000100 st Z, temp0 ;4. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 3 ori temp0, 0b00010000 sbrc tempG, 3 ori temp0, 0b00001000 sbrc tempB, 3 ori temp0, 0b00000100 st Z, temp0 ;5. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 4 ori temp0, 0b00010000 sbrc tempG, 4 ori temp0, 0b00001000 sbrc tempB, 4 ori temp0, 0b00000100 st Z, temp0 ;6. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 5 ori temp0, 0b00010000 sbrc tempG, 5 ori temp0, 0b00001000 sbrc tempB, 5 ori temp0, 0b00000100 st Z, temp0 ;7. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 6 ori temp0, 0b00010000 sbrc tempG, 6 ori temp0, 0b00001000 sbrc tempB, 6 ori temp0, 0b00000100 st Z, temp0 ;8. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 7 ori temp0, 0b00010000 sbrc tempG, 7 ori temp0, 0b00001000 sbrc tempB, 7 ori temp0, 0b00000100 st Z, temp0 ;9. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 0 ori temp0, 0b00010000 sbrc tempGh, 0 ori temp0, 0b00001000 sbrc tempBh, 0 ori temp0, 0b00000100 st Z, temp0 ;10. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 1 ori temp0, 0b00010000 sbrc tempGh, 1 ori temp0, 0b00001000 sbrc tempBh, 1 ori temp0, 0b00000100 st Z, temp0 ;11. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 2 ori temp0, 0b00010000 sbrc tempGh, 2 ori temp0, 0b00001000 sbrc tempBh, 2 ori temp0, 0b00000100 st Z, temp0 ;12. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 3 ori temp0, 0b00010000 sbrc tempGh, 3 ori temp0, 0b00001000 sbrc tempBh, 3 ori temp0, 0b00000100 st Z, temp0 ;3. LED (Dauert 230 Takte) ldi ZH, high(DMX_Daten+6) ldi ZL, low(DMX_Daten+6) ld tempR, Z+ ld tempG, Z+ ld tempB, Z+ rcall Dimmerkurve ldi ZH, high(BCM_Daten) ldi ZL, low(BCM_Daten) ;1. Tick (13. Takte) LED3 sitzt an PortA ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 0 ori temp0, 0b00000100 sbrc tempG, 0 ori temp0, 0b00001000 sbrc tempB, 0 ori temp0, 0b00010000 st Z, temp0 ;2. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 1 ori temp0, 0b00000100 sbrc tempG, 1 ori temp0, 0b00001000 sbrc tempB, 1 ori temp0, 0b00010000 st Z, temp0 ;3. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 2 ori temp0, 0b00000100 sbrc tempG, 2 ori temp0, 0b00001000 sbrc tempB, 2 ori temp0, 0b00010000 st Z, temp0 ;4. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 3 ori temp0, 0b00000100 sbrc tempG, 3 ori temp0, 0b00001000 sbrc tempB, 3 ori temp0, 0b00010000 st Z, temp0 ;5. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 4 ori temp0, 0b00000100 sbrc tempG, 4 ori temp0, 0b00001000 sbrc tempB, 4 ori temp0, 0b00010000 st Z, temp0 ;6. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 5 ori temp0, 0b00000100 sbrc tempG, 5 ori temp0, 0b00001000 sbrc tempB, 5 ori temp0, 0b00010000 st Z, temp0 ;7. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 6 ori temp0, 0b00000100 sbrc tempG, 6 ori temp0, 0b00001000 sbrc tempB, 6 ori temp0, 0b00010000 st Z, temp0 ;8. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 7 ori temp0, 0b00000100 sbrc tempG, 7 ori temp0, 0b00001000 sbrc tempB, 7 ori temp0, 0b00010000 st Z, temp0 ;9. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 0 ori temp0, 0b00000100 sbrc tempGh, 0 ori temp0, 0b00001000 sbrc tempBh, 0 ori temp0, 0b00010000 st Z, temp0 ;10. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 1 ori temp0, 0b00000100 sbrc tempGh, 1 ori temp0, 0b00001000 sbrc tempBh, 1 ori temp0, 0b00010000 st Z, temp0 ;11. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 2 ori temp0, 0b00000100 sbrc tempGh, 2 ori temp0, 0b00001000 sbrc tempBh, 2 ori temp0, 0b00010000 st Z, temp0 ;12. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 3 ori temp0, 0b00000100 sbrc tempGh, 3 ori temp0, 0b00001000 sbrc tempBh, 3 ori temp0, 0b00010000 st Z, temp0 ;4. LED (Dauert 230 Takte) ldi ZH, high(DMX_Daten+9) ldi ZL, low(DMX_Daten+9) ld tempR, Z+ ld tempG, Z+ ld tempB, Z+ rcall Dimmerkurve ldi ZH, high(BCM_Daten) ldi ZL, low(BCM_Daten) ;1. Tick (13. Takte) adiw Z, 0x03 ;Auf PortD springen ld temp0, Z andi temp0, 0b10001111 sbrc tempR, 0 ori temp0, 0b01000000 sbrc tempG, 0 ori temp0, 0b00100000 sbrc tempB, 0 ori temp0, 0b00010000 st Z, temp0 ;2. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b10001111 sbrc tempR, 1 ori temp0, 0b01000000 sbrc tempG, 1 ori temp0, 0b00100000 sbrc tempB, 1 ori temp0, 0b00010000 st Z, temp0 ;3. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b10001111 sbrc tempR, 2 ori temp0, 0b01000000 sbrc tempG, 2 ori temp0, 0b00100000 sbrc tempB, 2 ori temp0, 0b00010000 st Z, temp0 ;4. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b10001111 sbrc tempR, 3 ori temp0, 0b01000000 sbrc tempG, 3 ori temp0, 0b00100000 sbrc tempB, 3 ori temp0, 0b00010000 st Z, temp0 ;5. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b10001111 sbrc tempR, 4 ori temp0, 0b01000000 sbrc tempG, 4 ori temp0, 0b00100000 sbrc tempB, 4 ori temp0, 0b00010000 st Z, temp0 ;6. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b10001111 sbrc tempR, 5 ori temp0, 0b01000000 sbrc tempG, 5 ori temp0, 0b00100000 sbrc tempB, 5 ori temp0, 0b00010000 st Z, temp0 ;7. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b10001111 sbrc tempR, 6 ori temp0, 0b01000000 sbrc tempG, 6 ori temp0, 0b00100000 sbrc tempB, 6 ori temp0, 0b00010000 st Z, temp0 ;8. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b10001111 sbrc tempR, 7 ori temp0, 0b01000000 sbrc tempG, 7 ori temp0, 0b00100000 sbrc tempB, 7 ori temp0, 0b00010000 st Z, temp0 ;9. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b10001111 sbrc tempRh, 0 ori temp0, 0b01000000 sbrc tempGh, 0 ori temp0, 0b00100000 sbrc tempBh, 0 ori temp0, 0b00010000 st Z, temp0 ;10. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b10001111 sbrc tempRh, 1 ori temp0, 0b01000000 sbrc tempGh, 1 ori temp0, 0b00100000 sbrc tempBh, 1 ori temp0, 0b00010000 st Z, temp0 ;11. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b10001111 sbrc tempRh, 2 ori temp0, 0b01000000 sbrc tempGh, 2 ori temp0, 0b00100000 sbrc tempBh, 2 ori temp0, 0b00010000 st Z, temp0 ;12. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b10001111 sbrc tempRh, 3 ori temp0, 0b01000000 sbrc tempGh, 3 ori temp0, 0b00100000 sbrc tempBh, 3 ori temp0, 0b00010000 st Z, temp0 ;5. LED ldi ZH, high(DMX_Daten+12) ldi ZL, low(DMX_Daten+12) ld tempR, Z+ ld tempG, Z+ ld tempB, Z+ rcall Dimmerkurve ldi ZH, high(BCM_Daten) ldi ZL, low(BCM_Daten) ;1. Tick adiw Z, 0x03 ;Auf PortD springen ld temp0, Z andi temp0, 0b11110001 sbrc tempR, 0 ori temp0, 0b00001000 sbrc tempG, 0 ori temp0, 0b00000100 sbrc tempB, 0 ori temp0, 0b00000010 st Z, temp0 ;2. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11110001 sbrc tempR, 1 ori temp0, 0b00001000 sbrc tempG, 1 ori temp0, 0b00000100 sbrc tempB, 1 ori temp0, 0b00000010 st Z, temp0 ;3. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11110001 sbrc tempR, 2 ori temp0, 0b00001000 sbrc tempG, 2 ori temp0, 0b00000100 sbrc tempB, 2 ori temp0, 0b00000010 st Z, temp0 ;4. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11110001 sbrc tempR, 3 ori temp0, 0b00001000 sbrc tempG, 3 ori temp0, 0b00000100 sbrc tempB, 3 ori temp0, 0b00000010 st Z, temp0 ;5. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11110001 sbrc tempR, 4 ori temp0, 0b00001000 sbrc tempG, 4 ori temp0, 0b00000100 sbrc tempB, 4 ori temp0, 0b00000010 st Z, temp0 ;6. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11110001 sbrc tempR, 5 ori temp0, 0b00001000 sbrc tempG, 5 ori temp0, 0b00000100 sbrc tempB, 5 ori temp0, 0b00000010 st Z, temp0 ;7. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11110001 sbrc tempR, 6 ori temp0, 0b00001000 sbrc tempG, 6 ori temp0, 0b00000100 sbrc tempB, 6 ori temp0, 0b00000010 st Z, temp0 ;8. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11110001 sbrc tempR, 7 ori temp0, 0b00001000 sbrc tempG, 7 ori temp0, 0b00000100 sbrc tempB, 7 ori temp0, 0b00000010 st Z, temp0 ;9. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11110001 sbrc tempRh, 0 ori temp0, 0b00001000 sbrc tempGh, 0 ori temp0, 0b00000100 sbrc tempBh, 0 ori temp0, 0b00000010 st Z, temp0 ;10. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11110001 sbrc tempRh, 1 ori temp0, 0b00001000 sbrc tempGh, 1 ori temp0, 0b00000100 sbrc tempBh, 1 ori temp0, 0b00000010 st Z, temp0 ;11. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11110001 sbrc tempRh, 2 ori temp0, 0b00001000 sbrc tempGh, 2 ori temp0, 0b00000100 sbrc tempBh, 2 ori temp0, 0b00000010 st Z, temp0 ;12. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11110001 sbrc tempRh, 3 ori temp0, 0b0001000 sbrc tempGh, 3 ori temp0, 0b0000100 sbrc tempBh, 3 ori temp0, 0b0000010 st Z, temp0 ;6. LED (Dauert 230 Takte) ldi ZH, high(DMX_Daten+15) ldi ZL, low(DMX_Daten+15) ld tempR, Z+ ld tempG, Z+ ld tempB, Z+ rcall Dimmerkurve ldi ZH, high(BCM_Daten) ldi ZL, low(BCM_Daten) ;1. Tick (13. Takte) ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 0 ori temp0, 0b00100000 sbrc tempG, 0 ori temp0, 0b01000000 sbrc tempB, 0 ori temp0, 0b10000000 st Z, temp0 ;2. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 1 ori temp0, 0b00100000 sbrc tempG, 1 ori temp0, 0b01000000 sbrc tempB, 1 ori temp0, 0b10000000 st Z, temp0 ;3. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 2 ori temp0, 0b00100000 sbrc tempG, 2 ori temp0, 0b01000000 sbrc tempB, 2 ori temp0, 0b10000000 st Z, temp0 ;4. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 3 ori temp0, 0b00100000 sbrc tempG, 3 ori temp0, 0b01000000 sbrc tempB, 3 ori temp0, 0b10000000 st Z, temp0 ;5. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 4 ori temp0, 0b00100000 sbrc tempG, 4 ori temp0, 0b01000000 sbrc tempB, 4 ori temp0, 0b10000000 st Z, temp0 ;6. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 5 ori temp0, 0b00100000 sbrc tempG, 5 ori temp0, 0b01000000 sbrc tempB, 5 ori temp0, 0b10000000 st Z, temp0 ;7. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 6 ori temp0, 0b00100000 sbrc tempG, 6 ori temp0, 0b01000000 sbrc tempB, 6 ori temp0, 0b10000000 st Z, temp0 ;8. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 7 ori temp0, 0b00100000 sbrc tempG, 7 ori temp0, 0b01000000 sbrc tempB, 7 ori temp0, 0b10000000 st Z, temp0 ;9. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 0 ori temp0, 0b00100000 sbrc tempGh, 0 ori temp0, 0b01000000 sbrc tempBh, 0 ori temp0, 0b10000000 st Z, temp0 ;10. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 1 ori temp0, 0b00100000 sbrc tempGh, 1 ori temp0, 0b01000000 sbrc tempBh, 1 ori temp0, 0b10000000 st Z, temp0 ;11. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 2 ori temp0, 0b00100000 sbrc tempGh, 2 ori temp0, 0b01000000 sbrc tempBh, 2 ori temp0, 0b10000000 st Z, temp0 ;12. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 3 ori temp0, 0b00100000 sbrc tempGh, 3 ori temp0, 0b01000000 sbrc tempBh, 3 ori temp0, 0b10000000 st Z, temp0 ;7. LED (Dauert 230 Takte und n bisschen O.o ) ldi ZH, high(DMX_Daten+18) ldi ZL, low(DMX_Daten+18) ld tempR, Z+ ld tempG, Z+ ld tempB, Z+ rcall Dimmerkurve ldi ZH, high(BCM_Daten) ldi ZL, low(BCM_Daten) ;1. Tick (13. Takte) adiw Z, 0x02 ;Erst auf PortC springen ld temp0, Z andi temp0, 0b11111100 sbrc tempR, 0 ori temp0, 0b00000010 sbrc tempG, 0 ori temp0, 0b00000001 st Z+, temp0 ;und dann auf Port D ld temp0, Z andi temp0, 0b01111111 sbrc tempB, 0 ori temp0, 0b10000000 st Z, temp0 ;2. Tick adiw Z, 0x03 ld temp0, Z andi temp0, 0b11111100 sbrc tempR, 1 ori temp0, 0b00000010 sbrc tempG, 1 ori temp0, 0b00000001 st Z+, temp0 ld temp0, Z andi temp0, 0b01111111 sbrc tempB, 1 ori temp0, 0b10000000 st Z, temp0 ;3. Tick adiw Z, 0x03 ld temp0, Z andi temp0, 0b11111100 sbrc tempR, 2 ori temp0, 0b00000010 sbrc tempG, 2 ori temp0, 0b00000001 st Z+, temp0 ld temp0, Z andi temp0, 0b01111111 sbrc tempB, 2 ori temp0, 0b10000000 st Z, temp0 ;4. Tick adiw Z, 0x03 ld temp0, Z andi temp0, 0b11111100 sbrc tempR, 3 ori temp0, 0b00000010 sbrc tempG, 3 ori temp0, 0b00000001 st Z+, temp0 ld temp0, Z andi temp0, 0b01111111 sbrc tempB, 3 ori temp0, 0b10000000 st Z, temp0 ;5. Tick adiw Z, 0x03 ld temp0, Z andi temp0, 0b11111100 sbrc tempR, 4 ori temp0, 0b00000010 sbrc tempG, 4 ori temp0, 0b00000001 st Z+, temp0 ld temp0, Z andi temp0, 0b01111111 sbrc tempB, 4 ori temp0, 0b10000000 st Z, temp0 ;6. Tick adiw Z, 0x03 ld temp0, Z andi temp0, 0b11111100 sbrc tempR, 5 ori temp0, 0b00000010 sbrc tempG, 5 ori temp0, 0b00000001 st Z+, temp0 ld temp0, Z andi temp0, 0b01111111 sbrc tempB, 5 ori temp0, 0b10000000 st Z, temp0 ;7. Tick adiw Z, 0x03 ld temp0, Z andi temp0, 0b11111100 sbrc tempR, 6 ori temp0, 0b00000010 sbrc tempG, 6 ori temp0, 0b00000001 st Z+, temp0 ld temp0, Z andi temp0, 0b01111111 sbrc tempB, 6 ori temp0, 0b10000000 st Z, temp0 ;8. Tick adiw Z, 0x03 ld temp0, Z andi temp0, 0b11111100 sbrc tempR, 7 ori temp0, 0b00000010 sbrc tempG, 7 ori temp0, 0b00000001 st Z+, temp0 ld temp0, Z andi temp0, 0b01111111 sbrc tempB, 7 ori temp0, 0b10000000 st Z, temp0 ;9. Tick adiw Z, 0x03 ld temp0, Z andi temp0, 0b11111100 sbrc tempRh, 0 ori temp0, 0b00000010 sbrc tempGh, 0 ori temp0, 0b00000001 st Z+, temp0 ld temp0, Z andi temp0, 0b01111111 sbrc tempBh, 0 ori temp0, 0b10000000 st Z, temp0 ;10. Tick adiw Z, 0x03 ld temp0, Z andi temp0, 0b11111100 sbrc tempRh, 1 ori temp0, 0b00000010 sbrc tempGh, 1 ori temp0, 0b00000001 st Z+, temp0 ld temp0, Z andi temp0, 0b01111111 sbrc tempBh, 1 ori temp0, 0b10000000 st Z, temp0 ;11. Tick adiw Z, 0x03 ld temp0, Z andi temp0, 0b11111100 sbrc tempRh, 2 ori temp0, 0b00000010 sbrc tempGh, 2 ori temp0, 0b00000001 st Z+, temp0 ld temp0, Z andi temp0, 0b01111111 sbrc tempBh, 2 ori temp0, 0b10000000 st Z, temp0 ;12. Tick adiw Z, 0x03 ld temp0, Z andi temp0, 0b11111100 sbrc tempRh, 3 ori temp0, 0b00000010 sbrc tempGh, 3 ori temp0, 0b00000001 st Z+, temp0 ld temp0, Z andi temp0, 0b01111111 sbrc tempBh, 3 ori temp0, 0b10000000 st Z, temp0 ;8. LED (Dauert 230 Takte) ldi ZH, high(DMX_Daten+21) ldi ZL, low(DMX_Daten+21) ld tempR, Z+ ld tempG, Z+ ld tempB, Z+ rcall Dimmerkurve ldi ZH, high(BCM_Daten) ldi ZL, low(BCM_Daten) ;1. Tick (13. Takte) adiw Z, 0x02 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 0 ori temp0, 0b00010000 sbrc tempG, 0 ori temp0, 0b00001000 sbrc tempB, 0 ori temp0, 0b00000100 st Z, temp0 ;2. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 1 ori temp0, 0b00010000 sbrc tempG, 1 ori temp0, 0b00001000 sbrc tempB, 1 ori temp0, 0b00000100 st Z, temp0 ;3. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 2 ori temp0, 0b00010000 sbrc tempG, 2 ori temp0, 0b00001000 sbrc tempB, 2 ori temp0, 0b00000100 st Z, temp0 ;4. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 3 ori temp0, 0b00010000 sbrc tempG, 3 ori temp0, 0b00001000 sbrc tempB, 3 ori temp0, 0b00000100 st Z, temp0 ;5. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 4 ori temp0, 0b00010000 sbrc tempG, 4 ori temp0, 0b00001000 sbrc tempB, 4 ori temp0, 0b00000100 st Z, temp0 ;6. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 5 ori temp0, 0b00010000 sbrc tempG, 5 ori temp0, 0b00001000 sbrc tempB, 5 ori temp0, 0b00000100 st Z, temp0 ;7. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 6 ori temp0, 0b00010000 sbrc tempG, 6 ori temp0, 0b00001000 sbrc tempB, 6 ori temp0, 0b00000100 st Z, temp0 ;8. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempR, 7 ori temp0, 0b00010000 sbrc tempG, 7 ori temp0, 0b00001000 sbrc tempB, 7 ori temp0, 0b00000100 st Z, temp0 ;9. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 0 ori temp0, 0b00010000 sbrc tempGh, 0 ori temp0, 0b00001000 sbrc tempBh, 0 ori temp0, 0b00000100 st Z, temp0 ;10. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 1 ori temp0, 0b00010000 sbrc tempGh, 1 ori temp0, 0b00001000 sbrc tempBh, 1 ori temp0, 0b00000100 st Z, temp0 ;11. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 2 ori temp0, 0b00010000 sbrc tempGh, 2 ori temp0, 0b00001000 sbrc tempBh, 2 ori temp0, 0b00000100 st Z, temp0 ;12. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b11100011 sbrc tempRh, 3 ori temp0, 0b00010000 sbrc tempGh, 3 ori temp0, 0b00001000 sbrc tempBh, 3 ori temp0, 0b00000100 st Z, temp0 ;9. LED (Dauert 230 Takte) ldi ZH, high(DMX_Daten+24) ldi ZL, low(DMX_Daten+24) ld tempR, Z+ ld tempG, Z+ ld tempB, Z+ rcall Dimmerkurve ldi ZH, high(BCM_Daten) ldi ZL, low(BCM_Daten) ;1. Tick (13. Takte) adiw Z, 0x02 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 0 ori temp0, 0b10000000 sbrc tempG, 0 ori temp0, 0b01000000 sbrc tempB, 0 ori temp0, 0b00100000 st Z, temp0 ;2. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 1 ori temp0, 0b10000000 sbrc tempG, 1 ori temp0, 0b01000000 sbrc tempB, 1 ori temp0, 0b00100000 st Z, temp0 ;3. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 2 ori temp0, 0b10000000 sbrc tempG, 2 ori temp0, 0b01000000 sbrc tempB, 2 ori temp0, 0b00100000 st Z, temp0 ;4. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 3 ori temp0, 0b10000000 sbrc tempG, 3 ori temp0, 0b01000000 sbrc tempB, 3 ori temp0, 0b00100000 st Z, temp0 ;5. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 4 ori temp0, 0b10000000 sbrc tempG, 4 ori temp0, 0b01000000 sbrc tempB, 4 ori temp0, 0b00100000 st Z, temp0 ;6. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 5 ori temp0, 0b10000000 sbrc tempG, 5 ori temp0, 0b01000000 sbrc tempB, 5 ori temp0, 0b00100000 st Z, temp0 ;7. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 6 ori temp0, 0b10000000 sbrc tempG, 6 ori temp0, 0b01000000 sbrc tempB, 6 ori temp0, 0b00100000 st Z, temp0 ;8. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempR, 7 ori temp0, 0b10000000 sbrc tempG, 7 ori temp0, 0b01000000 sbrc tempB, 7 ori temp0, 0b00100000 st Z, temp0 ;9. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 0 ori temp0, 0b10000000 sbrc tempGh, 0 ori temp0, 0b01000000 sbrc tempBh, 0 ori temp0, 0b00100000 st Z, temp0 ;10. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 1 ori temp0, 0b10000000 sbrc tempGh, 1 ori temp0, 0b01000000 sbrc tempBh, 1 ori temp0, 0b00100000 st Z, temp0 ;11. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 2 ori temp0, 0b10000000 sbrc tempGh, 2 ori temp0, 0b01000000 sbrc tempBh, 2 ori temp0, 0b00100000 st Z, temp0 ;12. Tick adiw Z, 0x04 ld temp0, Z andi temp0, 0b00011111 sbrc tempRh, 3 ori temp0, 0b10000000 sbrc tempGh, 3 ori temp0, 0b01000000 sbrc tempBh, 3 ori temp0, 0b00100000 st Z, temp0 andi BCMstate, 0b01111111 ; Als berechnet markieren ret ; ================================================================================================ ; ISR für DMX-Empfang ; ------------------------------------------------------------------------------------------------ DMX_Byte_Received: in SREGbuf, SREG ; Register sichern push temp1 push temp0 in temp0,UCSRA ; USART Status und Daten holen in temp1,UDR sbrc temp0,FE ; Frame-Error: neuer Durchgang rjmp dmx_frame_error cpi DMXstate, 1 ; DMX-Status 1: Startbyte testen breq dmx_startbyte cpi DMXstate, 2 ; DMX-Status 2: Startadresse abfragen breq dmx_startadr cpi DMXstate, 3 ; DMX-Status 3: Byte empfangen und in's RAM brsh dmx_handle_byte dmx_finish: pop temp0 pop temp1 out SREG, SREGbuf reti dmx_startbyte: tst temp1 ; Byte = 0 --> Startbyte, sonst Fehler brne dmx_err inc DMXstate mov XL, DMX_Base_L ; Startadresse aus den Registern holen mov XH, DMX_Base_H rjmp dmx_finish dmx_startadr: sbiw XH:XL, 1 ; Adresse runterzählen brne dmx_finish ; Startadresse noch nicht erreicht ldi XH, high(DMX_Daten) ldi XL, low(DMX_Daten) inc DMXstate dmx_handle_byte: st X+, temp1 ; empfangenes Byte speichern clr Blink ; Timeout-Zähler resetten cpi XL, low(DMX_Daten+DMX_Kanaele) brne dmx_finish cpi XH, high(DMX_Daten+DMX_Kanaele) brne dmx_finish clr DMXstate rjmp dmx_finish dmx_frame_error: ldi DMXstate, 1 ; Frame-Error --> neuer Durchlauf cbi UCSRA,FE ; Flag löschen, falls längere Pause rjmp dmx_finish dmx_err: clr DMXstate ; auf nächsten FE warten rjmp dmx_finish ; ================================================================================================ ; Timer für BCM initialisieren ; ------------------------------------------------------------------------------------------------ init_BCM_timer1: ldi temp0, (1<