Shop OBEX P1 Docs P2 Docs Learn Events
Problem Initing Newhaven NHD-1.8-128160EF (ILI9163C) — Parallax Forums

Problem Initing Newhaven NHD-1.8-128160EF (ILI9163C)

MacTuxLinMacTuxLin Posts: 821
edited 2014-05-13 11:46 in Propeller 1
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
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)


358 x 305 - 59K

Comments

  • RaymanRayman Posts: 14,658
    edited 2014-05-03 07:51
    Garbage on screen after initial might be normal

    Maybe something wrong with pixel setting functions that come next...
  • T ChapT Chap Posts: 4,223
    edited 2014-05-03 09:12
    does the screen appear solid black on power up, then the garbage only after the code starts?
  • jazzedjazzed Posts: 11,803
    edited 2014-05-03 15:23
    Dang it,

    My NewHaven 1.8" display is a NHD-1.8-128160TF ....
  • MacTuxLinMacTuxLin Posts: 821
    edited 2014-05-04 04:46
    Rayman wrote: »
    Maybe something wrong with pixel setting functions that come next...

    Thanks Ray. I'll look into it.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2014-05-04 04:49
    T Chap wrote: »
    does the screen appear solid black on power up, then the garbage only after the code starts?

    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
  • MacTuxLinMacTuxLin Posts: 821
    edited 2014-05-04 04:53
    jazzed wrote: »
    Dang it,

    Guess you're right Steve. Think I'll just go for a display with SSD1306 controller instead...
  • jazzedjazzed Posts: 11,803
    edited 2014-05-04 08:55
    MacTuxLin wrote: »
    Guess you're right Steve. Think I'll just go for a display with SSD1306 controller instead...
    Umm, I wasn't trying to dissuade you. I thought it was fascinating that you had an LCD with the same name. Only one letter difference in the part number. I was only one letter away from being able to help with a prototype. That controller series is very popular ... surely someone has some advice.

    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?
  • T ChapT Chap Posts: 4,223
    edited 2014-05-04 09:14
    For the front panel, Acrylic P95 at .105" is nice in black or white, it has a matte surface on one side only looks nicer than the polished side. For the rear box, I CNC a clear acrylic box out of a sheet that is about .7" thick, There are two parts to the rear box sides, one part has the holes tapped for the rear panel to attach to after it is built. Clear is the only way IMO in that the only reliable way to glue two acrylic surfaces is with a UV curable glue. You can't use UV with any color cast material, but it goes through the clear and gives and immediate bond to the bezel. Loctite 352 UV glue with the spray primer.

    For the bezel, pocket an area for the LCD to drop down in slightly. This is the NHD capacitive touch screen turned vertical.
    480 x 640 - 59K
    640 x 480 - 137K
  • RaymanRayman Posts: 14,658
    edited 2014-05-04 12:31
    Sometimes the GRAM in these screens is a random pattern when powered on.
    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...
  • MacTuxLinMacTuxLin Posts: 821
    edited 2014-05-04 20:06
    All,

    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 :p

    @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...
    1024 x 594 - 66K
    606 x 495 - 79K
  • jazzedjazzed Posts: 11,803
    edited 2014-05-04 20:25
    @Kenichi,

    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.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2014-05-04 21:20
    Wow, I would definitely want to lose 25 pounds that's on me too. Its time to hit the gym (tomorrow for sure)...

    Just curious, may I know which location on the body to place your device would be most optimal? Head-band? Arm-band? Wist-band?
  • jazzedjazzed Posts: 11,803
    edited 2014-05-13 11:46
    MacTuxLin wrote: »
    Wow, I would definitely want to lose 25 pounds that's on me too. Its time to hit the gym (tomorrow for sure)...

    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 ;) The NHD 1.8 touchscreen is too big. The old Varitronix 1.44" COG LCDs are good size, but end of life apparently. Maybe something like this? Then there are battery issues even with a 150mAH 3.7V lipo.
Sign In or Register to comment.