This document is a result of the effort and contributions of a number of
people.


	Programming of the LCD controller chipset HD44352A01, HD44353


Interface
=========

The communication with the LCD controller occurs through a propertiary Casio
4-bit bus. The transfer is synchronised with a bi-phase clock. An additional
control signal OP (Operation) is used to distinguish between commands (OP=1)
and data (OP=0). Several devices connected to the same bus can be individually
selected with the CE (Chip Enable) signals.

In the PB-1000 and PB-2000C machines the HD44352A01 chip is selected by the
CE1 signal, while both HD44353 chips are selected by the CE2 signal.
In the FX-8000G all three chips are selected by the CE1 signal.

To ensure proper timing, the microprocessor HD61700 used in the PB-1000 and
PB-2000C must run in the fast mode while communicating with the LCD system.
The  microprocessor uPD1007 used in the FX-8000G must be switched to the slow
mode while communicating with the LCD system.

Each HD44353 chip drives a screen area of 96 pixels in width and 32 pixels
in height. In the PB-1000 and PB-2000C both areas are placed side by side,
while in the FX-8000G one above the other.

The FX-8000G has differently connected PN input (segment direction select) of
the HD44352 chip, which requires the data bytes written (but not the commands
and data read) to have reversed nibble order comparing with the PB-1000 and
PB-2000C.

The HD44356A01 chip found in some FX-8000G versions appears to be equivalent
to the HD44352A01, except that it is a mirror image thereof, or has the pins
bent in opposite direction.


Control Commands
================

Command 0:	?

----------------------------

Command 1:	Graphic Input

Chip Enable:	CE2=1, CE1=1

Parameter 1:	Bits 7..5:
		  111 - read the data RAM (nibbles swapped)
		Bit 4: 0= Left LCD, 1= Right LCD
Parameter 2:	Column: 0..95 (decimal)
		Bit 7: 0= 0..47, 1= 48..95
		Bits 6..1: offset 0..47 within the range specified by bit 7
		Bit 0: 0= even, 1= odd nibble in the data RAM
Parameter 3:	Row: 0..3

Data bytes:	Any number

Comment:	Input at current position if parameter 2 and 3 omitted.

----------------------------

Command 2:	Graphic Output

Chip Enable:	CE2=1, CE1=any

Parameter 1:	Bits 7..5: Nexus	(logical operation between the Old
					 and New pixel value)
		  000: not Old and New
		  001: Old xor New
		  010: 0		(clear)
		  011: Old and not New	(drawc)
		  100: New		(overwrite)
		  101: Old or New
		  110: 0		(clear)
		  111: Old		(do nothing)
		Bit 4: 0= Left LCD, 1= Right LCD
Parameter 2:	Column
Parameter 3:	Row

Data bytes:	Any number

Comment:	Output at current position if parameter 2 and 3 omitted.

----------------------------

Command 3:	Character Output

Chip Enable:	CE2=1, CE1=1

Parameter 1:	Bits 7..5: Nexus
		Bit 4: 0= Left LCD, 1= Right LCD
Parameter 2:	Column
Parameter 3:	Row

Data bytes:	Any number

Comment:	Output at current position if parameter 2 and 3 omitted.
		Short delay of at least 40 cycles between outputs of the data
		bytes required.

----------------------------

Command 4:	LCD Visibility

Chip Enable:	CE2=any, CE1=1

Parameter 1:	Bits 7..5: -
		Bit 4: 0=Off, 1=On

Data:		-

----------------------------

Command 5:	?

----------------------------

Command 6:	Cursor Definition by Graphic

Chip Enable:	CE2=1, CE1=any

Parameter 1:	Bits 7..5: -
		Bit 4: 0= Left LCD, 1= Right LCD
Parameter 2:	Column
Parameter 3:	purpose unknown, bogus value when used in the internal ROM

Data bytes:	8

----------------------------

Command 7:	Cursor Definition by Character

Chip Enable:	CE2=1, CE1=1

Parameter 1:	Bits 7..5: -
		Bit 4: 0= Left LCD, 1= Right LCD
