Shop OBEX P1 Docs P2 Docs Learn Events
2.4" LCD Touchscreen. Getting the screen to come on and do something, anything? — Parallax Forums

2.4" LCD Touchscreen. Getting the screen to come on and do something, anything?

eagletalontimeagletalontim Posts: 1,399
edited 2012-03-04 05:13 in Propeller 1
Well, I am back at it again and this time with something that is way out of my abilities. I have purchased 2 each 2.4" LCD touchscreens from here :
http://iteadstudio.com/store/index.php?main_page=product_info&cPath=57_58&products_id=55

I have been following these 2 posts which are also working with touchscreens :
Thread 1: http://forums.parallax.com/showthread.php?137266-Propeller-GUI-touchscreen-and-full-color-display > Using the same screen as I am but using latches instead of direct connections to the Prop as I am doing.
Thread 2: http://forums.parallax.com/showthread.php?137999-LCD-touchscreen-A-development-thread > Using a different display, but not using latches. Similar code as well.

What I have done so far is wired up my display exactly like done in Thread 2. I am using the screen initialization method in Thread 1 since it is for my screen. I have attached the testing file that I have modified for my setup from Thread 2. When the Prop is powered on, the LCD backlight comes on instantly but after that, nothing changes on the screen. I have temporarily connected LED's to each pin that controls the screen and some of them flash the LED about 1 second after power is connected so I know the program is running and the screen is receiving the signal. I have also tried 2 different screens with no change with either screen.

Here is the pinout of the LCD : DSC09480-1.jpg

