; (C) David Vajda ; 2024-11-30 ; LCD HD44780 - Atmega 8 .include "m8def.inc" ldi r16, HIGH (RAMEND) out SPH, r16 ldi r16, LOW (RAMEND) out SPL, r16 ldi r16, 0xff out DDRD, r16 rcall lcd_init ldi r16, ' ' rcall lcd_data ldi r16, 'w' rcall lcd_data ldi r16, 'w' rcall lcd_data ldi r16, 'w' rcall lcd_data ldi r16, '.' rcall lcd_data ldi r16, 'y' rcall lcd_data ldi r16, 'u' rcall lcd_data ldi r16, 'n' rcall lcd_data ldi r16, '7' rcall lcd_data ldi r16, 'x' rcall lcd_data ldi r16, '.' rcall lcd_data ldi r16, 'd' rcall lcd_data ldi r16, 'e' rcall lcd_data end: rjmp end sleep: push r16 ldi r16, 0xff sleep_loop1: dec r16 brne sleep_loop1 pop r16 ret lcd_enable: sbi PORTD, 5 nop nop nop cbi PORTD, 5 ret lcd_init: rcall sleep ldi r16, 0x03 out PORTD, r16 rcall sleep ldi r16, 0x03 out PORTD, r16 rcall sleep ldi r16, 0x03 out PORTD, r16 rcall sleep ldi r16, 0x02 rcall lcd_cmd ldi r16, 0x20 rcall lcd_cmd ldi r16, 0x01 rcall lcd_cmd ldi r16, 0x02 rcall lcd_cmd ret lcd_data: mov r17, r16 swap r16 andi r16, 0x0f andi r17, 0x0f ori r16, 0b00010000 ori r17, 0b00010000 out PORTD, r16 rcall lcd_enable out PORTD, r17 rcall lcd_enable rcall sleep ret lcd_cmd: mov r17, r16 swap r16 andi r16, 0x0f andi r17, 0x0f out PORTD, r16 rcall lcd_enable out PORTD, r17 rcall lcd_enable rcall sleep ret