; 2024-11-25 ; LCD ; (C) David Vajda .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, 0b00000001 rcall lcd_cmd ldi r16, 0b00000010 rcall lcd_cmd ldi r16, 'h' rcall lcd_data ldi r16, 't' rcall lcd_data ldi r16, 't' rcall lcd_data ldi r16, 'p' rcall lcd_data ldi r16, 's' rcall lcd_data ldi r16, ':' rcall lcd_data ldi r16, '/' rcall lcd_data 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, 'i' rcall lcd_data ldi r16, 't' rcall lcd_data ldi r16, 'u' rcall lcd_data ldi r16, 'e' rcall lcd_data ldi r16, 'n' rcall lcd_data ldi r16, 'i' 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 enable: sbi PORTD, 5 nop nop nop cbi PORTD, 5 ret lcd_init: rcall sleep ldi r16, 0x03 rcall lcd_cmd8 ldi r16, 0x03 rcall lcd_cmd8 ldi r16, 0x03 rcall lcd_cmd8 ldi r16, 0x02 rcall lcd_cmd ldi r16, 0x20 rcall lcd_cmd ret lcd_cmd8: out PORTD, r16 rcall enable rcall sleep ret lcd_cmd: mov r17, r16 swap r16 andi r16, 0x0f andi r17, 0x0f out PORTD, r16 rcall enable out PORTD, r17 rcall enable rcall sleep ret lcd_data: mov r17, r16 swap r16 andi r16, 0x0f andi r17, 0x0f ori r16, 0b00010000 ori r17, 0b00010000 out PORTD, r16 rcall enable out PORTD, r17 rcall enable rcall sleep ret |