.nolist .include "m8def.inc" .list .def save_sreg = r0 .def iwr0 = r1 .def iwr1 = r2 .def key_old = r3 .def key_state = r4 .def key_press = r5 .equ key_port = pinc .equ led_port = portc .def temp1 = r16 .def temp2 = r17 .def temp3 = r18 .def temp4 = r19 ;Zähler LS Einfahrt EG .def temp5 = r20 ;Zähler LS Einfahrt OG .def temp6 = r21 ;Zähler LS Ausfahrt EG .def temp7 = r22 ;Zähler LS Ausfahrt OG .def temp8 = r23 ;BelegungEG .def temp9 = r24 ;BelegungOG ldi temp1, HIGH(RAMEND) ; HIGH-Byte der obersten RAM-Adresse out SPH, temp1 ldi temp1, LOW(RAMEND) ; LOW-Byte der obersten RAM-Adresse out SPL, temp1 ldi temp1, 0b11111111 ;Port D = Ausgang out DDRD, temp1 rcall lcd_init ;Display initialisieren rcall lcd_clear ;Display löschen rcall lcd_init1 rcall lcd_clear1 rcall lcd_clear ldi temp1, 0b10000000 rcall lcd_command ldi temp1, 'P' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'a' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'r' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'k' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'h' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'a' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'u' ;Zeichen anzeigen rcall lcd_data ldi temp1, 's' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'a' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'n' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'z' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'e' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'i' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'g' ;Zeichen anzeigen rcall lcd_data ldi temp1, 'e' ;Zeichen anzeigen rcall lcd_data ldi temp1, 0b11001100 rcall lcd_command ldi temp1, 'b' rcall lcd_data ldi temp1, 'y' rcall lcd_data ldi temp1, ' ' rcall lcd_data ldi temp1, 'B' rcall lcd_data ldi temp1, 'j' rcall lcd_data ldi temp1, 0xFE rcall lcd_data ldi temp1, 'r' rcall lcd_data ldi temp1, 'n' rcall lcd_data ldi temp1, ' ' rcall lcd_data ldi temp1, 'K' rcall lcd_data ldi temp1, 'e' rcall lcd_data ldi temp1, 'm' rcall lcd_data ldi temp1, 'm' rcall lcd_data ldi temp1, 'e' rcall lcd_data ldi temp1, 'r' rcall lcd_data ldi temp8, 0 ldi temp9, 0 Main: sbic PINC, 0 rcall EinfEGp1 sbic PINC, 1 rcall AusfEGp1 sbic PINC, 2 rcall EinfOGp1 sbic PINC, 3 rcall AusfOGp1 rcall AuswertungEG0to7 rcall AuswertungEG8to14 rcall AuswertungEG15to20 rcall AuswertungOG0to7 rcall AuswertungOG8to14 rcall AuswertungOG15to20 rjmp Main EinfEGp1: rcall tast subi temp4, -1 rcall BelegEGp1 ret AusfEGp1: subi temp5, -1 rcall BelegEGm1 ret EinfOGp1: subi temp6, -1 rcall BelegEGm1 rcall BelegOGp1 ret AusfOGp1: subi temp7, -1 rcall BelegEGp1 rcall BelegOGm1 ret BelegEGp1: subi temp8, -1 ret BelegEGm1: subi temp8, 1 ret BelegOGp1: subi temp9, -1 ret BelegOGm1: subi temp9, 1 ret AuswertungEG0to7: cpi temp8,0 breq EG0 cpi temp8,1 breq EG1 cpi temp8,2 breq EG2 cpi temp8,3 breq EG3 cpi temp8,4 breq EG4 cpi temp8,5 breq EG5 cpi temp8,6 breq EG6 cpi temp8,7 breq EG7 ret EG0: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '0' rcall lcd_data1 ret EG1: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ret EG2: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '2' rcall lcd_data1 ret EG3: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '3' rcall lcd_data1 ret EG4: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '4' rcall lcd_data1 ret EG5: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '5' rcall lcd_data1 ret EG6: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '6' rcall lcd_data1 ret EG7: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '7' rcall lcd_data1 ret AuswertungEG8to14: cpi temp8,0 cpi temp8,8 breq EG8 cpi temp8,9 breq EG9 cpi temp8,10 breq EG10 cpi temp8,11 breq EG11 cpi temp8,12 breq EG12 cpi temp8,13 breq EG13 cpi temp8,14 breq EG14 ret EG8: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '8' rcall lcd_data1 ret EG9: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '9' rcall lcd_data1 ret EG10: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '0' rcall lcd_data1 ret EG11: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '1' rcall lcd_data1 ret EG12: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '2' rcall lcd_data1 ret EG13: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '3' rcall lcd_data1 ret EG14: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '4' rcall lcd_data1 ret AuswertungEG15to20: cpi temp8,15 breq EG15 cpi temp8,16 breq EG16 cpi temp8,17 breq EG17 cpi temp8,18 breq EG18 cpi temp8,19 breq EG19 cpi temp8,20 breq EG20 ret EG15: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '5' rcall lcd_data1 ret EG16: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '6' rcall lcd_data1 ret EG17: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '7' rcall lcd_data1 ret EG18: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '8' rcall lcd_data1 ret EG19: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '9' rcall lcd_data1 ret EG20: ldi temp1, 0b11000000 rcall lcd_command1 ldi temp1, '2' rcall lcd_data1 ldi temp1, '0' rcall lcd_data1 ret AuswertungOG0to7: cpi temp9,0 breq OG0 cpi temp9,1 breq OG1 cpi temp9,2 breq OG2 cpi temp9,3 breq OG3 cpi temp9,4 breq OG4 cpi temp9,5 breq OG5 cpi temp9,6 breq OG6 cpi temp9,7 breq OG7 ret OG0: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '0' rcall lcd_data1 ret OG1: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ret OG2: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '2' rcall lcd_data1 ret OG3: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '3' rcall lcd_data1 ret OG4: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '4' rcall lcd_data1 ret OG5: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '5' rcall lcd_data1 ret OG6: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '6' rcall lcd_data1 ret OG7: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '7' rcall lcd_data1 ret AuswertungOG8to14: cpi temp9,8 breq OG8 cpi temp9,9 breq OG9 cpi temp9,10 breq OG10 cpi temp9,11 breq OG11 cpi temp9,12 breq OG12 cpi temp9,13 breq OG13 cpi temp9,14 breq OG14 ret OG8: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '8' rcall lcd_data1 ret OG9: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '9' rcall lcd_data1 ret OG10: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '0' rcall lcd_data1 ret OG11: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '1' rcall lcd_data1 ret OG12: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '2' rcall lcd_data1 ret OG13: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '3' rcall lcd_data1 ret OG14: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '4' rcall lcd_data1 ret AuswertungOG15to20: cpi temp9,15 breq OG15 cpi temp9,16 breq OG16 cpi temp9,17 breq OG17 cpi temp9,18 breq OG18 cpi temp9,19 breq OG19 cpi temp9,20 breq OG20 ret OG15: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '5' rcall lcd_data1 ret OG16: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '6' rcall lcd_data1 ret OG17: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '1' ldi temp1, '7' rcall lcd_data1 rcall lcd_data1 ret OG18: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '8' rcall lcd_data1 ret OG19: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '1' rcall lcd_data1 ldi temp1, '9' rcall lcd_data1 ret OG20: ldi temp1, 0b11001100 rcall lcd_command1 ldi temp1, '2' rcall lcd_data1 ldi temp1, '0' rcall lcd_data1 ret lcd_init: ldi temp1, 0b00000011 out PORTD, temp1 rcall lcd_enable rcall delay5ms rcall lcd_enable rcall delay5ms rcall lcd_enable rcall delay5ms ldi temp1, 0b00100000 rcall lcd_command ldi temp1, 0b00101000 rcall lcd_command ldi temp1, 0b00001100 rcall lcd_command ldi temp1, 0b00000100 rcall lcd_command ret lcd_data: mov temp2, temp1 swap temp1 andi temp1, 0b00001111 ori temp1, 0b00010000 out PORTD, temp1 rcall lcd_enable andi temp2, 0b00001111 ori temp2, 0b00010000 out PORTD, temp2 rcall lcd_enable rcall delay50us ret lcd_command: mov temp2, temp1 swap temp1 andi temp1, 0b00001111 out PORTD, temp1 rcall lcd_enable andi temp2, 0b00001111 out PORTD, temp2 rcall lcd_enable rcall delay50us ret lcd_enable: sbi PORTD, 5 nop nop nop cbi PORTD, 5 ret delay50us: ldi temp1, 41 delay50us_: nop dec temp1 brne delay50us_ ret delay5ms: ldi temp1, 21 WGLOOP0: ldi temp2, 195 nop WGLOOP1: dec temp2 nop brne WGLOOP1 dec temp1 brne WGLOOP0 ret lcd_clear: ldi temp1, 0b00000001 rcall lcd_command rcall delay5ms ret lcd_init1: ldi temp1, 0b00000011 out PORTD, temp1 rcall lcd_enable1 rcall delay5ms rcall lcd_enable1 rcall delay5ms rcall lcd_enable1 rcall delay5ms1 ldi temp1, 0b00100000 rcall lcd_command1 ldi temp1, 0b00101000 rcall lcd_command ldi temp1, 0b00001100 rcall lcd_command1 ldi temp1, 0b00000100 rcall lcd_command1 ret lcd_data1: mov temp2, temp1 swap temp1 andi temp1, 0b00001111 ori temp1, 0b00010000 out PORTD, temp1 rcall lcd_enable1 andi temp2, 0b00001111 ori temp2, 0b00010000 out PORTD, temp2 rcall lcd_enable1 rcall delay50us ret lcd_command1: mov temp2, temp1 swap temp1 andi temp1, 0b00001111 out PORTD, temp1 rcall lcd_enable1 andi temp2, 0b00001111 out PORTD, temp2 rcall lcd_enable1 rcall delay50us1 ret lcd_enable1: sbi PORTD, 6 nop nop nop cbi PORTD, 6 ret delay50us1: ldi temp1, 41 delay50us_1: nop dec temp1 brne delay50us_1 ret delay5ms1: ldi temp1, 21 WGLOOP01: ldi temp2, 195 nop WGLOOP11: dec temp2 nop brne WGLOOP11 dec temp1 brne WGLOOP01 ret lcd_clear1: ldi temp1, 0b00000001 rcall lcd_command1 rcall delay5ms ret tast: rjmp init .org OVF0addr in save_sreg, SREG get8key: ;/old state iwr1 iwr0 mov iwr0, key_old ;00110011 10101010 00110011 in key_old, key_port ;11110000 eor iwr0, key_old ; 11000011 com key_old ;00001111 mov iwr1, key_state ; 10101010 or key_state, iwr0 ; 11101011 and iwr0, key_old ; 00000011 eor key_state, iwr0 ; 11101000 and iwr1, iwr0 ; 00000010 or key_press, iwr1 ; ; out SREG, save_sreg reti ;------------------------------------------------------------------------- init: ldi temp2, 0xFF out ddrc, temp2 ldi wr0, 1<