.... .equ data = 6 .equ clk = 0 .equ reset = 5 rtc_start: nop ; 1us pause nop nop nop sbi portd, reset ; Reset Line high nop ;1 us Pause nop nop nop ret rtc_stop: sbi portd, clk nop nop nop nop cbi portd, reset nop nop nop nop ret rtc_read_bit: cbi portd, clk nop sbis pind, data cbr temp1,1<<7 sbic pind, data sbr temp1,1<<7 sbi portd, clk ret rtc_write: cbi portd, clk nop sbi portd, Data sbrs command, 0 cbi portd, data nop sbi portd, clk nop ret rtc_write_byte_init: ldi temp, 8 sbi ddrd, data rtc_write_byte: rcall rtc_write lsr command dec temp brne rtc_write_byte ret rtc_read_byte_init: ldi temp,8 ldi temp1, $00 cbi portd, data cbi ddrd, data rtc_read_byte: rcall rtc_read_bit lsr temp1 dec temp brne rtc_read_byte ret rtc_main1: cbi portd, reset cbi portd, clk rcall rtc_start ldi command, 0x8E ;Write Protect Bit in Register- rcall rtc_write_byte_init ;Control löschen ldi command, 0x00 rcall rtc_write_byte_init rcall rtc_stop rcall rtc_start ldi command, 0xBE ;Schreib-Burst-Modus aktivieren rcall rtc_write_byte_init ldi command, 0x00 ;Sekunden = 00 rcall rtc_write_byte_init rcall rtc_write_byte_init ;Minuten = 00 ldi command, 0x05 rcall rtc_write_byte_init ;Stunden = z.B 5 rcall rtc_stop ret rtc_main2: cbi portd, reset cbi portd, clk rcall rtc_start ldi command, 0xBF ;Lese-Burst-Modus aktivieren rcall rtc_write_byte_init rcall rtc_read_byte_init ;Sekunden einlesen mov rtc_sek, temp1 rcall rtc_read_byte_init ;Minuten einlesen mov rtc_min, temp1 rcall rtc_read_byte_init ;Stunden einlesen mov rtc_std, temp1 rcall rtc_stop ret rtc_auswertung: ldi zeit, $0f mov temp2, rtc_sek and rtc_sek,zeit sbr rtc_sek,3<<4 mov sek_e, rtc_sek swap temp2 sbr temp,3<<4 mov sek_z, temp2 mov temp2, rtc_min and rtc_min, zeit sbr rtc_min, 3<<4 mov min_e, rtc_min swap temp2 sbr temp2,3<<4 mov min_z, temp2 mov temp2, rtc_std and rtc_std, zeit sbr rtc_std, 3<<4 mov std_e, rtc_std swap temp2 sbr temp2, 3<<4 mov std_z, temp2 ret ..... rcall rtc_main1 ;initialisieren loop: rcall rtc_main2 rcall rtc_auswertung rcall lcd_write rjmp loop