Post from Hippy re 14M/ 44780 LCD

Jim T

New Member
Unfortunately, the code Hippy posted in answer to my question regarding interfacing a 44780 based 2 line x 16 character to a 14M Picaxe, disappeared before my eyes when the Forum server went down. Could you possibly repost it please?
 

inglewoodpete

Senior Member
Jim, I don't know if you saw it, but I made a suggestion before the server "meltdown".

When debugging something that does not have critical timing (like an LCD), insert long pauses (Eg Pause 1000 or Pause 4000) between each output instruction. This gives you a chance to check the output signal sequence etc. Also, add a few LEDs + 300ohm resistors can be used when using this debugging method.
 

hippy

Technical Support
Staff member
@ Jim : Here you go, fingers crossed ...

Code:
        SYMBOL  RS        = 0         ; 0 = Command   1 = Data
        SYMBOL  E         = 1         ; 0 = Idle      1 = Active
        SYMBOL  DB4       = 2         ; LCD Data Line 4
        SYMBOL  DB5       = 3         ; LCD Data Line 5
        SYMBOL  DB6       = 4         ; LCD Data Line 6
        SYMBOL  DB7       = 5         ; LCD Data Line 7

        SYMBOL  RSCMDmask = %00000000 ; Select Command register
        SYMBOL  RSDATmask = %00000001 ; Select Data register

        SYMBOL  get       = b11
        SYMBOL  char      = b12
        SYMBOL  rsbit     = b13

    PowerOnReset:

        GOSUB InitialiseLcd

    DisplayTopLine:

        EEPROM 6,("Hello")

        FOR get = 6 TO 10
          READ get,char
          GOSUB SendDataByte
        NEXT

    MoveCursorToStartOfSecondLine:

        char = $C0
        GOSUB SendCmdByte

    DisplayBottomLine:

        EEPROM 11,("World!")

        FOR get = 11 TO 16
          READ get,char
          GOSUB SendDataByte
        NEXT

        END

    InitialiseLcd:

        FOR get = 0 TO 5
          READ get,char
          GOSUB SendInitCmdByte
        NEXT

        ' Nibble commands - To initialise 4-bit mode

        EEPROM 0,( $33 )    ; %0011---- %0011----   8-bit / 8-bit
        EEPROM 1,( $32 )    ; %0011---- %0010----   8-bit / 4-bit

        ' Byte commands - To configure the LCD

        EEPROM 2,( $28 )    ; %00101000 %001LNF00   Display Format
        EEPROM 3,( $0C )    ; %00001100 %00001DCB   Display On
        EEPROM 4,( $06 )    ; %00000110 %000001IS   Cursor Move

                            ; L : 0 = 4-bit Mode    1 = 8-bit Mode
                            ; N : 0 = 1 Line        1 = 2 Lines
                            ; F : 0 = 5x7 Pixels    1 = N/A
                            ; D : 0 = Display Off   1 = Display On
                            ; C : 0 = Cursor Off    1 = Cursor On
                            ; B : 0 = Cursor Steady 1 = Cursor Flash
                            ; I : 0 = Dec Cursor    1 = Inc Cursor
                            ; S : 0 = Cursor Move   1 = Display Shift

        EEPROM 5,( $01 )    ; Clear Screen

        RETURN

    SendInitCmdByte:

        PAUSE 15                        ; Delay 15mS

    SendCmdByte:

        rsbit = RSCMDmask               ; Send to Command register

    SendDataByte:

        pins = char & $F0 / 4 | rsbit   ; Put MSB out first
        PULSOUT E,1                     ; Give a 10uS pulse on E
        pins = char & $0F * 4 | rsbit   ; Put LSB out second
        PULSOUT E,1                     ; Give a 10uS pulse on E

        rsbit = RSDATmask               ; Send to Data register next

        RETURN
 

Jim T

New Member
Thanks Hippy. And no need for the crossing of fingers. One thing I have learnt after a lifetime in electronics. If you don't demonstrate daily that you are a bloody idiot, you are not learning............:)
 
Top