Problem Initing Newhaven NHD-1.8-128160EF (ILI9163C)
MacTuxLin
Posts: 821
There must be something wrong with my init code. The screen just reflects garbage right after Init. Can anyone see where I've gone wrong?
Thanks a lot
Thanks a lot
CON
'--- --- --- --- --- ---
'Declaring the CPU Freq & Crystal Clock
'--- --- --- --- --- ---
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
_ConClkFreq = ((_clkmode - xtal1) >> 6) * _xinfreq
_Ms_001 = _ConClkFreq / 1_000
'--- ***
' Debugging LED
'--- ***
_DebugLED = 22
'--- --- --- --- --- ---
' Newhaven
'--- --- --- --- --- ---
v_CS = 0
v_RST = 1
v_DC = 2
v_WR = 3 'Active Low
v_RD = 4 'Active Low
v_DB0 = 8
v_DB7 = 15
v_delay1 = 5 'Init
v_delay2 = 1 'Cmd & Data Write Function
v_delay3 = 50 'Used in Init
OBJ
DBG : "FullDuplexSerialExt.spin"
PUB Main | i
'--- Init ---
HardwareInit
DBG.Start(31, 30, 0, 115_200)
Pause(1500)
DBG.Tx(0)
DBG.Str(String(13, "Newhaven TFT LCD Driver - Testing"))
DBG.Str(String(13, "================================="))
DBG.Tx(13)
DBG.Tx(13)
'--- LCD Init
DBG.Str(String("Doing LCD Init...",13))
'---( CS/RD )--
OUTA[v_CS]~
OUTA[v_RD]~~
Init
DBG.Str(String("LCD Init Done...",13,13))
Pause(3000)
'--- Test Write Something
DBG.Str(String("Doing Fill Color...",13))
Fill_Color($FF0000)
DBG.Str(String("Fill Color Done...",13,13))
Pause(3000)
repeat 'Endlessly
!OUTA[_DebugLED]
Pause(200)
PRI HardwareInit
{{
}}
'--- LED
DIRA[_DebugLED]~~
OUTA[_DebugLED]~
'-- LCD
DIRA[v_CS]~~
DIRA[v_RST]~~
DIRA[v_DC]~~
DIRA[v_WR]~~
DIRA[v_RD]~~
DIRA[v_DB0..v_DB7]~~
return
PRI Fill_Bars | i, x, red, green, blue
{{
}}
red := green := blue := 0
Set_Col_Add($00, $00, $00, $7F)
Set_Page_Add($00, $00, $00, $9F)
Write_Memory_Start
repeat x from 0 to 159
repeat i from 0 to 41
red += $05
Send_Data(red)
Pause(v_delay2)
Send_Data(green)
Pause(v_delay2)
Send_Data(blue)
Pause(v_delay2)
red := 0
repeat i from 0 to 41
green += $05
Send_Data(red)
Pause(v_delay2)
Send_Data(green)
Pause(v_delay2)
Send_Data(blue)
Pause(v_delay2)
green := 0
repeat i from 0 to 41
blue += $05
Send_Data(red)
Pause(v_delay2)
Send_Data(green)
Pause(v_delay2)
Send_Data(blue)
Pause(v_delay2)
blue := 0
return
PRI Fill_Color(color) | i
{{
}}
Set_Col_Add($00, $00, $00, $7F)
Set_Page_Add($00, $00, $00, $9F)
Write_Memory_Start
repeat i from 0 to 20479
Send_Data(color>>16)
Send_Data(color>>8)
Send_Data(color)
return
PRI Set_Display_On
{{
}}
Send_Cmd($29)
return
PRI Set_Display_Off
{{
}}
Send_Cmd($28)
return
PRI Set_Pixel_Format(a)
{{
}}
Send_Cmd($3A)
Send_Data(a)
return
PRI Write_Memory_Start
{{
}}
Send_Cmd($2C)
return
PRI Memory_Access_Control(a)
{{
}}
Send_Cmd($36)
Send_Data(a)
return
PRI Set_Page_Add(a, b, c, d)
{{
}}
Send_Cmd($2B)
Send_Data(a)
Send_Data(b)
Send_Data(c)
Send_Data(d)
return
PRI Set_Col_Add(a, b, c, d)
{{
}}
Send_Cmd($2A)
Send_Data(a)
Send_Data(b)
Send_Data(c)
Send_Data(d)
return
PRI Set_Gamma_Curve(a)
{{
}}
Send_Cmd($26)
Send_Data(a)
return
PRI Set_F2(a)
{{
}}
Send_Cmd($F2)
Send_Data(a)
return
PRI Frame_Rate_Control(a, b)
{{
}}
Send_Cmd($B1)
Send_Data(a)
Send_Data(b)
return
PRI Power_Control_1(a, b)
{{
}}
Send_Cmd($C0)
Send_Data(a)
Send_Data(b)
return
PRI Power_Control_2(a)
{{
}}
Send_Cmd($C1)
Send_Data(a)
return
PRI VCOM_Control_1(a, b)
{{
}}
Send_Cmd($C5)
Send_Data(a)
Send_Data(b)
return
PRI VCOM_Offset_Control(a)
{{
}}
Send_Cmd($C7)
Send_Data(a)
return
PRI Software_Reset
{{
}}
Send_Cmd($01)
return
PRI Reduced_Colour_Dept
{{
}}
Send_Cmd($39)
return
PRI Set_Normal
{{
}}
Send_Cmd($13)
return
PRI Init
{{
}}
OUTA[v_RST]~~
Pause(50)
OUTA[v_RST]~
Pause(50)
OUTA[v_RST]~~
Pause(50)
'--- Exit Sleep
Send_Cmd($11)
Pause(150)
Set_Display_Off
Pause(v_delay3)
Set_Gamma_Curve($04)
Pause(v_delay3)
Set_F2($00)
Pause(v_delay3)
Frame_Rate_Control($0A, $14)
Pause(v_delay3)
Power_Control_1($0A, $00)
Pause(v_delay3)
Power_Control_2($02)
Pause(v_delay3)
VCOM_Control_1($2F, $3E)
Pause(v_delay3)
VCOM_Offset_Control($40)
Pause(v_delay3)
Set_Col_Add($00, $00, $00, $7F)
Pause(v_delay3)
Set_Page_Add($00, $00, $00, $9F)
Pause(v_delay3)
Memory_Access_Control($C8)
Pause(v_delay3)
Set_Pixel_Format($06)
Pause(v_delay3)
Set_Display_On
Pause(v_delay3)
Write_Memory_Start
Pause(500) '<-- Testing
return
PRI Send_Cmd(Cmd)
{{
}}
OUTA[v_WR]~
OUTA[v_DB7..v_DB0] := Cmd
Pause(v_delay2)
OUTA[v_WR]~~
return
PRI Send_Data(Data)
{{
}}
OUTA[v_WR]~
OUTA[v_DB7..v_DB0] := Data
OUTA[v_WR]~~
return
PRI BlinkLED | i
{{
}}
repeat i from 0 to 1
!OUTA[_DebugLED]
Pause(100)
return
PRI Pause(ms) | t
{{Delay program ms milliseconds}}
t := cnt - 1088 ' sync with system counter
repeat (ms #> 0) ' delay must be > 0
waitcnt(t += _MS_001)


Comments
Maybe something wrong with pixel setting functions that come next...
My NewHaven 1.8" display is a NHD-1.8-128160TF ....
Thanks Ray. I'll look into it.
The screen was in solid white upon powering up. It became garbage right after the Display_On was executed. It becomes solid white again when I issue a Software_Reset
Guess you're right Steve. Think I'll just go for a display with SSD1306 controller instead...
For whatever it may be worth, I've been sitting on a design for a while that uses this LCD: NHD-24-240320-CTXI-T1 Sitting means I haven't had much time to bother with it. Need a better bezel solution. Any ideas?
For the bezel, pocket an area for the LCD to drop down in slightly. This is the NHD capacitive touch screen turned vertical.
So perhaps, the garbage on the screen is actually the display functioning and showing the contents of GRAM.
So, I'd guess you're 90% of the way there.
Usually, you just need to send a write to gram command and start writing data to the screen...
Thanks a lot. Its working now! Thanks Ray, you're still the guru on LCD+prop & yes, the tip on the sequence helped!
I'm working on a project with prop as the main uC so if this LCD doesn't work, I'm shopping for another. So, the thought of dropping this was already in my mind before Steve's comment which I misunderstood
@Steve, regarding the bezel, I'll be designing a simple bracket in Rhino & 3D print it. I don't mind sharing it with you but if yours is for your baby gameboy, I think you might need a unique hand-&-finger friendly type of design? I did tried a portable gaming device based on prop but it is also KIV for now...
I was looking for a better and cheaper small LCD exercise help solution. I've lost 25 pounds since Jan 1st ;-)
The thing that bothers me most when I'm jogging is the size of my phone sloshing around in my pocket.
Just curious, may I know which location on the body to place your device would be most optimal? Head-band? Arm-band? Wist-band?
From a user perspective? Anywhere ... a pocket?
I really would like to make a watch band device (there must be billions of iPod 6 watchbands on the market). Not sure if there is room for a propeller and all the extra devices though. Need a good LCD (small, cheap, low power), Accelerometer, Heart-rate monitor, RTC (ya, watch feature), IRDA for sync (and maybe programming). LCD is a big problem