Parameter 2:	Column
Parameter 3:	purpose unknown, bogus value when used in the internal ROM

Data bytes:	1 (swapped nibbles)

----------------------------

Command 8:	Scroll, Character Width

Chip Enable:	CE2=1, CE1=any

Parameter 1:	bits 7..6: position of the top row in the data RAM
		  00 = offset of 0 rows
		  01 = offset of +1 rows
		  10 = offset of +2 rows
		  11 = offset of +3 rows
		bits 5..4: character width in the text mode
		  00 = 8 pixel width
		  01 = 7 pixel width
		  10 = 6 pixel width
		  11 = 5 pixel width
              
Data bytes:	-

----------------------------

Command 9:	Cursor Visibility

Chip Enable:	CE2=1, CE1=any

Parameter 1:	Bit 7..5: Nexus
		Bit 4: 0= Off, 1= On

Data bytes:	-

Comment:	The width of the cursor is the same as the width of characters
		(specified by the Command 8).
		Used in the internal ROM with F as Parameter 1 (to hide the
		cursor?).

----------------------------

Command A:	Reset

Chip Enable:	CE2=1, CE1=1

Parameter 1:	?

Data bytes:	-

Comment:	This commands resets the row counters in all LCD driver chips
		in order to synchronize them.
		Used in the internal ROM with 0 as Parameter 1 at the
		beginning of the LCD initialisation sequence.

----------------------------

Command B:	User Character Definition

Chip Enable:	CE2=any, CE1=1

Parameter 1:	Bit 7..4: -
Parameter 2:	Bit 7..2: -
		Bit 1..0: code of the defined character
		  0 = character &HFC
		  1 = character &HFD
		  2 = character &HFE
		  3 = character &HFF

Data bytes:	8

----------------------------

Command C:	Contrast Control

Chip Enable:	CE2=any, CE1=1

Parameter 1:	Bit 4: resistor 140k
		Bit 5: resistor 130k
		Bit 6: resistor 120k
		Bit 7: resistor 110k
Parameter 2:	Bit 0: resistor 100k
		Bit 1: resistor 90k
		Bit 2: resistor 80k
		Bit 3: resistor 80k
		Bit 4: resistor 70k
		Bit 5: resistor 70k
		Bit 6: resistor 18k
		Bit 7: resistor 15k
Parameter 3:	Bit 0: resistor 13k
		Bit 1: resistor 10.5k
		Bit 2: resistor 8.1k
		Bit 3: resistor 5.5k
		Bit 4: resistor 4.2k
		Bit 5: resistor 2.9k
		Bit 6: resistor 1.5k
		Bit 7: resistor 70ohm

Data bytes:	-

Comment:	The contrast control potentiometer inside the HD44352 chip
		consists of a fixed 50k resistor between the pins VRT and GND,
		and a set of parallel connected resistors between the pins VRT
		and VEXT. Each of them can be individually enabled or disabled
		by the respective bits of the parameter bytes.
		Recommended parameter values found in the ROMs are listed in
		the table at the end of this document.

----------------------------

Command D:	Timer Frequency Control

Chip Enable:	CE2=any, CE1=1

Parameter 1:	Main Clock divided by (decimal)
		0= 16384  (PB-1000)
		1= 8
		2= 16
		3= 32
		4= 64
		5= 128
		6= 256
		7= 512
		8= 1024
		9= 2048   (FX-8000G)
		A= 4096   (PB-2000C)
		B= 4096
		C= 8192
		D= 8192
		E= 8192
		F= 8192

Data bytes:	-

Comment:	This command determines the frequency of the signal generated
		on the TM output (50% duty cycle).
		The specified division rate applies to the PB-1000/PB-2000C.
		For the FX-8000G it needs to be multiplied by 2, because the
		uPD1007 processor outputs two times lower LCD clock frequency
		than the HD61700.
		In the PB-1000/PB-2000C this signal is fed to the ON Interrupt
		input, while in the FX-8000G it is fed to the INT1 input.

----------------------------

Command E:	Set Cursor Position

Chip Enable:	CE2=1, CE1=any

