I have a hantronix HDM128GS12-1 display. It is a 128x128 graphic LCD that has a T6963 controller. I've been trying for about a week to try to get it functioning.
http://www.hantronix.com/2_1.html
All that I get is a quick flash (that looks like there are some characters and vertical bars) then it goes black.
I'm using an AT89S52 microcontroller, and I'm pretty sure it's wired correctly(i've checked several times, i get the negative voltage for the display and all other pins seem to be fine.)
Here is my code, it's a little messy but it should work.
The important functions are LCD_Cwrite, LCD_Dwrite, and Check_Status which are toward the bottom
Also all the P2 clears, are to make sure the code isn't hanging somewhere.
This does not seem to be the case since in the end all P2 bits are where they should be.
Code:
; Micro controller speed - 24MHz or 41.666ns
; 500ns per cycle
;
; Display Size 128x128
; WR, RD Pulse Width: 80ns min
;
; Pin Controls
; /RD Low + C/D High = Status Read
; /WR Low + C/D High = Command Write
; /WR Low + C/D Low = Data Write
;
; Status Explanation
; bit 0 - Command Execution Capability
; bit 1 - Data Read/Write Capability
; bit 2 - Auto Mode Data Read
; bit 3 - Auto Mode Data Write
; bit 4 - Not Used
; bit 5 - Controller Operation Capability
; bit 6 - Error Flag: Used in Screen Peek and Screen Copy
; bit 7 - Check Blink Condition
; For 0-5 1 is enabled, 0 is disabled
; For 6 1 is error, 0 is no error
; For 7 0 is display off, 1 is normal display
;
; CE tie low
; FS tie low
$MOD52
;---------------------------Pin DECLARATIONS--------------------------------
LRD bit P1.2 ;
LWR bit P1.3 ;
CD bit P1.4 ;
RST bit P1.5 ;Inverted : 0 for On, 1 to Reset LCD
CE bit P1.6 ;
LCD_Voltage bit P3.1 ;Inverted 0 for -17v, 1 to 0v to LCD
Data_Bus equ P1
;---------------------------------------------------------------------------
;---------------------------Constant DECLARATIONS---------------------------
Graphic_Low equ 00
Graphic_High equ 00
Graphic_Column equ 10h
Text_Low equ 00
Text_High equ 08
Text_Column equ 10h
;----------------------------------------------------------------------------
ORG 0000H
LJMP LCD_Setup
ORG 100h
LCD_Setup:
MOV P1,#0
MOV P3,#0
CLR P2.0
SETB RST
SETB LCD_Voltage
;Wait 75ms
MOV B, #150
LCALL DELAY
CLR RST
NOP
NOP
NOP
NOP
SETB LWR
SETB LRD
CLR CE
;Wait 75ms
MOV B, #150
LCALL DELAY
;Text Home
MOV R4,#Text_Low
LCALL LCD_DWrite
MOV R4,Text_High
LCALL LCD_DWrite
MOV R4,#040h
LCALL LCD_CWrite
;Graphics Home
MOV R4,#Graphic_Low
LCALL LCD_DWrite
MOV R4,#Graphic_High
LCALL LCD_DWrite
MOV R4,#042h
LCALL LCD_CWrite
;Text Area
MOV R4,#Text_Column
LCALL LCD_DWrite
MOV R4,#0
LCALL LCD_DWrite
MOV R4,#041h
LCALL LCD_CWrite
;Graphics Area
MOV R4,#Graphic_Column
LCALL LCD_DWrite
MOV R4,#0
LCALL LCD_DWrite
MOV R4,#043h
LCALL LCD_CWrite
;Set Mode
MOV R4,#81h
LCALL LCD_CWrite ;XOR, Internal CG
CLR P2.1
LCALL Clear_Graphics
LCALL Clear_Text
;Allow Vlcd
CLR LCD_Voltage
CLR P2.2
;DISPLAY MODE
MOV R4,#9Ch
LCALL LCD_CWrite
;Set Cursor Pattern
MOV R4,#0
LCALL LCD_DWrite
MOV R4,#0
LCALL LCD_DWrite
MOV R4,#0A2h
LCALL LCD_CWrite
;Set Cursor Location
MOV R4,#1
LCALL LCD_DWrite
MOV R4,#1
LCALL LCD_DWrite
MOV R4,#21h
LCALL LCD_CWrite
;Set Address Pointer
MOV R4,#1
LCALL LCD_DWrite
MOV R4,#8
LCALL LCD_DWrite
MOV R4,#24h
LCALL LCD_CWrite
CLR P2.3
;Output
MOV R4,#25h
LCALL LCD_DWRITE
MOV R4,#0C0h
LCALL LCD_CWrite
MOV R4,#41h
LCALL LCD_DWRITE
MOV R4,#0C0h
LCALL LCD_CWrite
MOV R4,#54h
LCALL LCD_DWRITE
MOV R4,#0C0h
LCALL LCD_CWrite
MOV R4,#0
LCALL LCD_DWRITE
MOV R4,#0C0h
LCALL LCD_CWrite
MOV R4,#33h
LCALL LCD_DWRITE
MOV R4,#0C0h
LCALL LCD_CWrite
MOV R4,#48h
LCALL LCD_DWRITE
MOV R4,#0C0h
LCALL LCD_CWrite
MOV R4,#49h
LCALL LCD_DWRITE
MOV R4,#0C0h
LCALL LCD_CWrite
MOV R4,#54h
LCALL LCD_DWRITE
MOV R4,#0C0h
LCALL LCD_CWrite
END_LOOP:
SETB P2.4
MOV R4,#09Ch
LCALL LCD_CWrite ;DISP ON
LCALL LDELAY
LCALL LDELAY
LCALL LDELAY
LCALL LDELAY
CLR P2.4
MOV R4,#090h
LCALL LCD_CWrite ;DISP OFF
LCALL LDELAY
LCALL LDELAY
LCALL LDELAY
LCALL LDELAY
JMP END_LOOP
;------------------------------------------------------------------
;*************************************************************************
Clear_Graphics:
MOV R4,#Graphic_Low ;Set Address Pointer
LCALL LCD_DWrite
MOV R4,#Graphic_High
LCALL LCD_DWrite
MOV R4,#24h
LCALL LCD_CWrite
mov R7,#128
JMP Clear_Loop
Clear_Text:
MOV R4,#Text_Low ;Set Address Pointer
LCALL LCD_DWrite
MOV R4,#Text_High
LCALL LCD_DWrite
MOV R4,#24h
LCALL LCD_CWrite
mov R7,#16
; JMP Clear_Loop
Clear_Loop:
;Start Auto Write
MOV R4,#0B0h
LCALL LCD_CWrite
Clear1:
mov R6,#20
Clear2:
MOV R4,#000h
LCALL LCD_ADWrite
djnz R6,Clear2
djnz R7,Clear1
;End Auto Write
MOV R4,#0B2h
LCALL LCD_ACWrite
RET
;-------------------Common LCD Writing Functions-------------------
LCD_ACWrite:
LCALL AutoW_Check
SETB CD
SJMP LCD_Write
LCD_ADWrite:
LCALL AutoW_Check
CLR CD
SJMP LCD_Write
LCD_CWrite:
LCALL Check_Status
SETB CD
SJMP LCD_Write
LCD_DWrite:
LCALL Check_Status
CLR CD
; SJMP LCD_Write
LCD_Write:
SETB LRD
MOV Data_Bus, R4
NOP
CLR CE
CLR LWR
SETB LWR
SETB CE
RET
;*************************************************************************
Check_Status: ;Returns once status is okay
SETB LWR
SETB CD
SETB LRD
CS_1:
MOV Data_Bus, #0ffh
NOP
CLR CE
CLR LRD
NOP
NOP ;CHECK TIMING
MOV A,Data_Bus
SETB LRD
SETB CE
MOV R3,#03
ANL A,R3
CJNE A,#03h,CS_1 ;Switch if function shouldn't loop until status is ready
RET
AutoW_Check:
SETB LWR
SETB CD
SETB LRD
ACS_1:
MOV Data_Bus, #0ffh
NOP
CLR CE
CLR LRD
NOP
NOP ;CHECK TIMING
MOV A,Data_Bus
SETB LRD
SETB CE
MOV R3,#08
ANL A,R3
CJNE A,#08h,ACS_1 ;Switch if function shouldn't loop until status is ready
RET
;*************************************************************************
LCD_DBWrite: ;writes a section of data starting at dptr to #01AH
CLR A
MOVC A,@A+dptr
CJNE A,#01AH,LCD_DBWrite1 ; #01AH can be changed to any value
RET
LCD_DBWrite1:
MOV R4,A
LCALL LCD_DWrite
INC dptr
MOV B,#2d
LCALL DELAY ; 1ms delay
SJMP LCD_DBWrite
;*************************************************************************
; Value in B determines delay length, which is ~ B/2 milliseconds
;Time for Delay is .5ms * B
DELAY: ;STORE OUTER LOOP
DELAY2: MOV A,#0F8H ;SETUP FOR INNER LOOP
NOP
NOP
NOP
NOP
DELAY1: DEC A ;1 cycle, delay1 is 2us per loop
NOP ;1 cycle
JNZ DELAY1 ;2 cycles
DEC B ;1 cycle
MOV A,B ;1 cycle
JNZ DELAY2 ;2 cycles OUTER LOOP UNTIL ZERO
RET ;2 cycles
;*************************************************************************
LDELAY:
MOV B,#250
LCALL DELAY
MOV B,#250
LCALL DELAY
MOV B,#250
LCALL DELAY
MOV B,#250
LCALL DELAY
MOV B,#250
LCALL DELAY
MOV B,#250
LCALL DELAY
MOV B,#250
LCALL DELAY
MOV B,#250
LCALL DELAY
RET
Message1:
db 'Test'
db 01Ah
END_JMP:
END