84PCE:Ports:D000
From WikiTI
Synopsis
Port Number: D000
Memory-mapped Address: F80000
Function: LCD Interface
This appears to be an SPI controller that interfaces with the LCD. Non-extended commands from [1] appear to work, but there's plenty of unknown commands used by the boot code.
Port | Default | Bits | Information |
D000 F80000 |
0000F38C | Boot code writes 180B/09 before/after turning on/off the lcd. Bits 0-2 could be transfer size. | |
D004 F80004 |
0000182B | 007FFFFF | Boot code initializes to 02000B. |
D008 F80008 |
0002000B | 00000F8F | Boot code initializes to 010C. Bit 0 is set to transfer data. Bit 7 is set/reset for reading/writing. |
D00C F8000C |
000007F2 | Status bits. Bit 2 appears to be set if data is sending, and bits 12-15 the number of values queued. Boot code waits for bits 2 and 12-15 to be 0 before/after reading/writing. | |
D010 F80010 |
00002100 | Unknown | |
D014 F80014 |
00000008 | Unknown | |
D018 F80018 |
FIFO in/out. | ||
D01C F8001C |
0E0F0F1F | Constant, could be an ID or status. | |
D060 F80060 |
00012100 | Constant, could be an ID or status. | |
D064 F80064 |
0E0F0F1F | Constant, could be an ID or status. |
Known Commands
Hex Defaults |
Command | Details |
01 | Software Reset | |
10 10 |
Enable Sleep Mode | Turns pixels black, low power mode? |
11 11 |
Disable Sleep Mode | |
12 | Enable Partial Mode | Resets vertical scrolling start to 0. |
13 | Disable Partial Mode | Also disables vertical scrolling mode and resets vertical scrolling start to 0. |
20 | Uninvert Colors | |
21 | Invert Colors | |
26 <8:GC> 26 00 26 02 |
Set Gamma | Selects between 4 preset gamma curves: Valid values are 1, 2, 4, 8, invalid values appear to use 1. |
28 | Turn Off Display | Turns all pixels white. |
29 29 |
Turn On Display | Restore GRAM pixels. |
2A <BE16:StartCol> <BE16:EndCol> 2A 0000 013F |
Set Window Columns | Set the pixel update window from StartCol to EndCol inclusive. |
2B <BE16:StartLine> <BE16:EndRow> 2B 0000 00EF |
Set Window Rows | Set the pixel update window from StartRow to EndRow inclusive. |
30 <BE16:StartRow> <BE16:EndRow> | Set Partial Area Rows | Only displays from StartRow to EndRow inclusive, other lines white. |
33 <BE16:TopArea> <BE16:ScrollArea> <BE16:BottomArea> | Vertical Scrolling Definition | TopArea/BottomArea are static (non-scrolling) line counts before and after the ScrollArea whose value is ignored. |
36 <8:MAC> 36 08 |
Memory Address Control | Bit 2: Horizontal Refresh Order Bit 3: BGR Order Bit 4: Vertical Refresh Order Bit 5: Column Major Update Bit 6: Column Update Order Bit 7: Row Update Order |
37 <BE16:VSP> | Vertical Scrolling Start Position | First line of ScrollArea starts at this GRAM line. |
38 | Disable Idle Mode | Restore 18bpp mode. |
39 | Enable Idle Mode | 3bpp 8 color mode (only uses msb of each color component). |
3A ? 3A 66 |
Interface Pixel Format | Upper and lower nibbles are modes for the two interfaces: 3 is 12bpp, 5 is 16bpp, 6 is 18bpp (msb is ignored, invalid uses 18bpp). |
B0 ? ? B0 11 F0 |
Interface Control | First Param: Bit 0: Use lcd controller clocks instead of internal clocks. Bit 4: Get GRAM data from lcd controller instead of spi interface. Bit 7: Bypass GRAM and output directly to lcd. Second Param: Polarity of clocks? |
B1 ? ? ? B1 01 05 14 B1 01 15 14 |
Unknown? | |
B2 ? ? ? ? ? B2 0C 0C 00 33 33 |
Unknown? | |
B7 ? B7 35 |
Unknown? | |
BB ? BB 17 BB 1B |
Unknown? | |
C0 ? C0 2C C0 22 |
Unknown? | |
C2 ? C2 01 |
Unknown? | |
C3 ? C3 03 C3 15 |
Unknown? | |
C4 ? C4 20 |
Unknown? | |
C6 ? C6 0F |
Unknown? | |
D0 ? ? D0 AF A1 |
Unknown? | |
D2 ? D2 00 |
Unknown? | |
DC | Unknown? | One parameter "read" and checked if equal to 0x35, but reading doesn't appear to work in the first place... |
E0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? E0 D0 00 00 10 0F 1A 2D 54 3F 3B 18 17 13 17 E0 D0 00 00 10 0F 1A 2D 54 3F 3B 18 17 13 17 |
Positive Gamma Correction | Definitely affects gamma, parameters unknown and don't match docs. |
E1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? E1 D0 00 00 10 0F 09 2B 43 40 3B 18 17 13 17 E1 D0 00 00 10 0F 09 2B 43 40 3B 18 17 13 17 |
Negative Gamma Correction | Definitely affects gamma, parameters unknown and don't match docs. |
E9 ? ? ? E9 08 08 08 |
Unknown? | |
EB | Something! | |
F0 | Gamma? | |
F1 | Gamma? | |
F2 | Gamma? |
Example
Sending
ld a,036h ; Flips the lcd horizontally, vertically, and swaps the b and r components call spiCmd ld a,0C0h call spiParam ld a,002h ; Resetting the lcd on exit call spiCmd jp boot_InitializeHardware ; Input: A = parameter spiParam: scf ; First bit is set for data .db 030h ; jr nc,? ; skips over one byte ; Input: A = command spiCmd: or a,a ; First bit is clear for commands ld hl,0F80818h call spiWrite ld l,h ld (hl),001h spiWait: ld l,00Dh spiWait1: ld a,(hl) and a,0F0h jr nz,spiWait1 dec l spiWait2: bit 2,(hl) jr nz,spiWait2 ld l,h ld (hl),a ret spiWrite: ld b,3 spiWriteLoop: rla rla rla ld (hl),a ; send 3 bits djnz spiWriteLoop ret
Receiving
This does not appear to work, always returning 0 on the calcs I've tested, due to either a TI bug or hardware issue.
; Input: A = command ; Ouput: A = data spiRead: ld hl,0F80808 ld (hl),00Ch ld l,018h or a,a call spiWrite xor a,a ; not sure what this is for call spiWrite ld l,009h ld (hl),001h dec l ld (hl),081h call spiWait ld l,$18 ld a,(hl) ; dummy read ld a,(hl) ld a,(hl) ; Why is there no wait after dummy read? ld a,(hl) rla rla rla rla rla and a,0E0h ld c,a ld a,(hl) rla rla and a,01Ch or a,c ld c,a ld a,(hl) rra ; why are we throwing away the lsb instead of the msb and a,003h or a,c ret