Parameter 1:	Bits 7..5: -
		Bit 4: 0= Left LCD, 1= Right LCD
Parameter 2:	Column
Parameter 3:	Row

Data bytes:	-

Comment:	The column position should be of the same value as specified
		in the commands 6/7, otherwise the cursor image wraps around.

		For the FX-8000G an extra offset of character_width-1 needs
		to be added to the left/upper LCD column specification.

----------------------------

Command F:	?

----------------------------



HD61700 LCD programming examples
================================

Example 1: graphic output

	LD	$0,&H92		;graphic output, right side, overwrite
	LDW	$1,&H0228	;row=2, column=20
; graphic data
	LDW	$3,&H80FF
	LDW	$5,&HA1BF
	LDW	$7,&HBDA5
	LDW	$9,&HFF81
; transfer the command and 8 data bytes
	PPO	&HFF		;54 00 FF
	STLM	$0,3		;D2 00 40
	PPO	&HFE		;54 00 FE
	STLM	$3,8		;D2 03 E0
	RTN


Example 2: reading the font bitmaps from the LCD controller ROM

; display an example character 'A' in the text mode
	LD	$0,&H83		;character output, left side, overwrite
	LDW	$1,&H0000	;row=0, column=0
	LD	$3,&H14		;character code, reversed nibble order
	PPO	&HFF		;54 00 FF
	STLM	$0,3		;D2 00 40
	PPO	&HFE		;54 00 FE
	STL	$3		;12 03
	XRCM	$0,$0,8		;C7 40 E0, short delay
; read the character bitmap to the registers $4..$9
	LD	$0,&HE1		;graphic input, read left LCD data RAM
	PPO	&HFF		;54 00 FF
	STLM	$0,3		;D2 00 40
	PPO	&HFE		;54 00 FE
	LDLM	$4,6		;D3 04 A0
; the nibble order in each byte needs to be reversed
	LD	$10,6		;byte counter
L1:	LD	$0,$9
	DIU	$0
	DID	$9
	OR	$0,$9
	BYUM	$4,6		;DA 64 A0
	LD	$4,$0
	SB	$10,$30
	JR	NZ,L1		;next byte
	RTN


Example 3: user defined character

; optional character width specification
	PPO	&HFF		;54 00 FF
	STL	&H08		;52 08, character width=8,
				;top position of row=0 (default)
; define the character of code &HFD
	LDW	$0,&H010B	;character &HFD
	LDW	$2,&HFCFE
	LDW	$4,&HF0F8
	LDW	$6,&HC0E0
	LDW	$8,&H0080
	PPO	&HFF		;54 00 FF
	STLW	$0		;92 00
	PPO	&HFE		;54 00 FE
	STLM	$2,8		;D2 02 E0
; display the character of code &HFD
	LD	$0,&H83		;character output, left side, overwrite
	LDW	$1,&H018E	;row=1, column=55
	PPO	&HFF		;54 00 FF
	STLM	$0,3		;D2 00 40
	PPO	&HFE		;54 00 FE
	STL	&HDF		;52 DF, note the reversed nibble order
	RTN


Example 4: cursor programming

; character width specification
	PPO	&HFF		;54 00 FF
	STL	&H08		;52 08, character width=8,
				;top position of row=0 (default)
; define the left cursor by graphic
	LD	$0,&H86
	LDW	$1,&H0134	;row1, column 26
	LDW	$3,&H84FE
	LDW	$5,&H8488
	LDW	$7,&HD1A2
	LDW	$9,&H048A
	PPO	&HFF		;54 00 FF
	STLM	$0,3		;D2 00 40
	PPO	&HFE		;54 00 FE
	STLM	$3,8		;D2 03 E0
; set the position of the left cursor
	LD	$0,&H0E
	PPO	&HFF		;54 00 FF
	STLM	$0,3		;D2 00 40
; define the right cursor by text (character 'Yen' of code &H5C)
	LD	$0,&H97
	LDW	$1,&H024A	;row=2, column=37
	PPO	&HFF		;54 00 FF
	STLM	$0,3		;D2 00 40
	PPO	&HFE		;54 00 FE
	STL	&HC5		;52 C5, note the reversed nibble order
