;REM; Target specific init routines necessary before ;REM; not shown other subroutines as delays, TWI etc. .... lcdinit: ;LCD-Port: D0-D3=n.c.; D4-D7=data; ; ; ; P7 | P6 | P5 | P4 | P3 | P2 | P1 | P0 ; ; D7 | D6 | D5 | D4 | LED| ENA| R|W| RS ; ;======================================= rcall wait1 ; wait for LCD power on self reset rcall twistart ldi temp, 0x7E ; slave start adresse + RW-Bit rcall twiout ; PCF8574->0x40..4E; PCF8574A->0x70..7E rcall lcd_eight_bit ; LCD-Init: eight bit rcall lcd_eight_four ; LCD-Init: eight to four bit change rcall lcd_four_two_r ; LCD-Init: four bit, 2 rows rcall lcd_on_off ; LCD-Init: display buffer off rcall lcd_clear ; LCD-Init: clear display rcall lcd_entrymode ; LCD-Init: Entry Mode Set ret ; lcd_eight_bit: ; necessary first LCD software init ldi temp, 0b00001000 ; LED-backlight on rcall twiout ldi temp, 0b00110000 ; 0x30 rcall twiout rcall enable rcall wait1 ldi temp, 0b00110000 ; 0x30 rcall twiout rcall enable rcall wait1 ldi temp, 0b00110000 ; 0x30 rcall twiout rcall enable rcall wait1 ret ; lcd_eight_four: ; eight to four bit change push temp ldi temp, 0b00001000 ; LED-backlight on rcall twiout ldi temp, 0b00100000 ; first, four bit mode, only rcall twiout rcall enable rcall wait2 ; still lcd remains on 8 bit frame pop temp ; when accepting command lines ret ; lcd_four_two_r: ; four bit modus; two rows push temp ldi temp, 0b00101000 rcall cmd2lcd ; from now on lcd accepts rcall wait2 ; commands in a four bit frame, only pop temp ret ; lcd_on_off: ; On Off Control, swith display on/off: push temp ldi temp, 0b00001000 ; switch off display rcall cmd2lcd ; no cursor, no blinking rcall wait1 pop temp ret ; lcd_clear: ; clear entire display buffer: push temp ldi temp, 0b00000001 rcall cmd2lcd rcall wait1 pop temp ret ; lcd_entrymode: ; Entry/Shift Mode Set: push temp ldi temp, 0b00000110 ; cursor move direction from left to right rcall cmd2lcd ; no display shifting rcall wait2 ldi temp, 0b00010000 ; no display shifting, cursor move rcall cmd2lcd ; from left to right rcall wait2 ldi temp, 0b00001100 ; display on again rcall cmd2lcd ; no cursor, blinking off rcall wait2 ldi temp, 0b00000001 ; clearing display once more rcall cmd2lcd rcall wait2 pop temp ret ; char2lcd: ; charakter output on LCD via TWI: push temp ; saves "temps" on stack push temp1 mov temp1, temp ; content's copy for further actions below; andi temp, 0b11110000 ; blanking out D0-D3 data nibble ori temp, 0b00000001 ; RS=H masking rcall twiout ; output MSB D4-D7 on B4-B7 rcall enable ; output first enable impuls swap temp1 ; swapping nibbles andi temp1, 0b11110000 ; blanking out LSB port nibble ori temp1, 0b00001001 ; RS=H; LED-backlight on mov temp, temp1 ; copy temp1 to temp output register used rcall twiout ; output LSB D0-D3 on Port B4-B7 rcall enable ; output second enable impuls rcall wait2 ; wait for LCD processing pop temp1 ; reestablishing temps ... pop temp ; ...previous saved on stack ret ; cmd2lcd: ; transmitting instructions towards LCD via TWI push temp ; saves "temps" on stack push temp1 mov temp1, temp ; content's copy for further actions below andi temp, 0b11110000 ; RS=L; blanking out D0-D3 data nibble rcall twiout ; output MSB D4-D7 on B4-B7 rcall enable ; output first enable impuls swap temp1 ; swapping nibbles, uses copy of temp to temp1 andi temp1, 0b11110000 ; blanking out LSB port nibble mov temp, temp1 ; copy temp1 to temp output register used rcall twiout ; output LSB D0-D3 on Port B4-B7 rcall enable ; output second enable impuls rcall wait2 ; wait for LCD processing pop temp1 ; reestablishing temps ... pop temp ; ...previous saved on stack ret ; enable: nop ori temp, 0b00000100 ; H-masking enable bit rcall twiout ; output via subroutine "twiout" nop nop nop nop nop nop nop nop andi temp, 0b11111011 ; L-masking enable bit rcall twiout ; output via subroutine "twiout" nop ret ; ;*** fin ***