Att jag aldrig lär mig, jag ska aldrig ge mig in på något alls. Det leder bara till kodproblem.
Displayen är en Seiko G1213B1N med HD61202/203. Kompatibel med KS0108.
Pinnarna är både dubbel och trippelkollade.
Jag har dock inte blivit riktigt klok på om man ska initiera den med RST låg eller hög, men har provat båda.
.include "m8535def.inc"
.include "bild.bas"
.equ lcdport=porta
.equ ctlport=portd
.equ CS1=0
.equ CS2=1
.equ rst=2
.equ RW=3
.equ DI=4
.equ E=5
.def temp=r16
.def temp2=r17
.def delay=r18
.cseg
.org 0x0000
rjmp reset
reset:
ldi temp, HIGH(RAMEND)
out SPH, temp
ldi temp, LOW(RAMEND)
out SPL, temp
ser temp
out ddra, temp
ldi temp, 0b00111111
out ddrd, temp
rcall lcd_init
rjmp main
main:
ldi temp2, 63
sbis pind,7
rcall writeloop
rjmp main
writeloop:
ldi ZH, HIGH(bild*2)
ldi ZL, LOW(bild*2)
writeloop2:
rcall lcd_writebyte
dec temp2
brne writeloop2
rjmp main
lcd_writebyte:
ld temp, z+
rcall lcddelay
out lcdport, temp
sbi ctlport, DI
cbi ctlport, RW
cbi ctlport, CS1
rcall lcd_pulsee
ret
lcd_pulsee:
rcall lcddelay
sbi ctlport, E
rcall lcddelay
rcall lcddelay
cbi ctlport, E
ret
lcd_init:
sbi ctlport, RST
rcall lcddelay
rcall lcddelay
rcall lcddelay
cbi ctlport, DI
cbi ctlport, RW
ldi temp, 63 ;(Disp on)
out lcdport, temp
cbi ctlport, cs1
cbi ctlport, cs2
rcall lcd_pulsee
ldi temp, 0b10111000
out lcdport, temp
rcall lcd_pulsee
ret
lcddelay:
ldi delay, 255
lcddelay2:
dec delay
brne lcddelay2
ret