#include "dt_inc.s" .text .org 0x0 start: br+ main br+ main ret main: call+ u_init call+ u_recv_byte call u_send_newline ldis r1, 0x41 ; 'A' call u_send_byte call lcd_init ldis r1, 0x42 ; 'B' call u_send_byte call lcd_clear ldis r1, 0x43 ; 'C' call u_send_byte call lcd_home ldis r1, 0x44 ; 'D' call u_send_byte call delay5ms ; print 'E' on LCD and UART ldis r1, 0x45 ; 'E' push r1 call lcd_data pop r1 call+ u_send_byte call+ u_send_newline loop: call+ u_recv_byte ; print received Char on LCD addi r1, r0, 0 call+ lcd_data br loop hang: br+ hang .define LCD_BASE, 0x2050 ; http://www.mikrocontroller.net/articles/AVR-Tutorial:_LCD#Routinen_zur_LCD-Ansteuerung lcd_data: lrs r2, r1, 4 andx r2, 0xf orx r2, 0x10 stw r2, 0(r12) call+ lcd_enable andx r1, 0xf orx r1, 0x10 stw r1, 0(r12) call+ lcd_enable call+ delay50us ret lcd_command: lrs r2, r1, 4 andx r2, 0xf stw r2, 0(r12) call+ lcd_enable andx r1, 0xf stw r1, 0(r12) call+ lcd_enable call+ delay50us ret lcd_enable: addinv r0, r0, 0 addinv r0, r0, 0 addinv r0, r0, 0 ldw r0, 0(r12) orx r0, 0x20 stw r0, 0(r12) addinv r0, r0, 0 addinv r0, r0, 0 addinv r0, r0, 0 addinv r0, r0, 0 addinv r0, r0, 0 ldw r0, 0(r12) ldis r5, 0xffdf and r0, r0, r5 stw r0, 0(r12) ret delay50us: ; @ 50 MHz ldis r0, 2500/2 ;ldis r0, 4000/2 delay50us_: subi r0, r0, 1 brnz+ delay50us_ ; not zero ret delay5ms: ; @ 50 MHz ldis r0, 5 ;ldis r0, 7 delay5ms_1: ldis r1, 50000/2 delay5ms_2: subi r1, r1, 1 brnz+ delay5ms_2 ; not zero subi r0, r0, 1 brnz+ delay5ms_1 ; not zero ret lcd_init: ldis r12, LCD_BASE@lo ldih r12, LCD_BASE@hi ldis r3, 50 powerupwait: call+ delay5ms subi r3, r3, 1 brnz+ powerupwait ldis r3, 0x3 stw r3, 0(r12) call+ lcd_enable call+ delay5ms call+ lcd_enable call+ delay5ms call+ lcd_enable call+ delay5ms ldis r3, 0x2 stw r3, 0(r12) call+ lcd_enable call+ delay5ms ldis r1, 0x24 call+ lcd_command ldis r1, 0xc call+ lcd_command ldis r1, 0x4 call+ lcd_command ret lcd_clear: ldis r1, 0x1 call lcd_command call delay5ms ret lcd_home: ldis r1, 0x2 call lcd_command call delay5ms ret