; set the position of the right cursor
	LD	$0,&H1E
	PPO	&HFF		;54 00 FF
	STLM	$0,3		;D2 00 40
; show the cursors
	PPO	&HFF		;54 00 FF
	STL	&H99		;52 99
	RTN


Example 5: Scroll function of the Command 8 (PB-1000)

10 FOR A=&H7000 TO &H7005
20 READ X: POKE A,X
30 NEXT A
35 CALL &H7000: REM top row at offset 0
40 CLS: PRINT "1","2","3","4";
50 K$=INKEY$: REM select the top row with the keys 0..3
60 IF K$<"0" THEN 50
70 IF K$>"3" THEN 50
80 LOCATE 16,1: PRINT " ";
90 POKE &H7004, 8+VAL(K$)*64: CALL &H7000: REM scroll the old contents
100 LOCATE 16,1: PRINT K$;: REM position of new output unaffected
110 GOTO 50
1000 DATA &H54,&H00,&HFF
1010 DATA &H52,&H08
1020 DATA &HF7


Example 6: setting the contrast, code copied from the internal PB-2000C ROM

	PPO	&HC3		;54 00 C3
	LD	$0,&H0C
	LDW	$1,&H3000
	STLM	$0,3		;D2 00 40
	RTN



uPD1007 LCD programming examples
================================

Example 1: graphic output

	LD	R0,&H92		;graphic output, lower part, overwrite
	LD	R1,&H28		;column=20
	LD	R2,&H02		;row=2
; graphic data
	LD	R8,&HFF
	LD	R9,&H08
	LD	R10,&HFB
	LD	R11,&H1A
	LD	R12,&H5A
	LD	R13,&HDB
	LD	R14,&H18
	LD	R15,&HFF
; transfer the command and 8 data bytes
	PST	IE,&HF0		;slow mode
	STLOM	R0..R2,&H21
	STLEM	R8..R15,&H01
	PST	IE,&H70		;fast mode
	RTN


; Example 2: reading the font bitmaps from the LCD controller ROM

; display an example character 'A' in the text mode
	LD	R0,&H83		;character output, upper part, overwrite
	LDM	R1..R2,&H00	;row=0, column=0
	LD	R3,&H41		;character code
	PST	IE,&HF0		;slow mode
	STLOM	R0..R2,&H21
	STLE	R3,&H01
	TXRM	R0..R7,R64..R71	;small delay
; read the character bitmap to the registers R8..R13
	LD	R0,&HE1		;graphic input, read upper LCD data RAM
	STLOM	R0..R2,&H21
	LDLEM	R8..R13,&H01
	PST	IE,&H70		;fast mode
; the nibble order in each byte needs to be reversed
	SWPM	R8..R13,R64..R69
	RTN


Example 3: user defined character

; define the character of code &HFD
	LD	R0,&H0B		;character definition
	LD	R1,&HFD		;character code=&HFD
	LD	R8,&HEF
	LD	R9,&HCF
	LD	R10,&H8F
	LD	R11,&H0F
	LD	R12,&H0E
	LD	R13,&H0C
	LD	R14,&H08
	LD	R15,&H00
	PST	IE,&HF0		;slow mode
	STLOM	R0..R1,&H21
	STLEM	R8..R15,&H01
; optional character width specification
	LD	R0,&H08		;character width=8,
				;top position of row=0 (default)
	STLE	R0,&H21
; display the character of code &HFD
	LD	R0,&H83		;character output, upper part, overwrite
	LD	R1,&H8E		;column=55
	LD	R2,&H01		;row=1
	LD	R3,&HFD		;character code
	STLOM	R0..R2,&H21
	STLE	R3,&H01
	PST	IE,&H70		;fast mode
	RTN


Example 4: cursor programming

	PST	IE,&HF0		;slow mode
; character width specification
	LD	R0,&H08		;character width=8,
				;top position of row=0 (default)
	STLE	R0,&H21
