LCD will not start


Results 1 to 40 of 50

Threaded View

  1. #17
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Brian,

    I see what you mean about the minimum power-up time of 10ms and the big power supply. Couple things you might try.

    If you have an extra pin available? You could use that to power the LCD. It would allow a nice fast rise time independant of the power supply. It only draws 4-5ma for the logic. Power the backlight separately (if there is one).

    Or, if you want to try the software initialization. Here's something I threw together.

    The datasheet shows a slightly different init sequence than a normal HD44780. It doesn't even say which driver chip the display uses.

    This routine follows the datasheet, and over emphasizes the delays, just in case. (16F only)
    Code:
    ;---- Change these to match your hardware ---------------------------
    @ Device pic16F877A, HS_OSC, BOD_OFF, PWRT_ON, WDT_ON, PROTECT_OFF
    DEFINE OSC 20
    DEFINE LOADER_USED 1 
    
    DEFINE LCD_DREG PORTD   ' Set LCD Data port
    DEFINE LCD_DBIT 0       ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTD  ' Set LCD Register Select port
    DEFINE LCD_RSBIT 5      ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTD   ' Set LCD Enable port
    DEFINE LCD_EBIT 4       ' Set LCD Enable bit
    DEFINE LCD_BITS 4       ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2      ' Set number of lines on LCD
    
    ;CMCON = 7               ' if needed
    ;ADCON1 = 7
    ;--------------------------------------------------------------------
    
    GOSUB LCD_INIT          ' Do manual LCD Initialization
    
    LCDOUT "Hello World!"
    
    stop
    
    ;---- Manual LCD Initialization -------------------------------------
    TempB     VAR BYTE
    BUSdata   VAR BYTE
    
    Send4Bit:
        @ MOVE?CT  1, LCD_EREG,LCD_EBIT       ; Enable LCD
    @   MOVE?BB  LCD_DREG, _TempB             ; Put Data on the Bus R-M-W
    @   if LCD_DBIT == 0                      ;   Bus starts at 0
            TEMPB = (TEMPB & $F0) | BUSdata
    @   else                                  ;   Bus starts at 4
            TEMPB = (TEMPB & $0F) | (BUSdata << 4)
    @   endif
    @   MOVE?BB  _TempB, LCD_DREG  
        
        PAUSEUS 25                            ; Keep enabled extra long
        @ MOVE?CT  0, LCD_EREG,LCD_EBIT       ; Disable LCD
        Pauseus 50
    return
    ;-----------------------------------------
    LCD_INIT:
        @ MOVE?CT  0, LCD_RSREG,LCD_RSBIT     ; Start with RS LOW
        @ MOVE?CT  0, LCD_RSREG+80h,LCD_RSBIT ; RS is OUTPUT
        
        @ MOVE?CT  0, LCD_EREG,LCD_EBIT       ; Start with Enable LOW
        @ MOVE?CT  0, LCD_EREG+80h,LCD_EBIT   ; Enable is OUTPUT
    
        @ MOVE?CT  0, LCD_DREG+80h,LCD_DBIT   ; Data Bus is OUTPUT
        @ MOVE?CT  0, LCD_DREG+80h,LCD_DBIT +1
        @ MOVE?CT  0, LCD_DREG+80h,LCD_DBIT +2
        @ MOVE?CT  0, LCD_DREG+80h,LCD_DBIT +3
        
        PAUSE 1000
        BUSdata = 3
        GOSUB Send4Bit : pause 8              ; FunctionSet 4 times
        GOSUB Send4Bit : pauseUS 200
        GOSUB Send4Bit : pauseUS 200
        GOSUB Send4Bit : pauseUS 200
        BUSdata = 2  :  GOSUB Send4Bit        ; 4-bit mode
    
        BUSdata = 2  :  GOSUB Send4Bit        ; 2-line, 5x7
        BUSdata = 8  :  GOSUB Send4Bit        
        
        BUSdata = 0  :  GOSUB Send4Bit        ; Display OFF
        BUSdata = 8  :  GOSUB Send4Bit
        
        BUSdata = 0  :  GOSUB Send4Bit        ; Display Clear
        BUSdata = 1  :  GOSUB Send4Bit
        PAUSE 3
    
        BUSdata = 0  :  GOSUB Send4Bit        ; Entry Mode Set
        BUSdata = 6  :  GOSUB Send4Bit
        PAUSE 3
        
        BUSdata = 0  :  GOSUB Send4Bit        ; Display ON
        BUSdata = $C :  GOSUB Send4Bit
        
        @  MOVE?CT 1, LCDINITFLAG   ; Tell PBP LCD is already Initialized
    return
    ;---------- END LCD_INIT --------------------------------------------
    HTH,
    Last edited by Darrel Taylor; - 18th October 2006 at 23:29. Reason: Changed Defines to match original Post
    DT

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  3. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  4. Gps with 16f628
    By dragons_fire in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 8th June 2006, 03:38
  5. Dedicated LCD Controller question
    By chuckles in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th February 2006, 14:44

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts