From: kon@cs.titech.ac.jp (Narihito Kon)
Subject: Sharp PC-E500's LCDC
Organization: Tokyo Institute of Tech., Dept. of Computer Science, Japan
Distribution: comp
Date: Fri, 2 Oct 1992 05:11:01 GMT


PC-E500 has two LCDC ( LCD Controller ) and these mappings are what
you see next.

	Y adrs
	 0	63 0	55 55	0 63	0
(0,0)--> --------------------------------
	 | Page0  | Page0 | Page4| Page4|
	 --------------------------------
	 | Page1  | Page1 | Page5| Page5|
	 --------------------------------
	 | Page2  | Page2 | Page6| Page6|
	 --------------------------------
	 | Page3  | Page3 | Page7| Page7|
	 -------------------------------- <-- (239,31)
	 ##########***************#######

LCDC#2 owns "######" area, and LCDC#1 owns "*****" area. For
example, The dots of ( 64 , 8 ) to ( 64 , 15 ) locates at "Page=1, Y
adrs=0, LCDC#1" and ( 239 , 24 ) to ( 239 , 31 ) locates at "Page=7,
Y adrs=0, LCDC#2".

As you know from GPRINT and other, a byte data was projected to
vertical 8dots on the display. Upside is LSB and Down is MSB.

Registers of LCDC is mapped from $2000 to $200B. Below is details of
address assignments.

	Instruction	LCDC#1	LCDC#2	Both at a time
	----------------------------------------------
	Display ON/OFF	$2008	$2004	$2000
	Display start-	$2008	$2004	$2000
	 ing line
	Set page	$2008	$2004	$2000
	Set Y adrs	$2008	$2004	$2000
	Read status	$2009	$2005	-----
	Write display	$200A	$2006	$2002
	 data
	Read display	$200B	$2007	-----
	 data

And below is function of each instruction and bit assignments.

	Code(binary)	(hex)	Function
	MSB	LSB
	0011   111x	3E+x	Turn on/off all display.
				x=0: turn off
				x=1: turn on
	11xx   xxxx	E0+x	Set "display starting line" to x
	1011   1xxx	B8+x	Set page to x
	01xx   xxxx	40+x	Set Y adrs to x
	
And below is about bit assignment of obtained status

	bit7(MSB):	If "1" , it means LCDC's busy. Any instruction
			and data is ignored while "1".
	bit6     :	Always "0"
	bit5     :	If "1" , display is turned on
	bit4     :	If "1" , reset(???)
	bit3-0	 :	Always "0"

And Data read/write location is specifyed by "Page" and "Y adrs" as
explained above, already. After you read/write a data, Y adrs is
incremented automatically. But you need to do "dummy read" one time
just after setting Page or Y adrs.  Otherwise you'll get meaningless
data if you read. Y adrs is not incremented on doing "dummy read".

The "display starting line" decides which logical line comes to the
top of the real display. For example, if you set display starting
line to "2", it means logical line#2 comes to the top of the
display. As a result, you feel display was scrolled up just 2dots. 
In fact scrolling up/down the text is achieved by changing the
display starting line. Each of display starting line (of LCDC#1 and
LCDC#2) can be set individually.

Saying more about display starting line, above graphic mapping of
LCDC is valid when you set each of display starting line to "0". I
think you've already know that setting other value to display
starting line means scrolling the real display hardwarely.

And at the last, LCDC's busy time is very short and you need to pay
little atention about this. But if you want to do your work more
precisely, you should check the busy bit just before
reading/writing.

I'll show some examples at next time if you want.

--
--
Narihito Kon
Dept. of Computer Science, Tokyo Institute of Tech., Japan
E-Mail : kon@cs.titech.ac.jp
HAM    : JK1OSG @ JR1YTD
Newsgroups: comp.sys.handhelds