20x2 driving Allelectronics HG25504 LCD

ptribbey

New Member
This is working code to make a 20X2 control the SED1330 lcd controller on a Hyundai HG25504 256 X128 graphics LCD Panel. The LCD is available at www.allelectronics.com #LCD-101. This is a rough draft that works.
Thanks for checking it out.
Paul Tribbey

Code:
'Picaxe 20X2 hooked to Hyundai HG25504 256 X 128 LCD Display available from allelectronics
'For this program, hookup B.0 - B.7 to DB0 - DB7. pins 10 to 17 on the display.
'C.0 to /Res pin 5, C.1 to /RD pin 6(always high), C.2 to /WR pin 7, C.3 to /CS pin 8, C.4 to A0 pin 9.
'Of course this display needs +5 pin 3, and GND pins 1-2. Also between -9 and -11 volts referenced from +5, to Vo (pin 4 on the display)
'I used a CMOS 555 timer for setting up the minus voltage. Schematics can be found at site below. If you can't see the word PICAXE on the lcd, try adjusting the -10 Volt contrast.
'Much useful info can be found here: http://home.myfairpoint.net/~snowleop/gdisp3/index.htm Thanks to Snow Leopard.
'I wrote this program in sequence to be easy to follow, I realize it could be done allot differently (faster and smaller)

setfreq m64
low a.0    'for debugging - hookup LED to A.0 - will flash when programming then off while initializing.
dirsc = $1f	'lower 5 bits of port c are outputs.
call res	'reset
call init	'initialize
high a.0	'LED is on when initialized (takes 26 seconds with this program at 8mhz. about 3 seconds at 64 mhz)

main:		'here is where chars are put on the screen. Commands such as "CSRW" below can be found in section 3.0 of the SED1330 datasheet
w1= $46	'CSRW - Set cursor address
call writec
w1= $00
call writed
w1= $00
call writed
w1= $42	'MWRITE - Write to display memory.
call writec
w1= $50	'P
call writed
w1= $49	'I
call writed
w1= $43	'C
call writed
w1= $41	'A
call writed
w1= $58	'X
call writed
w1= $45	'E
call writed

el:
goto el	'endless loop - get rid of this and do other stuff here.

writec:	'write command to display

pinsb= w1	'load data
pinsc= $13	'setup cmd write (A0 high hooked to c.4)
dirsb= $ff	'present data on bus
pinsc= $1f	'toggle /WR bit c.2 and /CS c.3
dirsb= $00	'release the databus by changing to inputs
return

writed:	'write data to display

pinsb = w1	'load data
pinsc= $03	'setup data write (A0 low hooked to c.4)
dirsb = $ff	'present data on bus
pinsc= $0f	'toggle /WR bit c.2 and /CS c.3
dirsb= $00	'release the databus by changing to inputs
return

res:		'reset display.

low c.0	'/RES - pin 5 on display low to reset.
pause 10
high c.0	'/RES high and keep it there.
return

init:		'The following commands and their descriptions can be found in the SED1330 datasheet section 3.0 on the 'net addy listed up top.

w1= $58	'DISP ON/OFF - Disable display (during init).
call writec
w1= $40	'SYSTEM SET - Initialize display using 8 bytes of data Parameters. the first 3 are bitwise, other 5 are whole bytes.
call writec
w1= $30	'P1 See section 3.2.1 of SED1330 datasheet. (DR T/L IV 1 W/S M2 M1 M0 = %00110000, or $30)	
call writed
w1= $87	'P2 See section 3.2.1.9 (WF 0 0 0 0 FX FX FX = %10000111, or $87)
call writed
w1= $07	'P3 See section 3.2.1.11 (0 0 0 0 FY FY FY FY = %00000111, or $07)
call writed
w1= $1f	'P4 See section 3.2.1.12 (CR = %00011111, or $1f)
call writed
w1= $23	'P5 See section 3.2.1.13 (TC/R = %10000111, or $87)
call writed
w1= $7f	'P6 See section 3.2.1.14 (L/F = %01111111, or $7f)
call writed
w1= $20	'P7 See section 3.2.1.15 (APL = %00100000, or $20)
call writed
w1= $00	'P8 See section 3.2.1.16 (APH = %00000000, or $00)
call writed
w1= $44	'SCROLL - Scroll command, Set start address of page 1 cgram $00,$00. See 3.3.2
call writec
w1= $00	'most significant address byte.
call writed
w1= $00	'least significant address byte.
call writed
w1= $7f	'128 line display region page 1(starts at zero hence $7f for 128).
call writed
w1= $00	'most significant address byte layer 2, graphics.
call writed
w1= $10	'least significant address byte layer 2.
call writed
w1= $7f	'128 line display region layer 2.
call writed	'(I'm not using layer 3, if you are, insert data below this line)
w1= $5a	'HDOT SCR - Set horizontal scroll position.
call writec
w1= $00	'
call writed
w1= $5b	'OVLAY - Set display overlay.
call writec
w1= $00
call writed
w1= $4c	'CSRDIR - Set direction of cursor movement.
call writec
w1= $46	'CSRW - Set cursor address (to clear display).
call writec
w1= $00
call writed
w1= $00
call writed
w1= $42	'MWRITE - Write to display memory.
call writec
w1= $20	'Space character
for w0= 1 to 512 'Fill character memory with space character.
call writed
next w0
w1= $00
for w0= 1 to 7680 'Fill cgram and graphics memory area with zeros.
call writed
next w0
w1= $5d	'CSRFORM - Set cursor type.
call writec
w1= $04
call writed
w1= $86
call writed
w1= $59	'DISP ON/OFF - Enable display.
call writec
w1= $14
call writed
w1= $5c	'CGRAM ADR - Set start adderss of cgram.
call writec
w1= $00	'MSB
call writed
w1= $04	'LSB
call writed
return
 
Last edited:

westaust55

Moderator
Great effort there and thanks for posting so that others may benefit from your development work.

A couple of points:

1. You are using a word variable "w1" to hold that command and data values. You could change that to a byte variable (eg b1 or b5, etc) and save on variables.

2. Using the LOOKUP command to send fixed data can save program space.
For example, replacing
Code:
w1= $50	'P
call writed
w1= $49	'I
call writed
w1= $43	'C
call writed
w1= $41	'A
call writed
w1= $58	'X
call writed
w1= $45	'E
call writed
with this
Code:
FOR b27 = 0 to 5
  LOOKUP b27, ("PICAXE"), w1
  CALL writed
NEXT b27
albeit a small sample saves 32 bytes of program space for a 6 character data string



3. Finally if you can post a schematic diagram for your project others who wish to use the same LCD display will find it easier, particularly with respect to use of the 555 to generate the negative voltage.
 

tom91

New Member
Thanks for the code - I'm it to drive a 128x128 display - problem is that it splits the screen into an upper and lower half, but seems to think the two screens are side by side rather than top and bottom. If I display text, the first 16 characters are in the top half, then 16 in the bottom, then 16 in the top.

Any idea what parameter to change?

Thanks.
 
Top