.include "m8def.inc" ;****************************** ; Pin Belegung ;DB4-7 = PORT D. 0-3 ;ENABLE=PORT D Pin 7 ;RS= PORTD Pin 4 .def temp = r16 .def temp1=r17 .def t0_status=r18 .def dcf=r19 ; Hier wird gespeichert ob vom dcf eine 0 oder 1 erkannt wurde. .equ pin=2 .equ LCD_PORT = PORTC ;Auf PORTC stellen .equ LCD_DDR = DDRC .equ enable=5 .equ rs=4 .org 0x0000 rjmp main .org INT0addr rjmp int0_handler .org OVF0addr rjmp timer0_overflow ; Timer Overflow Handler main: ldi temp, LOW(RAMEND) ; Stackpointer initialisieren out SPL, temp ldi temp, HIGH(RAMEND) out SPH, temp ;****************************** ; INTERRUPT 0 konfigurieren ldi temp, 0b00000010 ; INT0 out MCUCR, temp ldi temp, 1 << TOIE0 ; Bei überlauf Interrupt out TIMSK, temp ;****************************** ; T I M E R 0 konfigurieren ldi temp, 0b00000000 ; Timer für den Anfang ausschalten! out TCCR0, temp ldi temp, 0x06 ; Zählbeginng mit 64er prescale=1ms bis overflow! out TCNT0, temp ;****************************** ;****************************** ; P O R T KONFIGURATION ldi temp,0xFF ;LCDPORT Ausgang einstellen out LCD_DDR, temp ldi temp,0x00 ; Port D ( Interrupt port) out DDRD,temp ldi temp, 0x00 ; Pull ups aktivieren out PORTD, temp ;Port D ist nun Eingang mit Pullups. -noetig um fallende flanke zu erkennen ;***************************** ;******************************* ; Für definierte Zustände sorgen ldi temp1, 0b00000000 ldi t0_status, 0b00000000 ldi dcf, 0b00000000 ;sei ; Kommt erst nach LCD init um schreiben auf un-initialisiertes Display zu verhindern lcdinit: ldi temp, 0x00 out LCD_PORT, temp ;****************************************** ; LCD mitteilen, dass im 4 Bit Modus gearbeitet wird rcall delay15ms ;Hier mindestens 15ms warten! rcall delay15ms ;Zur sicherheit! z.b. nach Stromeinschalten! ldi temp, 0b00000011 out LCD_PORT, temp rcall enable_routine rcall delay4ms ;Mindestens 4,1ms warten! ldi temp, 0b00000011 out LCD_PORT,temp rcall enable_routine rcall short_delay ;Mindestens 100us warten! rcall short_delay ldi temp, 0b00000011 out LCD_PORT, temp rcall enable_routine ldi temp, 0b00000010 ;Hier wird letztendlich 4-Bit Modus eingeschaltet out LCD_PORT, temp rcall enable_routine rcall short_delay ;Hier zur sicherheit 60us zum abarbeiten ;4 Bit Modus Mitteilung abgeschlossen ; ******************************************* ldi temp, 0b00001010 ;2 Zeilig 5x8 matrix rcall lcd_command rcall delay2ms rcall short_delay ;Kurze Wartezeit zum abarbeiten rcall display_off rcall clear_display ldi temp, 0b00000010 ; Kursor nach rechts wandernd, kein display shift rcall lcd_command rcall delay2ms ldi temp, 0b00001111 rcall lcd_command rcall delay2ms ldi temp, 'H' rcall lcd_print ;************** ; LCD INITIALISIERT, JETZT KANN INTERRUPT AKTIVIERT WERDEN! ldi temp, 0b01000000 ; INT0 aktivieren out GICR, temp sei ; Interrupts freigeben endloop: rjmp endloop ;********************************************************* ; L C D C O M M A N D S lcd_print: mov temp1, temp swap temp andi temp, 0b00001111 sbr temp, 1<