$NOMOD51 $INCLUDE (AT898252.INC) org 0x0200 ;************* HAUPTPROGRAMM ********************* DB0 EQU P2.0 DB1 EQU P2.1 DB2 EQU P2.2 DB3 EQU P2.3 DB4 EQU P2.4 DB5 EQU P2.5 DB6 EQU P2.6 DB7 EQU P2.7 RW EQU P1.1 EN EQU P1.2 RS EQU P1.0 DAT EQU P2 lcall lcdinit ;aufruf des up zur initialisierung des lcd lcall clear_lcd lcall zeilentest ;aufruf des up mit test für cursorsteuerung ; ******************** ; *** lcd routines *** ; ******************** LCDINIT: mov r4,#02h repeat: CLR RS MOV DAT,#38h SETB EN CLR EN LCALL WAITLCD CLR RS MOV DAT,#0Eh SETB EN CLR EN LCALL WAITLCD CLR RS MOV DAT,#06h SETB EN CLR EN LCALL WAITLCD djnz r4,repeat ret CLEAR_LCD: clr en CLR RS ;declares following bytes as command MOV p2,#01h ;01h is clear-command. pinned to p2 (aka dat) SETB EN ;falling edge of en starts executon CLR EN LCALL WAITlcd RET setb en ;should work without this setb en, too ret output: setb rs mov dat,a setb en clr en lcall waitlcd ret waitlcd: clr en clr rs setb rw mov dat,#0ffh setb en mov a,dat jb acc.7,waitlcd ;checks busy flag clr en clr rw ret zeilentest: ;cursor auf 1te zeile 1tes zeichen clr rs mov dat,#80h setb en clr en lcall waitlcd ;cursorpos ende mov a,#'X' lcall output ;cursor auf 1te zeile 6tes zeichen clr rs mov dat,#85h setb en clr en lcall waitlcd ;cursorpos ende mov a,#'X' lcall output ;cursor auf 2te zeile 9tes zeichen clr rs mov dat,#0C8h setb en clr en lcall waitlcd ;cursorpos ende mov a,#'X' lcall output ;cursor auf 2te zeile letztes zeichen clr rs mov dat,#0CFh setb en clr en lcall waitlcd ;cursorpos ende mov a,#'X' lcall output endless: ljmp endless ; **************** ; ** shortdelay ** ; **************** shortdelay: mov r6,#200d ;outer loopct waste2: mov r5,#250d ;inner loopct ccl2: nop nop nop ; 3c nop +2c djnz (inner) djnz r5,ccl2 ; = 5 cycles wasted djnz r6,waste2 ret ; *** approx delaytime=200x250x5=312k usec ; *** end of shortdelayroutine end