This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LCD help needed

Hello EveryBody, I am working on LCD (16x2) and i have built some of my ideas about LCD programming but i am using Assembly language for my LCD, well as all things was going sweet so as every programmer is having something wrong ... (in starting) my problem specification is that i am using that LCD in 8-bit mode and i have connected my AT89C2051 (with some pull-ups)
P1 DB
P3.7 RS
P3.5 RW
P3.4 E
and i have interfaced my LCD with my MCu but my problem is that i am getting the LCD not working ... (i dont know why) .... i have interfaced my LCD but there only little bit of contrast....i mean to say that there nothing visible... even i move my 10K-ohm-POT to the ground.....

and i have done some programming, so could any one please help me .... (i am really stucked)
any help will be appritiatable.....

<code> ORG 0000H LJMP MAIN ORG 0030H RS EQU P3.7 RW EQU P3.5 EN EQU P3.4
MAIN: LCALL DELAY CLR EN MOV DPTR,#MYCOM LCALL LCD_INI MOV DPTR,#MYDATA LCALL LOOP MOV A,#0C9h LCALL COM LCALL DELAY MOV DPTR,#MYDAT2 LCALL LOOP
AGAIN: SJMP AGAIN
;========================================
COM: MOV P1,A CLR RS CLR RW SETB EN LCALL DELAY CLR EN RET
;========================================
DATAW: MOV P1,A SETB RS CLR RW SETB EN LCALL DELAY CLR EN RET
;========================================
DELAY: MOV R6,#100
HERE2: MOV R7,#250
HERE: DJNZ R7,HERE DJNZ R6,HERE2 RET
;========================================
LCD_INI: CLR A MOVC A,@A+DPTR LCALL COM LCALL DELAY JZ GO_B1 INC DPTR SJMP LCD_INI
GO_B1: RET
;========================================
LOOP: CLR A MOVC A,@A+DPTR LCALL DATAW LCALL DELAY INC DPTR JZ GO_B2 SJMP LOOP
GO_B2: RET
;========================================
MYCOM: DB 38H,0EH,06,01,84H,0
MYDATA: DB "DAREDEVIL",0
MYDAT2: DB "GUNS AND ROSES",0
;======================================== END
</code>

Asif Ali "DareDevil"

Parents
  • This is the Code which worked for me, and also there is the pin configuration of My MCu (AT89C2051) with the LCD, Hoping that it will help the Noob Programmers (just like me) ;-)

    VSS ----> GROUND (PIN-NO 1 ON LCD)
    VCC ----> +5V (PIN-NO 2 ON LCD)
    CONTRAST-> 10KPOT (PIN-NO 3 ON LCD) [ONE SIDE GROUND ONE SIDE +5V]
    P3.4 ----> RS (PIN-NO 4 ON LCD)
    P3.5 ----> RW (PIN-NO 5 ON LCD)
    P3.7 ----> EN (PIN-NO 6 ON LCD)
    P1.0 ----> DB0 (PIN-NO 7 ON LCD)
    P1.1 ----> DB1 (PIN-NO 8 ON LCD)
    P1.2 ----> DB2 (PIN-NO 9 ON LCD)
    P1.3 ----> DB3 (PIN-NO 10 ON LCD)
    P1.4 ----> DB4 (PIN-NO 11 ON LCD)
    P1.5 ----> DB5 (PIN-NO 12 ON LCD)
    P1.6 ----> DB6 (PIN-NO 13 ON LCD)
    P1.7 ----> DB7 (PIN-NO 14 ON LCD)

    CODE FOR 8-BIT HD44780 LCD FOR WRITING "DARE DEVIL" ON LCD

                    ORG 0000H
                    LJMP MAIN
                    ORG 0030H
                    RS EQU P3.5
                    RW EQU P3.4
                    EN EQU P3.7
                                            ;initialization
    MAIN:           MOV A,#038H             ;8 bit mode ON, 2 lines, 5*8 font
                    LCALL COM               ;first time
                    MOV A,#038H             ;second time
                    LCALL COM
                    MOV A,#038H             ;third time
                    LCALL COM
                    MOV A,#038H             ;fourth time
                    LCALL COM
                    MOV A,#00CH             ;display ON, cursor OFF, blink OFF
                    LCALL COM
                    MOV A,#001H             ;clear screen
                    LCALL COM
                    MOV A,#006H             ;increase cursor position, scroll display OFF
                    LCALL COM
                    MOV A,#080H             ;Set DDRAM address to 0 (means to starting)
                    LCALL COM               ;initialization End
                    MOV A,#'D'              ;data to write on LCD
                    LCALL DATAW
                    MOV A,#'A'
                    LCALL DATAW
                    MOV A,#'R'
                    LCALL DATAW
                    MOV A,#'E'
                    LCALL DATAW
                    MOV A,#' '
                    LCALL DATAW
                    MOV A,#'D'
                    LCALL DATAW
                    MOV A,#'E'
                    LCALL DATAW
                    MOV A,#'V'
                    LCALL DATAW
                    MOV A,#'I'
                    LCALL DATAW
                    MOV A,#'L'
                    LCALL DATAW             ;data end
    AGAIN:          SJMP AGAIN              ;endless loop
    COM:            MOV P1,A                ;command write sequence
                    CLR RS
                    CLR RW
                    SETB EN
                    ;LCALL TEST
                    CLR EN
                    LCALL DELAY
                    RET
    DATAW:          MOV P1,A                ;data write sequence
                    SETB RS
                    CLR RW
                    SETB EN
                    ;LCALL TEST
                    CLR EN
                    LCALL DELAY
                    RET
    DELAY:          MOV R6,#50              ;simple delay routine
    HERE2:          MOV R7,#255             ;for 0.0124S or 124MS
    HERE:           DJNZ R7,HERE
                    DJNZ R6,HERE2
                    RET
    TEST:           JB P3.0,TEST
    TEST2:          JNB P3.0,TEST2
                    RET
                    END
    