Do I have something wrong?
«13

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2012-02-26 10:02
    I also have one of those LCDs running (not with an ILI but same size/resolution..) and also had some problems. What can easily happen is that you have a bad soldering or shortcuts. So, I'd always write a small connection-test-program for such complex devices. You simply loop through all output pins (propeller-side), set one pin high and check with a voltmeter (or another propeller pin) whether the voltage arrives at the display flex cable and that no other pins are high (shortcut).
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 11:21
    The whole circuit is on a breadboard. The screen is connected with a 40 pin hard drive cable cut about 2 inches away from the connector and all the tips tinned so they can easily be put into the connections on the breadboard and to prevent short circuits. I have checked each connection with an ohm meter from the leg of the Prop where it comes out of the chip, to the solder connection on the display connecting pins. Every one checked out 100%. I have even retraced each connection to ensure they are going to the appropriate pin on the prop according to the schematic in the Thread 2 link above. One thing I do not have is the capacitors as shown in this schematic : http://forums.parallax.com/attachment.php?attachmentid=89647&d=1329472813 Are they needed to run the display?
  • MagIO2MagIO2 Posts: 2,243
    edited 2012-02-26 11:28
    You don't have any of the caps??
    That would indeed be a bad idea! Yes, you need caps for running anything reliably on the prop. There are severals threads discussing capacitor issues.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 13:55
    I have the caps on the power regulators like I should, but I see he has some kind of ADC setup with 3 caps which I don't think I need unless it is to run the display and the circuit to the right of the eeprom is something I have no idea about. Is that supposed to be the power supply in? The schematic is not that readable to me since some traces are not labeled the way I am used to.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-02-26 13:58
    Is that the entire code? if so, where is the part that calls Start, and calls Draw?

    If that is the code as it is, it will run the Start method but it still needs to run the Draw method and the Pixel method from somewhere.

    Also a photo of the board would be helpful if there is some discussion about capacitors being left out.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 14:13
    That is the entire program as posted. I don't know how to use the draw functions since I am trying to piece together something that will work. I have seen the Pixel function as well, but that confuses me too. I usually find a working function and modify it to fit my needs. Since I am not that familiar with 60% of the coding used to run the display, I don't have the ability to write code from the top of my head :( I will get there though!

    If the code I posted is close, could someone help me get it farther than that? I don't have a way to take a picture and upload it at the moment. I am not even sure a picture will help since my circuit looks like a spider sitting on top of the 40 pin Prop.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-02-26 14:33
    Quick test - see if this puts one pixel on the screen. I added two routines at the bottom.
    PUB Start_SSD1289
        ''init pins
        OUTA[SD_CS] := 1
        OUTA[TS_CS] := 1
        EnableDisplayPins                                     ' enable pins 0 to 15
    
        ResetHigh
        wait.pause1ms(5)
    
        ResetLow
        wait.pause1ms(5)
        ResetHigh
    
        WriteHigh
        wait.pause1ms(5)
    
        Lcd_Write_Com($00,$E5)
        Lcd_Write_Data($78,$F0)                               ' set SRAM internal timing
        Lcd_Write_Com($00,$01)
        Lcd_Write_Data($01,$00)                             ' set SS and SM bit
        Lcd_Write_Com($00,$02)
        Lcd_Write_Data($07,$00)                             ' set 1 line inversion
        Lcd_Write_Com($00,$03)
        Lcd_Write_Data($10,$30)                             ' set GRAM write direction and BGR=1.
        Lcd_Write_Com($00,$04)
        Lcd_Write_Data($00,$00)                             ' Resize register
        Lcd_Write_Com($00,$08)
        Lcd_Write_Data($02,$07)                             ' set the back porch and front porch
        Lcd_Write_Com($00,$09)
        Lcd_Write_Data($00,$00)                             ' set non-display area refresh cycle ISC[3:0]
        Lcd_Write_Com($00,$0A)
        Lcd_Write_Data($00,$00)                             ' FMARK function
        Lcd_Write_Com($00,$0C)
        Lcd_Write_Data($00,$00)                             ' RGB interface setting
        Lcd_Write_Com($00,$0D)
        Lcd_Write_Data($00,$00)                             ' Frame marker Position
        Lcd_Write_Com($00,$0F)
        Lcd_Write_Data($00,$00)                             ' RGB interface polarity
    '        *************Power On sequence ****************//
        Lcd_Write_Com($00,$10)
        Lcd_Write_Data($00,$00)                             ' SAP, BT[3:0], AP, DSTB, SLP, STB
        Lcd_Write_Com($00,$11)
        Lcd_Write_Data($00,$07)                             ' DC1[2:0], DC0[2:0], VC[2:0]
        Lcd_Write_Com($00,$12)
        Lcd_Write_Data($00,$00)                             ' VREG1OUT voltage
        Lcd_Write_Com($00,$13)
        Lcd_Write_Data($00,$00)                             ' VDV[4:0] for VCOM amplitude
        Lcd_Write_Com($00,$07)
        Lcd_Write_Data($00,$01)
        wait.pause1ms(50)                                  ' Dis-charge capacitor power voltage
        Lcd_Write_Com($00,$10)
        Lcd_Write_Data($10,$90)                             ' 1490//SAP, BT[3:0], AP, DSTB, SLP, STB
        Lcd_Write_Com($00,$11)
        Lcd_Write_Data($02,$27)                             ' DC1[2:0], DC0[2:0], VC[2:0]
        wait.pause1ms(50)                                  ' delay
        Lcd_Write_Com($00,$12)
        Lcd_Write_Data($00,$1F)                             '001C// Internal reference voltage= Vci;
        wait.pause1ms(50)                                  ' delay   
        Lcd_Write_Com($00,$13)
        Lcd_Write_Data($15,$00)                             '$1000//1400   Set VDV[4:0] for VCOM amplitude  1A00
        Lcd_Write_Com($00,$29)
        Lcd_Write_Data($00,$27)                             '$0012 //001a  Set VCM[5:0] for VCOMH  //$0025  0034
        Lcd_Write_Com($00,$2B)
        Lcd_Write_Data($00,$0D)                             ' Set Frame Rate   000C
        wait.pause1ms(50)                                  ' delay   
        Lcd_Write_Com($00,$20)
        Lcd_Write_Data($00,$00)                             ' GRAM horizontal Address
        Lcd_Write_Com($00,$21)
        Lcd_Write_Data($00,$00)                             ' GRAM Vertical Address
    '         ----------- Adjust the Gamma Curve ----------//
        Lcd_Write_Com($00,$30)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$31)
        Lcd_Write_Data($07,$07)
        Lcd_Write_Com($00,$32)
        Lcd_Write_Data($03,$07)
        Lcd_Write_Com($00,$35)
        Lcd_Write_Data($02,$00)
        Lcd_Write_Com($00,$36)
        Lcd_Write_Data($00,$08)                           '//0207
        Lcd_Write_Com($00,$37)
        Lcd_Write_Data($00,$04)                           '//0306
        Lcd_Write_Com($00,$38)
        Lcd_Write_Data($00,$00)                           '//0102
        Lcd_Write_Com($00,$39)
        Lcd_Write_Data($07,$07)                           '//0707
        Lcd_Write_Com($00,$3C)
        Lcd_Write_Data($00,$02)                           '//0702
        Lcd_Write_Com($00,$3D)
        Lcd_Write_Data($1D,$04)                           '//1604
    '        ------------------ Set GRAM area ---------------//
        Lcd_Write_Com($00,$50)
        Lcd_Write_Data($00,$00)     ' Horizontal GRAM Start Address
        Lcd_Write_Com($00,$51)
        Lcd_Write_Data($00,$EF)     ' Horizontal GRAM End Address
        Lcd_Write_Com($00,$52)
        Lcd_Write_Data($00,$00)     ' Vertical GRAM Start Address
        Lcd_Write_Com($00,$53)
        Lcd_Write_Data($01,$3F)     ' Vertical GRAM Start Address
        Lcd_Write_Com($00,$60)
        Lcd_Write_Data($A7,$00)     ' Gate Scan Line
        Lcd_Write_Com($00,$61)
        Lcd_Write_Data($00,$01)     ' NDL,VLE, REV
        Lcd_Write_Com($00,$6A)
        Lcd_Write_Data($00,$00)     ' set scrolling line
    '        -------------- Partial Display Control ---------/
    
        Lcd_Write_Com($00,$80)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$81)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$82)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$83)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$84)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$85)
        Lcd_Write_Data($00,$00)
    '        //-------------- Panel Control -------------------//
        Lcd_Write_Com($00,$90)
        Lcd_Write_Data($00,$10)
        Lcd_Write_Com($00,$92)
        Lcd_Write_Data($06,$00)
        Lcd_Write_Com($00,$07)
        Lcd_Write_Data($01,$33)     ' 262K color and display ON
    
    
        Draw (10,10,10,10)
        Pixel($FF,$FF)
    

    Also I know average joe is not using chip select, but this code came from the C source code that came with the display and they toggle chip select as part of the startup sequence
        ResetHigh
        wait.pause1ms(5)
        ResetLow
        wait.pause1ms(5)
        ResetHigh
        ChipSelectHigh
        ReadHigh
        WriteHigh
        wait.pause1ms(5)
        ChipSelectLow
    


    If not, I'll put my thinking cap on again...
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 15:44
    Which pin is that one for the ChipSelect? On the diagram above, there are 4 of them: SD_CD (SD Card), F_CS (Not sure what this is), CS (I am thinking this is the one) and D_CS (This could be it as well)
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 15:57
    I figured out which pin it is, but still nothing. Here is my updated code :
    ' SSD1289 P0 - P15 pins
    ' 
    ' Methods:
    ' .Start = start the driver
    ' .Draw  = start drawing at x1,y1 and continue until x2,y2
    ' .Pixel = a pixel in 2 bytes RRRRRGGG GGGBBBBB
    
    
    CON
      _clkmode      = xtal1 + pll16x                        ' use crystal x 16
      _xinfreq      = 5_000_000
    
      CS              = 24
      RS              = 16
      RD              = 25
      LCD_WR          = 17
      LCD_RST         = 23
      SD_CS           = 22
      TS_CS           = 21
    
    OBJ  
        wait    : "timing"                                    ' thanks to parallax   
    
    VAR
         byte lcd_data_high, lcd_data_low  ' status of all the display pins
          
    PUB Start_SSD1289
        ''init pins
        OUTA[SD_CS] := 1
        OUTA[TS_CS] := 1
        EnableDisplayPins                                     ' enable pins 0 to 15
    
        'ResetHigh
        'wait.pause1ms(5)
        'ResetLow
        'wait.pause1ms(5)
        'ResetHigh
        'WriteHigh
        'wait.pause1ms(5)
        ResetHigh
        wait.pause1ms(5)
        ResetLow
        wait.pause1ms(5)
        ResetHigh
        ChipSelectHigh
        ReadHigh
        WriteHigh
        wait.pause1ms(5)
        ChipSelectLow
    
        Lcd_Write_Com($00,$E5)
        Lcd_Write_Data($78,$F0)                               ' set SRAM internal timing
        Lcd_Write_Com($00,$01)
        Lcd_Write_Data($01,$00)                             ' set SS and SM bit
        Lcd_Write_Com($00,$02)
        Lcd_Write_Data($07,$00)                             ' set 1 line inversion
        Lcd_Write_Com($00,$03)
        Lcd_Write_Data($10,$30)                             ' set GRAM write direction and BGR=1.
        Lcd_Write_Com($00,$04)
        Lcd_Write_Data($00,$00)                             ' Resize register
        Lcd_Write_Com($00,$08)
        Lcd_Write_Data($02,$07)                             ' set the back porch and front porch
        Lcd_Write_Com($00,$09)
        Lcd_Write_Data($00,$00)                             ' set non-display area refresh cycle ISC[3:0]
        Lcd_Write_Com($00,$0A)
        Lcd_Write_Data($00,$00)                             ' FMARK function
        Lcd_Write_Com($00,$0C)
        Lcd_Write_Data($00,$00)                             ' RGB interface setting
        Lcd_Write_Com($00,$0D)
        Lcd_Write_Data($00,$00)                             ' Frame marker Position
        Lcd_Write_Com($00,$0F)
        Lcd_Write_Data($00,$00)                             ' RGB interface polarity
    '        *************Power On sequence ****************//
        Lcd_Write_Com($00,$10)
        Lcd_Write_Data($00,$00)                             ' SAP, BT[3:0], AP, DSTB, SLP, STB
        Lcd_Write_Com($00,$11)
        Lcd_Write_Data($00,$07)                             ' DC1[2:0], DC0[2:0], VC[2:0]
        Lcd_Write_Com($00,$12)
        Lcd_Write_Data($00,$00)                             ' VREG1OUT voltage
        Lcd_Write_Com($00,$13)
        Lcd_Write_Data($00,$00)                             ' VDV[4:0] for VCOM amplitude
        Lcd_Write_Com($00,$07)
        Lcd_Write_Data($00,$01)
        wait.pause1ms(50)                                  ' Dis-charge capacitor power voltage
        Lcd_Write_Com($00,$10)
        Lcd_Write_Data($10,$90)                             ' 1490//SAP, BT[3:0], AP, DSTB, SLP, STB
        Lcd_Write_Com($00,$11)
        Lcd_Write_Data($02,$27)                             ' DC1[2:0], DC0[2:0], VC[2:0]
        wait.pause1ms(50)                                  ' delay
        Lcd_Write_Com($00,$12)
        Lcd_Write_Data($00,$1F)                             '001C// Internal reference voltage= Vci;
        wait.pause1ms(50)                                  ' delay   
        Lcd_Write_Com($00,$13)
        Lcd_Write_Data($15,$00)                             '$1000//1400   Set VDV[4:0] for VCOM amplitude  1A00
        Lcd_Write_Com($00,$29)
        Lcd_Write_Data($00,$27)                             '$0012 //001a  Set VCM[5:0] for VCOMH  //$0025  0034
        Lcd_Write_Com($00,$2B)
        Lcd_Write_Data($00,$0D)                             ' Set Frame Rate   000C
        wait.pause1ms(50)                                  ' delay   
        Lcd_Write_Com($00,$20)
        Lcd_Write_Data($00,$00)                             ' GRAM horizontal Address
        Lcd_Write_Com($00,$21)
        Lcd_Write_Data($00,$00)                             ' GRAM Vertical Address
    '         ----------- Adjust the Gamma Curve ----------//
        Lcd_Write_Com($00,$30)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$31)
        Lcd_Write_Data($07,$07)
        Lcd_Write_Com($00,$32)
        Lcd_Write_Data($03,$07)
        Lcd_Write_Com($00,$35)
        Lcd_Write_Data($02,$00)
        Lcd_Write_Com($00,$36)
        Lcd_Write_Data($00,$08)                           '//0207
        Lcd_Write_Com($00,$37)
        Lcd_Write_Data($00,$04)                           '//0306
        Lcd_Write_Com($00,$38)
        Lcd_Write_Data($00,$00)                           '//0102
        Lcd_Write_Com($00,$39)
        Lcd_Write_Data($07,$07)                           '//0707
        Lcd_Write_Com($00,$3C)
        Lcd_Write_Data($00,$02)                           '//0702
        Lcd_Write_Com($00,$3D)
        Lcd_Write_Data($1D,$04)                           '//1604
    '        ------------------ Set GRAM area ---------------//
        Lcd_Write_Com($00,$50)
        Lcd_Write_Data($00,$00)     ' Horizontal GRAM Start Address
        Lcd_Write_Com($00,$51)
        Lcd_Write_Data($00,$EF)     ' Horizontal GRAM End Address
        Lcd_Write_Com($00,$52)
        Lcd_Write_Data($00,$00)     ' Vertical GRAM Start Address
        Lcd_Write_Com($00,$53)
        Lcd_Write_Data($01,$3F)     ' Vertical GRAM Start Address
        Lcd_Write_Com($00,$60)
        Lcd_Write_Data($A7,$00)     ' Gate Scan Line
        Lcd_Write_Com($00,$61)
        Lcd_Write_Data($00,$01)     ' NDL,VLE, REV
        Lcd_Write_Com($00,$6A)
        Lcd_Write_Data($00,$00)     ' set scrolling line
    '        -------------- Partial Display Control ---------/
    
        Lcd_Write_Com($00,$80)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$81)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$82)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$83)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$84)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$85)
        Lcd_Write_Data($00,$00)
    '        //-------------- Panel Control -------------------//
        Lcd_Write_Com($00,$90)
        Lcd_Write_Data($00,$10)
        Lcd_Write_Com($00,$92)
        Lcd_Write_Data($06,$00)
        Lcd_Write_Com($00,$07)
        Lcd_Write_Data($01,$33)     ' 262K color and display ON
    
    
        Draw (10,10,10,10)
        Pixel($FF,$FF)
    
    PUB Draw(x1, y1, x2, y2)      ' sets the pixel to x1,y1 and then fills the next (x2-x1)*(y2-y1) pixels
       
        Lcd_Write_Com($00,$20)
        Lcd_Write_Data(x1>>8,x1)
        Lcd_Write_Com($00,$21)
        Lcd_Write_Data(y1>>8,y1)
        Lcd_Write_Com($00,$50)
        Lcd_Write_Data(x1>>8,x1)
        Lcd_Write_Com($00,$52)
        Lcd_Write_Data(y1>>8,y1)
        Lcd_Write_Com($00,$51)
        Lcd_Write_Data(x2>>8,x2)
        Lcd_Write_Com($00,$53)
        Lcd_Write_Data(y2>>8,y2)
        Lcd_Write_Com($00,$22)
      
    PUB Pixel(VH,VL)               ' send out a pixel, high byte then low byte                                
        Lcd_Write_Data(VH,VL)  
                                             
    '********************** private methods *********************
    PRI LCD_Writ_Bus(VH,VL) 
        OUTA[7..0]  := VL
        OUTA[15..8] := VH
        WriteLow                                            ' write pin low
        WriteHigh                                           ' toggle write pin
    
    PRI Lcd_Write_Com(VH,VL)
        RSLow
        LCD_Writ_Bus(VH,VL)
    
    PRI Lcd_Write_Data(VH,VL)
        RSHigh
        LCD_Writ_Bus(VH,VL)    
    
    PRI EnableDisplayPins
        DIRA:=%00000000_11100011_11111111_11111111 ' , Reset, WR, RS and 16 data lines active    
    
    PRI TristateDisplayPins ' tristate all pins - 
        DIRA:=%00000000_11100010_00000000_00000000
    
    PRI ChipSelectLow                                    
        outa[CS] := 0
    
    PRI ChipSelectHigh
        outa[CS] := 1
    
    PRI ReadLow                                    
        OUTA[RD] := 0                                           ' send to the latch
    
    PRI ReadHigh
        OUTA[RD] := 1
        
    PRI RSLow                                    ' RS pin
     outa[RS] := 0                  
    
    PRI RSHigh
     outa[RS] := 1                 '
    
    PRI WriteLow                                    
        outa[LCD_WR] := 0                             ' 
    
    PRI WriteHigh
        outa[LCD_WR] := 1 
    
    PRI ResetLow                                    
        outa[LCD_RST] := 0                        ' 
    
    PRI ResetHigh
        outa[LCD_RST] := 1
    
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 16:14
    ok, using LED's as a test, I have found that the Chip Select pin (24) is not going high and neither is the Read (RD) Pin 25 on the Prop. It has to be something simple!
  • kuronekokuroneko Posts: 3,623
    edited 2012-02-26 16:18
    It has to be something simple!
    It is. Both pins are never defined as outputs.
  • average joeaverage joe Posts: 795
    edited 2012-02-26 16:23
    In your tristate and enable pin routines,pin 24 and 25 are inputs.
    try
    PRI EnableDisplayPins
        DIRA:=%00000011_11100011_11111111_11111111 ' , Reset, WR, RS and 16 data lines active    
    
    PRI TristateDisplayPins ' tristate all pins - 
        DIRA:=%00000011_11100010_00000000_00000000
    
    
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-02-26 16:27
    Just to double check, re getting the pins confused, on the schematic on post 1, all down the bottom row are the display pins. Also the top row, starting at the left, the next 8 pins.

    The touchscreen ones are the next 6. Then there are the 4 SD card ones. The display, touchscreen and SD card are three separate circuits.

    Yes I see what you mean about all the CS pins! The one you want is labeled 'CS", (not F_CS, nor D_CS nor SD_CS).

    You will need some new routines to toggle CS.

    RD can be tied to 3V3.

    A photo here would be very helpful. Just one thing wrong and the whole circuit won't work.
    I am not even sure a picture will help since my circuit looks like a spider sitting on top of the 40 pin Prop.
    that is ok all prototypes look like that.

    @average joe - yes, good find. It might be easier to use P16 and count up 5 pins as the current pins allocation is split in two.

    The tristate code can be deleted - that was there for when those pins are shared by other things.

    Then you just need a DIRA with the correct pins enabled.
  • average joeaverage joe Posts: 795
    edited 2012-02-26 16:49
    If I may make a suggestion, keeping the lcd pins together is very helpful. You may find, after you get your screen working, you may want to use pull up resistors on the WR and RS pins as I am. It doesn't make a difference in spin, but in PSAM it saves 4 instructions PER WRITE. *or at least the way I am doing things.* And Dr. A is right, all prototypes are rough.Tristate can be removed if you are not planning on using those pins for other stuff.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 16:58
    Ok, here is the updated code with the above changes :
    ' SSD1289 P0 - P15 pins
    ' 
    ' Methods:
    ' .Start = start the driver
    ' .Draw  = start drawing at x1,y1 and continue until x2,y2
    ' .Pixel = a pixel in 2 bytes RRRRRGGG GGGBBBBB
    
    
    CON
      _clkmode      = xtal1 + pll16x                        ' use crystal x 16
      _xinfreq      = 5_000_000
    
      CS              = 24
      RS              = 16
      RD              = 25
      LCD_WR          = 17
      LCD_RST         = 23
      SD_CS           = 22
      TS_CS           = 21
    
    OBJ  
        wait    : "timing"                                    ' thanks to parallax   
    
    VAR
         byte lcd_data_high, lcd_data_low  ' status of all the display pins
          
    PUB Start_SSD1289
        ''init pins
        OUTA[SD_CS] := 1
        OUTA[TS_CS] := 1
        EnableDisplayPins                                     ' enable pins 0 to 15
    
        'ResetHigh
        'wait.pause1ms(5)
        'ResetLow
        'wait.pause1ms(5)
        'ResetHigh
        'WriteHigh
        'wait.pause1ms(5)
        ResetHigh
        wait.pause1ms(5)
        ResetLow
        wait.pause1ms(5)
        ResetHigh
        ChipSelectHigh
        ReadHigh
        WriteHigh
        wait.pause1ms(5)
        ChipSelectLow
    
        Lcd_Write_Com($00,$E5)
        Lcd_Write_Data($78,$F0)                               ' set SRAM internal timing
        Lcd_Write_Com($00,$01)
        Lcd_Write_Data($01,$00)                             ' set SS and SM bit
        Lcd_Write_Com($00,$02)
        Lcd_Write_Data($07,$00)                             ' set 1 line inversion
        Lcd_Write_Com($00,$03)
        Lcd_Write_Data($10,$30)                             ' set GRAM write direction and BGR=1.
        Lcd_Write_Com($00,$04)
        Lcd_Write_Data($00,$00)                             ' Resize register
        Lcd_Write_Com($00,$08)
        Lcd_Write_Data($02,$07)                             ' set the back porch and front porch
        Lcd_Write_Com($00,$09)
        Lcd_Write_Data($00,$00)                             ' set non-display area refresh cycle ISC[3:0]
        Lcd_Write_Com($00,$0A)
        Lcd_Write_Data($00,$00)                             ' FMARK function
        Lcd_Write_Com($00,$0C)
        Lcd_Write_Data($00,$00)                             ' RGB interface setting
        Lcd_Write_Com($00,$0D)
        Lcd_Write_Data($00,$00)                             ' Frame marker Position
        Lcd_Write_Com($00,$0F)
        Lcd_Write_Data($00,$00)                             ' RGB interface polarity
    '        *************Power On sequence ****************//
        Lcd_Write_Com($00,$10)
        Lcd_Write_Data($00,$00)                             ' SAP, BT[3:0], AP, DSTB, SLP, STB
        Lcd_Write_Com($00,$11)
        Lcd_Write_Data($00,$07)                             ' DC1[2:0], DC0[2:0], VC[2:0]
        Lcd_Write_Com($00,$12)
        Lcd_Write_Data($00,$00)                             ' VREG1OUT voltage
        Lcd_Write_Com($00,$13)
        Lcd_Write_Data($00,$00)                             ' VDV[4:0] for VCOM amplitude
        Lcd_Write_Com($00,$07)
        Lcd_Write_Data($00,$01)
        wait.pause1ms(50)                                  ' Dis-charge capacitor power voltage
        Lcd_Write_Com($00,$10)
        Lcd_Write_Data($10,$90)                             ' 1490//SAP, BT[3:0], AP, DSTB, SLP, STB
        Lcd_Write_Com($00,$11)
        Lcd_Write_Data($02,$27)                             ' DC1[2:0], DC0[2:0], VC[2:0]
        wait.pause1ms(50)                                  ' delay
        Lcd_Write_Com($00,$12)
        Lcd_Write_Data($00,$1F)                             '001C// Internal reference voltage= Vci;
        wait.pause1ms(50)                                  ' delay   
        Lcd_Write_Com($00,$13)
        Lcd_Write_Data($15,$00)                             '$1000//1400   Set VDV[4:0] for VCOM amplitude  1A00
        Lcd_Write_Com($00,$29)
        Lcd_Write_Data($00,$27)                             '$0012 //001a  Set VCM[5:0] for VCOMH  //$0025  0034
        Lcd_Write_Com($00,$2B)
        Lcd_Write_Data($00,$0D)                             ' Set Frame Rate   000C
        wait.pause1ms(50)                                  ' delay   
        Lcd_Write_Com($00,$20)
        Lcd_Write_Data($00,$00)                             ' GRAM horizontal Address
        Lcd_Write_Com($00,$21)
        Lcd_Write_Data($00,$00)                             ' GRAM Vertical Address
    '         ----------- Adjust the Gamma Curve ----------//
        Lcd_Write_Com($00,$30)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$31)
        Lcd_Write_Data($07,$07)
        Lcd_Write_Com($00,$32)
        Lcd_Write_Data($03,$07)
        Lcd_Write_Com($00,$35)
        Lcd_Write_Data($02,$00)
        Lcd_Write_Com($00,$36)
        Lcd_Write_Data($00,$08)                           '//0207
        Lcd_Write_Com($00,$37)
        Lcd_Write_Data($00,$04)                           '//0306
        Lcd_Write_Com($00,$38)
        Lcd_Write_Data($00,$00)                           '//0102
        Lcd_Write_Com($00,$39)
        Lcd_Write_Data($07,$07)                           '//0707
        Lcd_Write_Com($00,$3C)
        Lcd_Write_Data($00,$02)                           '//0702
        Lcd_Write_Com($00,$3D)
        Lcd_Write_Data($1D,$04)                           '//1604
    '        ------------------ Set GRAM area ---------------//
        Lcd_Write_Com($00,$50)
        Lcd_Write_Data($00,$00)     ' Horizontal GRAM Start Address
        Lcd_Write_Com($00,$51)
        Lcd_Write_Data($00,$EF)     ' Horizontal GRAM End Address
        Lcd_Write_Com($00,$52)
        Lcd_Write_Data($00,$00)     ' Vertical GRAM Start Address
        Lcd_Write_Com($00,$53)
        Lcd_Write_Data($01,$3F)     ' Vertical GRAM Start Address
        Lcd_Write_Com($00,$60)
        Lcd_Write_Data($A7,$00)     ' Gate Scan Line
        Lcd_Write_Com($00,$61)
        Lcd_Write_Data($00,$01)     ' NDL,VLE, REV
        Lcd_Write_Com($00,$6A)
        Lcd_Write_Data($00,$00)     ' set scrolling line
    '        -------------- Partial Display Control ---------/
    
        Lcd_Write_Com($00,$80)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$81)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$82)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$83)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$84)
        Lcd_Write_Data($00,$00)
        Lcd_Write_Com($00,$85)
        Lcd_Write_Data($00,$00)
    '        //-------------- Panel Control -------------------//
        Lcd_Write_Com($00,$90)
        Lcd_Write_Data($00,$10)
        Lcd_Write_Com($00,$92)
        Lcd_Write_Data($06,$00)
        Lcd_Write_Com($00,$07)
        Lcd_Write_Data($01,$33)     ' 262K color and display ON
    
    
        Draw (10,10,10,10)
        Pixel($FF,$FF)
    
    PUB Draw(x1, y1, x2, y2)      ' sets the pixel to x1,y1 and then fills the next (x2-x1)*(y2-y1) pixels
       
        Lcd_Write_Com($00,$20)
        Lcd_Write_Data(x1>>8,x1)
        Lcd_Write_Com($00,$21)
        Lcd_Write_Data(y1>>8,y1)
        Lcd_Write_Com($00,$50)
        Lcd_Write_Data(x1>>8,x1)
        Lcd_Write_Com($00,$52)
        Lcd_Write_Data(y1>>8,y1)
        Lcd_Write_Com($00,$51)
        Lcd_Write_Data(x2>>8,x2)
        Lcd_Write_Com($00,$53)
        Lcd_Write_Data(y2>>8,y2)
        Lcd_Write_Com($00,$22)
      
    PUB Pixel(VH,VL)               ' send out a pixel, high byte then low byte                                
        Lcd_Write_Data(VH,VL)  
                                             
    '********************** private methods *********************
    PRI LCD_Writ_Bus(VH,VL) 
        OUTA[7..0]  := VL
        OUTA[15..8] := VH
        WriteLow                                            ' write pin low
        WriteHigh                                           ' toggle write pin
    
    PRI Lcd_Write_Com(VH,VL)
        RSLow
        LCD_Writ_Bus(VH,VL)
    
    PRI Lcd_Write_Data(VH,VL)
        RSHigh
        LCD_Writ_Bus(VH,VL)    
    
    PRI EnableDisplayPins
        DIRA:=%00000011_11100011_11111111_11111111 ' , Reset, WR, RS and 16 data lines active    
    
    PRI TristateDisplayPins ' tristate all pins - 
        DIRA:=%00000011_11100010_00000000_00000000
    
    PRI ChipSelectLow                                    
        outa[CS] := 0
    
    PRI ChipSelectHigh
        outa[CS] := 1
    
    PRI ReadLow                                    
        OUTA[RD] := 0                                           ' send to the latch
    
    PRI ReadHigh
        OUTA[RD] := 1
        
    PRI RSLow                                    ' RS pin
     outa[RS] := 0                  
    
    PRI RSHigh
     outa[RS] := 1                 '
    
    PRI WriteLow                                    
        outa[LCD_WR] := 0                             ' 
    
    PRI WriteHigh
        outa[LCD_WR] := 1 
    
    PRI ResetLow                                    
        outa[LCD_RST] := 0                        ' 
    
    PRI ResetHigh
        outa[LCD_RST] := 1
    

    The LED's flash now, but the screen does not change. The backlight comes on, but no screen flicker, no pixels showing up, just all black :(

    Based on the first schematic from Average Joe's thread, there are 3 pins on the prop that are shared. Pins 23, 24, and 25 which are P16, P17 and P18. Are those supposed to be shared? There are 2 pin connections from the 40 pin connection on the display connected to each of the prop pins I listed.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 17:14
    I just tried to post a picture from my phone, but I could not since I don't have a smart phone :( Not sure what else to do to get a picture uploaded since my digital camera is MIA.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-02-26 17:39
    Based on the first schematic from Average Joe's thread, there are 3 pins on the prop that are shared. Pins 23, 24, and 25 which are P16, P17 and P18. Are those supposed to be shared? There are 2 pin connections from the 40 pin connection on the display connected to each of the prop pins I listed.

    Can you explain that a bit more - I can't see that looking at the schematic. P16 only goes to one place as far as I can see, but I might be missing something there.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 17:44
    Oops.. that was supposed to be P18, P19, and P20. The wires were the SD card, and Touch DIN and OUT and one other one. Can't remember now. I have removed all wires not pertaining to the LCD screen itself. Still working on that now so I can see which wires are still hooked up once I am finished.
  • average joeaverage joe Posts: 795
    edited 2012-02-26 17:52
    The shared wires are the spi bus for the sd card and touchscreen. Data in, data out and clock are shared between the two. Should not affect the screen.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-02-26 17:54
    Should be just 4 control wires.

    Then test things one line at a time
    ResetHigh
        wait.pause1ms(5)
        ResetLow
        wait.pause1ms(5)
        ResetHigh
        ChipSelectHigh
        ReadHigh
        WriteHigh
        wait.pause1ms(5)
        ChipSelectLow
    
        Lcd_Write_Com($00,$E5)
    

    change that to
    ResetHigh
    
      repeat
        wait.pause1ms(5)
        ResetLow
        wait.pause1ms(5)
        ResetHigh
        ChipSelectHigh
        ReadHigh
        WriteHigh
        wait.pause1ms(5)
        ChipSelectLow
    
        Lcd_Write_Com($00,$E5)
    

    That repeat will hang the prop at that point. Go along on the 40 pin header on the display and measure the volts on the reset pin. Then redo the code with that repeat moved down one line. Recheck the pin is what it should be

    Once you get down to LCD_Write with a repeat underneath that line, you should be able to find E5 on the pins. (use windows calculator to convert hex to binary).

    This is the way I tested the display out the first time. I'll be doing it again in the next few days with a new board design. Test things one line at a time.
  • average joeaverage joe Posts: 795
    edited 2012-02-26 17:58
    A trick I use is to define a public method called DEADEND and it looks like this.
    Pub Deadend
    repeat
      repeat
    
    This makes it less likely to loose an errant repeat in debugging IMO.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-02-26 18:02
    That is a great idea average joe. Yes - and when you have finished debugging, comment out that PUB and then if there are any calls to deadend that you missed the compiler will error.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 18:16
    Ok, I have redone all the wires and ensured each one was securely connected. I left out all SD, Touch and F_ pins. I put the repeat at the spot where Dr_Acula specified and then tested each of the pins. All of them were getting some kind of voltage. Some were a constant high, others fluctuated steadily from roughly 0.00 to 0.53v. I have a digital meter right now. My analog one is down since the batteries are dead in it :( I could probably see the swing a little better with the analog one. Still no pixel :(
  • average joeaverage joe Posts: 795
    edited 2012-02-26 18:28
    Dr_Acula wrote: »
    Should be just 4 control wires.

    Then test things one line at a time
    ResetHigh
        wait.pause1ms(5)
        ResetLow
        wait.pause1ms(5)
        ResetHigh
        ChipSelectHigh
        ReadHigh
        WriteHigh
        wait.pause1ms(5)
        ChipSelectLow
    
        Lcd_Write_Com($00,$E5)
    

    change that to
    *edited
    ResetHigh
    
      deadend
        wait.pause1ms(5)
        ResetLow
        wait.pause1ms(5)
        ResetHigh
        ChipSelectHigh
        ReadHigh
        WriteHigh
        wait.pause1ms(5)
        ChipSelectLow
    
        Lcd_Write_Com($00,$E5)
    

    ResetHigh
    
    
        wait.pause1ms(5)
        ResetLow
        deadend
      wait.pause1ms(5)
        ResetHigh
        ChipSelectHigh
        ReadHigh
        WriteHigh
        wait.pause1ms(5)
        ChipSelectLow
    
        Lcd_Write_Com($00,$E5)
    
    *edit*and continue this way

    That repeat will hang the prop at that point. Go along on the 40 pin header on the display and measure the volts on the reset pin. Then redo the code with that repeat moved down one line. Recheck the pin is what it should be

    Once you get down to LCD_Write with a repeat underneath that line, you should be able to find E5 on the pins. (use windows calculator to convert hex to binary).

    This is the way I tested the display out the first time. I'll be doing it again in the next few days with a new board design. Test things one line at a time.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 18:31
    I am not sure what you mean by

    "Go along on the 40 pin header on the display and measure the volts on the reset pin. ...
    Recheck the pin is what it should be
    Once you get down to LCD_Write with a repeat underneath that line, you should be able to find E5 on the pins. (use windows calculator to convert hex to binary)."

    Does this mean connect the meter to the reset pin and measure voltage on the D0 though D15 pins?

    I know all the pins are wired correctly and the pins on the display are getting voltage. Man this is frustrating!
  • average joeaverage joe Posts: 795
    edited 2012-02-26 18:35
    He meant to check the voltage between reset and ground. Even if all the wires are *correct* it is possible to call them in the wrong way. Testing each pin can assure this is not the problem. so connect meter to ground and probe each pin on the display for 3.3v or 0v
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 18:49
    Ok here are the results. All D0 though D15 stayed 0.0v until I got to the last line "Lcd_Write_Com($00,$E5)". When it dead ended at that line, These are the pins that went high on the display : 21 (DB0), 23 (DB2), 26 (DB5), and 27 (DB6). After a second or two, a few of the pins would go low, then come back to high. What do I do with the results?
  • average joeaverage joe Posts: 795
    edited 2012-02-26 18:53
    Use the dead end example I use, this won't allow pins to change during testing. E5 should leave pins D7,D6,D5,D4,D2 and D0 high. Check your write commands by feeding
    Lcd_Write_Com($00,$00)
    deadend
    
    and make sure data pins =0
    then, pass
    Lcd_Write_Com($00,$01)
    deadend
    
    and this should make D0 high
    repeat this for hex digits
    1, 2, 4, 8. These are the individual pins for each digit...SO..
    pin0, pin1, pin2, pin3

    that means $04 will make pin 2 high.
    if you set to $40,this will change pin 7... and so on
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-02-26 19:00
    That is with using the dead end example :) D4 is the only one that is not going High. I have traced the wire and tested the pin on the prop and it is not showing any voltage.
  • average joeaverage joe Posts: 795
    edited 2012-02-26 19:06
    D4,D3 and d1 should be low..for cmd ($00,$e5)
    try something like,

    CON
      _clkmode      = xtal1 + pll16x                        ' use crystal x 16
      _xinfreq      = 5_000_000
    
      CS              = 24
      RS              = 16
      RD              = 25
      LCD_WR          = 17
      LCD_RST         = 23
      SD_CS           = 22
      TS_CS           = 21
    
    OBJ  
        wait    : "timing"                                    ' thanks to parallax   
    
    VAR
         byte lcd_data_high, lcd_data_low  ' status of all the display pins
    Pub Test
    LCD_writ_Bus($00,00)
      deadend
    LCD_writ_Bus($00,01)
      deadend
    LCD_writ_Bus($00,02)
      deadend
    LCD_writ_Bus($00,04)
       deadend
    LCD_writ_Bus($00,08)
      deadend
    LCD_writ_Bus($00,10)
      deadend
    LCD_writ_Bus($00,20)
      deadend
    LCD_writ_Bus($00,40)
      deadend
    LCD_writ_Bus($00,80)
       deadend
    LCD_writ_Bus($01,00)
       deadend
    LCD_writ_Bus($02,00)
       deadend
    LCD_writ_Bus($04,00)
       deadend
    LCD_writ_Bus($08,00)
       deadend
    LCD_writ_Bus($10,00)
      deadend
    LCD_writ_Bus($20,00)
       deadend
    LCD_writ_Bus($40,00)
       deadend
    LCD_writ_Bus($80,00)
       deadend
    
    ChipSelectLow                                    
       deadend    
    
     ChipSelectHigh
        deadend
    
    ReadLow                                    
        deadend                                    ' send to 
    
    ReadHigh
        deadend
        
    RSLow                                    ' RS pin
           deadend          
    
    RSHigh
            deadend 
    
     WriteLow                                    
                   deadend          ' 
    
     WriteHigh
       deadend
    
    ResetLow                                    
      deadend                   ' 
    
     ResetHigh
       deadend
    
    
    
    
    
    
    
    
    
    
    
    
    pub deadend
        repeat
         repeat
    '********************** private methods *********************
    PRI LCD_Writ_Bus(VH,VL) 
        OUTA[7..0]  := VL
        OUTA[15..8] := VH
        WriteLow                                            ' write pin low
        WriteHigh                                           ' toggle write pin
    
    PRI Lcd_Write_Com(VH,VL)
        RSLow
        LCD_Writ_Bus(VH,VL)
    
    PRI Lcd_Write_Data(VH,VL)
        RSHigh
        LCD_Writ_Bus(VH,VL)    
    
    PRI EnableDisplayPins
        DIRA:=%00000000_11100011_11111111_11111111 ' , Reset, WR, RS and 16 data lines active    
    
    PRI TristateDisplayPins ' tristate all pins - 
        DIRA:=%00000000_11100010_00000000_00000000
    
    PRI ChipSelectLow                                    
        outa[CS] := 0
    
    PRI ChipSelectHigh
        outa[CS] := 1
    
    PRI ReadLow                                    
        OUTA[RD] := 0                                           ' send to the latch
    
    PRI ReadHigh
        OUTA[RD] := 1
        
    PRI RSLow                                    ' RS pin
     outa[RS] := 0                  
    
    PRI RSHigh
     outa[RS] := 1                 '
    
    PRI WriteLow                                    
        outa[LCD_WR] := 0                             ' 
    
    PRI WriteHigh
        outa[LCD_WR] := 1 
    
    PRI ResetLow                                    
        outa[LCD_RST] := 0                        ' 
    
    PRI ResetHigh
        outa[LCD_RST] := 1
    
    
    comment each code pair out when it tests ok
Sign In or Register to comment.