84PCSE:LCD Controller
Contents
- 1 Quick Specs
- 2 Overview
- 3 Register List
- 3.1 00: Driver Code
- 3.2 01: Driver Output Control 1
- 3.3 02: LCD Driving Control
- 3.4 03: Entry Mode
- 3.5 05: 16-bit Data Format Selection
- 3.6 07: Display Control 1
- 3.7 08: Display Control 2
- 3.8 09: Display Control 3
- 3.9 0A: Display Control 4
- 3.10 0C: RGB Display Interface Control 1
- 3.11 0D: Frame Maker Position
- 3.12 0F: RGB Display Interface Control 2
- 3.13
- 3.14
Quick Specs
- ILI9335
- TFT color LCD
- Supports 8 and 16-bit interfaces
- 172,800 bytes internal RAM
- 76,800 pixels
- Power-saving 8-color mode
- 262,144 = 2^18 = 6x6x6 colors
- Data sheet: http://www.displayfuture.com/Display/datasheet/controller/ILI9335.pdf
Overview
Like the old LCD controller, the new color controller is controlled by ports 10h and 11h. The LCD controller wants 16- or 18-bit data, but the Z80 only does 8-bit I/O, so each read or write takes TWO operations. The controller expects them to be in big-endian order, i.e. to output 1234h, you write 12h first, then write 34h to the SAME port. Writes to port 10h set the current "register". You need to send 16-bits to 10h at a time, even though there are no registers above 0FFh; every time you set the current register, send a dummy zero first. Reading 10h probably returns some kind of status information (more information needed). Reading and writing to 11h reads or writes to or from a register.
Therefore, to send the LCD a command, you first send two bytes to port 10h to set the current register. Then, you send two bytes to write the data. Similarly, to read, write the register number to 10h, and then read twice from 11h. You should be able to read-modify-write without resending the register number.
To send graphics to the LCD, set the column and row address registers, and then send the data serially to register #22h. You do not need to write 00 22h to port 10h after every byte.
NOTA BENE: IMPORTANT TERMINOLOGY:
In this document, the word "cursor" refers to the LCD controller's current reading or writing location on the screen; that is, the current row and column set by registers 20h and 21h.
(For those following along with the data sheet: Like before, the X/Y plane is flipped in the data sheet documentation. Specifically, the the screen is rotated 90 degrees from the way the manufacturer expects, so "horizontal" and "vertical" refer to the OTHER, i.e. horizontal means up and down on the screen. Also, "up" and "down" are switched with "left" and "right". Also, the auto-increment behavior in hardware is rotated 90 degrees clockwise from the register 0x03 diagram. It also suggests that the manufacturer expects the screen to be in landscape mode, which is wrong.)
To resolve potential CONFUSION about the meaning of the words "horizontal", "vertical", "up", "down", "left", "right", "X", and "Y", (see above paragraph) this document will use the terms "row" and "Y" to refer to the up/down direction positioning of the cursor on the actual calculator; similarly, "column" and "X" refer to the left/right axis. Additionally, as is standard for computer screens, the X=0 position is at the left side, and X+ is pointing to the right; and moreover, Y=0 is at the top, and Y+ points DOWN.
READ THE ABOVE OR YOU WILL HAVE BUGS!
Like the old B&W LCD controller, this one has an internal cursor (the data sheet calls it the GRAM address) that determines where data written or read goes. Unlike the old controller, setting the row register will cause the column pointer to reset to the last value written, and vice versa. For example, if you set the row to 1, the column to 2, write a pixel so the column is now 3, and then set the row to 5, the column will not remain at 3, but revert to 2. (If you then set the column to 10, the row remains at 5, because 5 is the last value you wrote.)
So, port 10h:
- Writing sets the index for the IR register
- Reading reads an internal status code
- Write four zeros to sync for multibyte transfers
Port 11h:
- Writing sets a control register value or writes to GRAM (auto-buffered to WRD)
- Reading reads from GRAM through the buffered RDR register (so a dummy
read (16-bits!) is required before the data are valid, just like before)
TI always uses the 16-bit color mode, and they always set BGR color order, for no good reason.
If you read the data sheet, the interface mode is the I80 8-bit mode.
Register List
This is a list of all the LCD's registers, what each bit does (if anything), and the values the OS expects for normal operation, so you can hopefully return the screen to normal after you're done screwing things up.
You should probably not screw with the power and scanning control registers. The screen might catch on fire, or cause the screen to fade over time, or just stop working. Remember, some of said registers directly control the internal voltages used in the controller.
00: Driver Code
Reads 9335h
01: Driver Output Control 1
Default: 0000h
Bit | Default | Description |
8 | 0 | Set to reverse row scan direction (i.e. upside-down mode) |
10 | 0 | Set for interlaced output |
02: LCD Driving Control
Default:
Bit | Default | Description |
8 | 0 | EOR: Set with B/C = 1 to set line inversion |
9 | 1 | B/C: 0 = Frame/Field inversion, 1 = lin inversion |
Comments: This seems to have no effect?
03: Entry Mode
Default:
Bit | Default | Description |
3 | 1 | AM: Cursor direction. Set = L/R, reset = U/D. After every pixel, the cursor moves either U/D or L/R.
If set to L/R (1), after every pixel the cursor moves left (bit 5=0) or right (b5=1). At the end of the row, the cursor moves up (b4=0) or down (b4=1). If AM is set to U/D, after every pixel, the cursor moves up (b4=0) or down (b4=1). At the end of each column, the cursor moves left (b5=0) or right (b5=1). At the end of every row or column, the cursor resets to the start of the next line, where ever the current window setting puts it. |
4 | 1 | Vertical increment/decrement: Set = increment |
5 | 1 | Horizontal increment/decrement: Set = increment |
7 | 0 | ORG: The controller's wording suggests that if this is set, then the cursor seeks to the corner of the window when the window is set, but this appears to be wrong? |
12 | 1 | BGR: If set, this specifies BGR color channel order. TI uses this. |
14 | 0 | TRI: If set, 3 writes are required for every pixel. |
15 | 0 | DFM: If reset, the 3 writes are packed.
If set, the 3 writes are unpacked. (That is, write 1 byte red, 1 byte green, and finally 1 byte blue, or reverse for BGR.) |
The display has three color modes:
TRI | DFM | Transfer Mode |
0 | any | 16-bit color, packed values, MSB first (big endian) |
1 | 0 | 18-bit color, packed values, R[5:4] low bits of first transfer |
1 | 1 | 18-bit color, unpacked values, uses high 6 bits, low two bits
ignored |
05: 16-bit Data Format Selection
TI does not appear ever to set a value for this register?
Bit | Default | Description |
1:0 | 1 | EPF: If set to 0, the low bit of red and blue is always zero.
If set to 1, the low bit of red and blue is always one. If set to 2, the low bit of red and blue is copied from the high bit. If set to 3, the low bit of red and blue is copied from the low bit of green. |
07: Display Control 1
Default: 0133h
Bit | Default | Description |
0 | 1 | D0: Turn off scanning?? |
1 | 1 | D1: Turn off LCD?? |
3 | 0 | CL: Set for 8-colors mode |
4 | 1 | DTE: Set for normal operation |
5 | 1 | GON: Set for normal operation |
8 | 1 | BASEE: Set to keep LCD controller active even in standby/sleep |
12 | 0 | PTDE0: Set to enable partial image 1 |
13 | 0 | PTDE1: Set to enable partial image 2 |
08: Display Control 2
Default: 0202h
You probably shouldn't muck with this field.
Bit | Default | Description |
3:0 | 2 | BP: Number of lines to skip after after VSYNC |
11:8 | 2 | FP: Number of lines to skip after finishing LCD scan |
Neither may be set to 0, 1, or more than 128, and must total less than or equal to 256.
09: Display Control 3
Default: 0000h
You probably shouldn't muck with this field.
Bit | Default | Description |
3:0 | 0 | ISC: Scan cycle period = ISC*2-1 frames |
4 | 0 | PTG0: Do not set this bit |
5 | 0 | PTG1: Set for interval scan |
10:8 | 0 | PTS: Output voltage when scanning in non-display area |
0A: Display Control 4
Default: 0000h
Probably useless to us
Bit | Default | Description |
2:0 | 0 | FMARK interval, valid values are 0, 1, 3, 5 |
3 | 0 | MKARKOE: Enables FMARK |
0C: RGB Display Interface Control 1
Default: 0000h
Probably useless to us
Bit | Default | Description |
1:0 | 0 | RIM |
5:4 | 0 | DM |
8 | 0 | RM |
14:12 | 0 | ENC |
0D: Frame Maker Position
Default: 0000h
Probably useless to us
Bit | Default | Description |
8:0 | 0 | FMP: Sets when the FMARK pulse is output |
0F: RGB Display Interface Control 2
Default: 0000h
Probably useless to us, TI doesn't initalize it
Bit | Default | Description |
0 | DPL | |
1 | EPL | |
3 | HSPL | |
4 | VSPL |
Default:
Bit | Default | Description |
Default:
Bit | Default | Description |