Reply
  • This is the Code which worked for me, and also there is the pin configuration of My MCu (AT89C2051) with the LCD, Hoping that it will help the Noob Programmers (just like me) ;-)

    VSS ----> GROUND (PIN-NO 1 ON LCD)
    VCC ----> +5V (PIN-NO 2 ON LCD)
    CONTRAST-> 10KPOT (PIN-NO 3 ON LCD) [ONE SIDE GROUND ONE SIDE +5V]
    P3.4 ----> RS (PIN-NO 4 ON LCD)
    P3.5 ----> RW (PIN-NO 5 ON LCD)
    P3.7 ----> EN (PIN-NO 6 ON LCD)
    P1.0 ----> DB0 (PIN-NO 7 ON LCD)
    P1.1 ----> DB1 (PIN-NO 8 ON LCD)
    P1.2 ----> DB2 (PIN-NO 9 ON LCD)
    P1.3 ----> DB3 (PIN-NO 10 ON LCD)
    P1.4 ----> DB4 (PIN-NO 11 ON LCD)
    P1.5 ----> DB5 (PIN-NO 12 ON LCD)
    P1.6 ----> DB6 (PIN-NO 13 ON LCD)
    P1.7 ----> DB7 (PIN-NO 14 ON LCD)

    CODE FOR 8-BIT HD44780 LCD FOR WRITING "DARE DEVIL" ON LCD

                    ORG 0000H
                    LJMP MAIN
                    ORG 0030H
                    RS EQU P3.5
                    RW EQU P3.4
                    EN EQU P3.7
                                            ;initialization
    MAIN:           MOV A,#038H             ;8 bit mode ON, 2 lines, 5*8 font
                    LCALL COM               ;first time
                    MOV A,#038H             ;second time
                    LCALL COM
                    MOV A,#038H             ;third time
                    LCALL COM
                    MOV A,#038H             ;fourth time
                    LCALL COM
                    MOV A,#00CH             ;display ON, cursor OFF, blink OFF
                    LCALL COM
                    MOV A,#001H             ;clear screen
                    LCALL COM
                    MOV A,#006H             ;increase cursor position, scroll display OFF
                    LCALL COM
                    MOV A,#080H             ;Set DDRAM address to 0 (means to starting)
                    LCALL COM               ;initialization End
                    MOV A,#'D'              ;data to write on LCD
                    LCALL DATAW
                    MOV A,#'A'
                    LCALL DATAW
                    MOV A,#'R'
                    LCALL DATAW
                    MOV A,#'E'
                    LCALL DATAW
                    MOV A,#' '
                    LCALL DATAW
                    MOV A,#'D'
                    LCALL DATAW
                    MOV A,#'E'
                    LCALL DATAW
                    MOV A,#'V'
                    LCALL DATAW
                    MOV A,#'I'
                    LCALL DATAW
                    MOV A,#'L'
                    LCALL DATAW             ;data end
    AGAIN:          SJMP AGAIN              ;endless loop
    COM:            MOV P1,A                ;command write sequence
                    CLR RS
                    CLR RW
                    SETB EN
                    ;LCALL TEST
                    CLR EN
                    LCALL DELAY
                    RET
    DATAW:          MOV P1,A                ;data write sequence
                    SETB RS
                    CLR RW
                    SETB EN
                    ;LCALL TEST
                    CLR EN
                    LCALL DELAY
                    RET
    DELAY:          MOV R6,#50              ;simple delay routine
    HERE2:          MOV R7,#255             ;for 0.0124S or 124MS
    HERE:           DJNZ R7,HERE
                    DJNZ R6,HERE2
                    RET
    TEST:           JB P3.0,TEST
    TEST2:          JNB P3.0,TEST2
                    RET
                    END
    

Children