; define the upper cursor by graphic
	LD	R0,&H86
	LD	R1,&H42		;column=26 + extra=7 for the upper LCD
	LD	R2,&H01		;row=1
	LD	R8,&HEF
	LD	R9,&H48
	LD	R10,&H88
	LD	R11,&H48
	LD	R12,&H2A
	LD	R13,&H1D
	LD	R14,&HA8
	LD	R15,&H40
	STLOM	R0..R1,&H21
	STLEM	R8..R15,&H01
; set the position of the upper cursor
	LD	R0,&H0E
	STLOM	R0..R2,&H21
; define the lower cursor by text (character 'Yen' of code &H5C)
	LD	R0,&H97
	LD	R1,&H4A		;column=37
	LD	R2,&H02		;row=2
	LD	R3,&H5C
	STLOM	R0..R2,&H21
	STLE	R3,&H01
; set the position of the lower cursor
	LD	R0,&H1E
	STLOM	R0..R2,&H21
; show the cursors
	LD	R0,&H99
	STLE	R0,&H21
	PST	IE,&H70		;fast mode
	RTN


Example 5: setting the contrast

	LD	R0,&H0C
	LD	R1,&H00
	LD	R2,&H30
	PST	IE,&HF0		;slow mode
	STLEM	R0..R2,&H21
	PST	IE,&H70		;fast mode
	RTN



Appendix
========

Table of parameters 1 to 3 for the contrast control command C, extracted
from the ROMs

 AC 00 01	;13k || 110k || 130k		= 10.7k (lowest contrast)
 8C 04 01	;13k || 110k || 80k		= 10.1k
 0C 18 01	;13k || 70k || 80k		= 9.6k
 0C 04 02	;10.5k || 80k			= 9.3k
 6C 00 02	;10.5k || 120k || 130k		= 9.0k
 2C 20 02	;10.5k || 70k || 130k		= 8.5k
 1C C0 00	;15k || 18k || 140k		= 7.7k
 0C C8 00	;15k || 18k || 80k		= 7.4k
 1C E0 00	;15k || 18k || 70k || 140k	= 7.0k
 1C 80 01	;13k || 15k || 140k		= 6.6k
 1C 40 02	;10.5k || 18k || 140k		= 6.3k
 0C 60 02	;10.5k || 18k || 70k		= 6.1k
 0C 64 02	;10.5k || 18k || 70k || 80k	= 5.6k
 3C 00 03	;10.5k || 13k || 130k || 140k	= 5.3k
 8C 00 08	;5.5k || 110k			= 5.2k
 BC 00 08	;5.5k || 110k || 130k || 140k	= 4.9k
 8C 00 06	;8.1k || 10.5k || 110k		= 4.4k
 1C 40 08	;5.5k || 18k || 140k		= 3.8k
 0C A0 08	;5.5k || 15k || 70k		= 3.8k
 FC 00 09	;5.5k || 13k || 110k || 120k || 130k || 140k	= 3.4k
 0C 80 10	;4.2k || 15k			= 3.3k
 0C 00 12	;4.2k || 10.5k			= 3.0k
 0C 00 14	;4.2k || 8.1k			= 2.8k
 0C 20 0E	;5.5k || 8.1k || 10.5k || 70k	= 2.4k
 0C 00 22	;2.9k || 10.5k			= 2.3k
 0C 00 1A	;4.2k || 5.5k || 10.5k		= 1.9k
 0C 00 30	;2.9k || 4.2k			= 1.7k
 0C 00 34	;2.9k || 4.2k || 8.1k		= 1.4k
 0C 00 3C	;2.9k || 4.2k || 5.5k || 8.1k	= 1.1k
 0C C0 3F	;2.9k || 4.2k || 5.5k || 8.1k || 10.5k || 13k	= 0.9k
 0C 00 78	;1.5k || 2.9k || 4.2k || 5.5k	= 0.7k
 0C FF 7F	;1.5k || 2.9k || 4.2k || 5.5k || 8.1k || 10.5k || 13k ||
		 15k || 18k || 70k || 70k || 80k || 80k || 90k || 100k
		 = 0.5k (highest contrast)

The symbol || means parallel connection.