no idea if this will help
;*** Driver program for MG1206E4-SGL 128x64 graphics display
;*** Target: AT90S2313 at 4Mhz speed
;*** Author: Serasidis Vasilis
;*** Date : 29-07-2001
;*** Email :
info@serasidis.gr
;*** web site:
https://www.serasidis.gr
;
;
;
;
;*** Connections
;*** LCD CONTROLS
;*** PortB D0----> Lcd D0
;*** PortB D1----> Lcd D1
;*** PortB D2----> Lcd D2
;*** PortB D3----> Lcd D3
;*** PortB D4----> Lcd D4
;*** PortB D5----> Lcd D5
;*** PortB D6----> Lcd D6
;*** PortB D7----> Lcd D7
;*** PortD D2----> Lcd CS1
;*** PortD D3----> Lcd CS2
;*** PortD D4----> Lcd D/I
;*** PortD D5----> Lcd WR
;*** PortD D6----> Lcd E
;*** Delay40us - Delay 40 us
;*** Delay100us - Delay 100 us
;*** Delay4ms - Delay 4ms
;*** NOTE : ALL DELAYS ARE CALCULATED FOR A 4MhZ CRYSTAL
.nolist
.include "2313def.inc" ;Set 2313's data for the compiler
.list
;***** Global register variables
.def Temp=r17
.def wreg =R16 ;General use working register
.def wreg2=R18
.def CommandReg=R23
.def DataReg=R24
.def Count=R19
;EEPROM related variables
.equ lcddi =PD4 ;LCD D/I pin connected to PD4
.equ lcdrw =PD5 ;LCD r/w pin connected to PD5
.equ lcde =PD6 ;LCD e pin connected to PD6
reset:
; Setup buffers and pointers
ldi temp,RAMEND
out SPL,temp;Init Stack Pointer
;*************************************************
ldi wreg,0x00 ;PortB Low
out PORTB,wreg
ldi wreg,0xFF ;Make port B pin all outputs
out DDRB,wreg
ldi wreg,0x00 ;PortD Low
out PORTD,wreg
ldi wreg,0xFF ;Make port D pin all outputs
out DDRD,wreg
rcall Lcd_Init ;Init the LCD
ldi temp,$7
;*************************************************************
;*************************************************************
rcall Delay4ms
clr count
ldi ZH,high(msg*2)
ldi ZL,low(msg*2) ;Init Z-pointer
clr wreg
rcall command
rcall cs1
rcall next
rcall cs2
rcall next
ldi wreg,$01
rcall command
rcall cs1
rcall next
rcall cs2
rcall next
ldi wreg,$02
rcall command
rcall cs1
rcall next
rcall cs2
rcall next
ldi wreg,$03
rcall command
rcall cs1
rcall next
rcall cs2
rcall next
ldi wreg,$04
rcall command
rcall cs1
rcall next
rcall cs2
rcall next
ldi wreg,$05
rcall command
rcall cs1
rcall next
rcall cs2
rcall next
ldi wreg,$06
rcall command
rcall cs1
rcall next
rcall cs2
rcall next
ldi wreg,$07
rcall command
rcall cs1
rcall next
rcall cs2
rcall next
telos:
rjmp telos
next:
lpm ;Get next character from ROM
mov temp,R0
cpi count,$40;See if at end of message
breq cont ;If so, do next message
rcall lcdwait ;Send it
rcall write_lcd
adiw ZL,1 ;Increment Z-pointer
inc count
rjmp next ;Loop for more
cont:
clr count
ret
;********************************************************************
cs1:
Sbi PortD,2 ;Enable the CS1 of the display
Cbi PortD,3 ;Disable the CS2 of the display
ret
cs2: Cbi PortD,2 ;Enable the CS2 of the display
Sbi PortD,3 ;Disable the CS1 of the display
ret
;*********************************************************************
;*********************************************************************
;***************************************************************
; Wait for LCD to go unbusy
lcdwait:
ldi wreg,0x00;Make portB all inputs
out DDRB,wreg
sbi PORTD,lcdrw;Set r/w pin to read
cbi PORTD,lcddi;Set register select to command
waitloop:
rcall E_strobe
in wreg2,PIND;Read busy flag
sbrc wreg2,7 ;Loop until done
rjmp waitloop
ldi wreg,0xff;Make portB all outputs
out DDRB,wreg
ret
;*********************************************************************
Lcd_Init:
Sbi PortD,2 ;Enable the CS1 of the display
Sbi PortD,3 ;Enable the CS2 of the display
cbi PortD,lcddi ;Clear D/I \_
cbi PortD,lcdrw ;Clear RW / Command mode
rcall Delay4ms
ldi Wreg,$c0 ;Display start line = 0 (0-63)
Out PortB,Wreg
Rcall E_strobe
rcall Delay4ms
ldi Wreg,$40 ;Set address = 0 (0-63)
out PortB,Wreg
rcall E_strobe
rcall Delay4ms
ldi Wreg,$b8 ;Set page = 0 (0-7)
Out PortB,Wreg
Rcall E_strobe
rcall Delay4ms
ldi Wreg,$3f ;Display ON
out PortB,Wreg
rcall E_strobe
Cbi PortD,2 ;Disable the CS1 of the display
Cbi PortD,3 ;Disable the CS2 of the display
ret
;***************************************************************
;*********************************************************************
E_strobe:
sbi PortD,lcde ;E high
cbi PortD,lcde ;E low
Ret
;***************************************************************************
Write_lcd:
Sbi PortD,lcddi
Cbi PortD,lcdrw
Out PortB,temp
rcall E_strobe
ret
;*********************************************************************
command:
Sbi PortD,2 ;Enable the CS1 of the display
Sbi PortD,3 ;Enable the CS2 of the display
cbi PortD,lcddi ;Clear D/I Command mode
ldi Wreg2,$b8 ;Set page (0-7)
add wreg,wreg2
Out PortB,Wreg
Rcall E_strobe
sbi PortD,lcddi ;Set D/I Data mode
Ret
;*********************************************************************
Delay40us:
ldi r21,$40
Loop3: dec r21
brne loop3
ret
;*********************************************************************
;****
;****
;*********************************************************************
Delay100us:
ldi r21,$88
Loop: dec r21
brne loop
ret
;*********************************************************************
;****
;****
;*********************************************************************
Delay4ms:
ldi r22,$1c
Loop1: ldi r21,$00
Loop2: dec r21
brne loop2
dec r22
brne loop1
ret
;*********************************************************************
;****
;****
;*********************************************************************
LongDelay:
ldi wreg,255 ; Delay for about 1 sec for the LCD to start
Longdelay_Loop:
rcall delay4ms
dec wreg
brne LongDelay_Loop
Ret
msg: .DB 0,0,0,160,88,5,86,145,74,49,142,81,173,86,171,191
.DB 238,95,255,191,253,255,187,255,255,255,223,255,190,255,127,255
.DB 254,255,247,255,223,255,254,191,253,255,251,255,223,255,255,251
.DB 223,255,255,247,255,127,239,255,254,127,247,255,127,239,255,254
.DB 111,255,254,255,183,255,255,253,223,255,123,255,254,239,253,255
.DB 251,223,254,191,251,255,255,219,255,255,219,255,247,126,239,253
.DB 247,255,221,247,254,223,245,255,223,251,222,247,127,219,254,239
.DB 187,255,90,255,93,247,127,219,126,111,251,94,127,245,95,123
.DB 0,224,220,98,189,74,245,26,237,178,93,166,219,108,215,58
.DB 214,107,189,102,187,221,43,246,31,235,23,237,31,167,91,39
.DB 142,51,79,19,77,163,23,75,165,19,75,149,35,75,21,75
.DB 165,19,75,37,83,143,35,215,43,199,59,71,191,7,91,175
.DB 23,175,93,175,31,182,95,191,93,63,223,127,125,191,119,254
.DB 255,123,255,239,255,254,187,255,255,239,254,191,255,127,251,255
.DB 254,251,221,255,254,246,254,222,252,245,252,172,249,236,120,212
.DB 248,164,241,76,162,88,132,104,21,160,86,8,228,18,76,0
.DB 52,223,106,255,168,215,125,214,171,124,215,253,42,223,50,223
.DB 33,222,35,156,67,44,145,6,81,4,146,0,74,32,5,208
.DB 2,73,160,21,194,40,69,48,74,32,213,104,82,60,141,36
.DB 153,4,82,129,42,133,36,146,73,36,130,17,74,0,145,4
.DB 64,18,0,74,32,138,96,202,112,149,232,82,221,240,154,245
.DB 104,23,232,87,41,151,73,23,107,183,203,47,87,47,95,77
.DB 63,143,127,31,254,47,127,191,253,127,255,247,255,239,255,255
.DB 254,247,255,253,191,247,254,190,233,252,98,217,196,18,0,160
.DB 16,75,167,253,175,250,255,170,253,87,255,160,127,137,246,25
.DB 230,25,228,18,169,84,34,136,101,16,74,160,82,9,164,74
.DB 176,15,240,205,178,120,137,118,10,149,66,181,104,181,216,164
.DB 126,194,62,131,45,6,169,4,1,148,2,40,5,64,20,34
.DB 8,81,4,81,4,91,5,82,137,110,145,111,151,106,151,105
.DB 86,105,52,82,185,26,140,46,3,137,34,8,130,41,0,85
.DB 0,21,64,21,64,21,130,41,4,83,138,37,95,171,255,190
.DB 239,253,127,255,239,255,255,125,255,239,255,125,251,238,188,251
.DB 255,255,251,191,255,247,127,255,247,255,255,254,247,253,238,251
.DB 220,247,216,230,185,196,89,166,81,140,99,24,198,57,68,176
.DB 74,181,69,179,84,146,85,128,85,40,66,9,34,137,37,0
.DB 75,0,37,2,149,0,86,129,106,128,106,165,82,168,131,104
.DB 181,196,50,76,176,77,176,74,176,72,160,74,16,37,0,170
.DB 1,16,69,0,16,4,64,8,0,34,128,8,0,34,0,9
.DB 32,2,64,8,129,16,66,32,201,212,96,250,237,122,255,239
.DB 125,255,223,247,125,255,215,127,255,219,255,119,255,191,253,7
.DB 127,247,223,239,191,239,255,127,255,238,255,127,253,255,239,255
.DB 191,255,253,191,251,255,255,111,254,239,238,155,252,119,221,250
.DB 221,123,234,253,86,249,214,248,166,249,68,249,196,178,200,165
.DB 80,170,196,17,234,140,119,154,253,87,188,235,95,109,183,151
.DB 107,148,37,146,201,100,171,116,27,79,165,5,144,69,16,72
.DB 2,104,1,80,132,17,64,132,17,64,4,144,65,4,144,65
.DB 168,192,101,208,242,212,243,185,238,243,223,245,119,223,235,255
.DB 175,251,239,191,237,255,175,251,191,237,191,235,255,39,137,0
.DB 255,219,254,247,255,90,255,247,127,237,255,223,255,245,255,191
.DB 235,255,127,239,251,127,239,255,127,247,255,239,255,255,223,254
.DB 255,127,255,253,255,255,251,254,255,247,255,239,254,255,255,246
.DB 255,239,254,255,190,255,250,255,254,187,254,253,251,255,245,254
.DB 251,237,255,245,252,119,248,247,248,247,232,254,176,255,240,237
.DB 250,217,250,253,184,253,244,190,250,253,118,254,254,119,255,253
.DB 239,255,223,251,127,238,255,219,255,190,251,255,255,237,255,126
.DB 223,251,126,223,125,247,95,246,95,235,190,235,117,15,0,128
.DB 255,186,239,190,251,175,253,183,221,191,212,127,181,218,191,213
.DB 110,187,159,235,157,183,173,157,247,155,182,219,175,182,219,183
.DB 95,239,183,222,191,239,189,223,187,255,175,255,191,237,191,251
.DB 191,239,191,255,183,255,127,247,191,255,191,255,253,191,251,255
.DB 255,247,255,255,239,255,255,254,255,247,255,239,255,255,255,189
.DB 255,123,255,191,255,191,187,255,111,255,191,247,63,255,123,175
.DB 254,191,235,63,239,191,237,63,247,95,246,191,213,127,171,191
.DB 247,29,247,189,215,189,215,189,151,253,150,251,0,0,0,32