Discussion in "8051 Discussion Forum" started by    sumant08    Sep 24, 2009.
Thu Sep 24 2009, 12:28 PM
#1
I want to connect 20x4 lcd to 8051.
I am using the same .asm code which i used for 16x2 lcd.
It is displaying the data but the first line is cont. on the third line & second line on fourth line.
Is initialization code same for both the lcd ?, i.e 38h , 0ch , 01 , 06 , 80h ,0 ...
Thu Sep 24 2009, 03:37 PM
#2

It is displaying the data but the first line is cont. on the third line & second line on fourth line.




Yep, the initialization is same as 16X2 LCD, the third line is the continuation of first line and fourth line that of second line.

first line address : 00h to 13h
second line address : 40h to 53h
third line : 14h to 27h
fourth line : 54h to 67h


Arun
 sumant08 like this.
Thu Sep 24 2009, 05:08 PM
#3
Thanks...
But can u pls post a demo code for displaying data on 4 different lines...
Fri Sep 25 2009, 08:27 AM
#4
O.K sumant, here's the code i wrote for you :

;***********************************************************************
; 20X4 LCD DEMO CODE FOR 8051,WRITTEN BY ARUN KUMAR V - DATE: 25/09/09
;***********************************************************************
$MOD51

  
  LCD EQU P1
  
  RS EQU P3.2
  RW EQU P3.3
  EN EQU P3.4
  
   
  ORG 0000H
  
  MAIN: LCALL PWR_DELAY
        LCALL INIT
 
 LINE1:  MOV A,#080H
         LCALL CMD
         MOV DPTR,#MSG_1
  AGAIN1: CLR A
         MOVC A,@A+DPTR
         JZ LINE2
         LCALL DAT
         INC DPTR
         SJMP AGAIN1
  
  
  LINE2: MOV A,#0C0H
         LCALL CMD
         MOV DPTR,#MSG_2
  AGAIN2: CLR A
         MOVC A,@A+DPTR
         JZ LINE3
         LCALL DAT
         INC DPTR
         SJMP AGAIN2
  
  LINE3: MOV A,#094H
         LCALL CMD
         MOV DPTR,#MSG_3
  AGAIN3: CLR A
         MOVC A,@A+DPTR
         JZ LINE4
         LCALL DAT
         INC DPTR
         SJMP AGAIN3
  
  
  
  LINE4: MOV A,#0D4H
         LCALL CMD
         MOV DPTR,#MSG_4
  AGAIN4: CLR A
         MOVC A,@A+DPTR
         JZ DONE
         LCALL DAT
         INC DPTR
         SJMP AGAIN4
  
  DONE: SJMP $  
  
 
;****************************LCD SUBROUTINES****************************************
          
   DAT:   SETB EN ;H->
L PULSE ON E 
          SETB RS ;RS=1 DATA
          CLR RW  ;RW=0 FOR WRITE
          MOV LCD,A ;MOVE ACC.DATA TO PORT
          CLR EN
          NOP
          LCALL DDELAY
          RET
;****************************LCD SUBROUTINES****************************************

   CMD:      SETB EN ;H->
L PULSE ON E
             CLR RS ;RS=0 FOR COMMAND
             CLR RW ;RW=0 FOR WRITE
             MOV LCD,A ;MOVE ACC. DATA TO PORT
             CLR EN
             NOP
             LCALL DDELAY
             RET
 ;****************************LCD SUBROUTINES****************************************
        
INIT:           MOV A,#038H ; INITIALIZE, 2-LINES, 5X7 MATRIX.
                LCALL  CMD
                ACALL DDELAY ;INITIAL DELAY 4.1MSEC
                MOV A,#038H ; INITIALIZE, 2-LINES, 5X7 MATRIX.
                LCALL  CMD
                ACALL DDELAY ;
                MOV A,#038H ; INITIALIZE, 2-LINES, 5X7 MATRIX.
                LCALL  CMD
                
                MOV A,#0EH ;  VISIBLE CURSOR ON;
                LCALL  CMD
                MOV A,#01H ; CLEAR LCD SCREEN
                LCALL  CMD
                MOV A,#06H ; SHIFT CURSOR RIGHT
                LCALL  CMD
                RET
                
 ;****************************LCD SUBROUTINES****************************************
               
CLEAR:  MOV A,#01H
        LCALL  CMD
        RET

;****************************LCD SUBROUTINES****************************************
DDELAY:  MOV R5,#41D           
    QT2: MOV R6,#50D
    QT1: DJNZ R6,QT1
         DJNZ R5,QT2                 
         RET
;****************************LCD SUBROUTINES****************************************
PWR_DELAY:                       
          MOV R4,#30D
H2:       MOV R3,#250D
H1:       DJNZ R3,H1
          DJNZ R4,H2
          RET
        


ORG 250H
MSG_1:
DB "THIS IS LINE1 OF LCD",00H
MSG_2:
DB "THIS IS LINE2 OF LCD",00H
MSG_3:
DB "THIS IS LINE3 OF LCD",00H
MSG_4:
DB "THIS IS LINE4 OF LCD",00H


END
 



and here is its working :






Arun
 nischay kumarsumant08 like this.
Sat Sep 26 2009, 04:07 AM
#5


WOW! Arun, thanks for the code and testing.

Sat Sep 26 2009, 12:30 PM
#6
[Topic moved to 8051 Discussion forum]
 sumant08 like this.
Sat Sep 26 2009, 06:24 PM
#7
Thanks....Arun

Get Social

Information

Powered by e107 Forum System

Conversation

Fri Sep 29 2017, 02:45 AM
Maaz
i am doing the same project on verilog please contact me [email protected]
Wed Sep 20 2017, 12:36 AM
Ted
In a missing pulse detector using a 555 timer connected as a monostable vibrator with a PNP transistor,how does the positve input pulse turn on the PNP transistor?
Sun Sep 03 2017, 02:29 PM
martymarty
How do I connect an <NOKIA 1100 LCD > to an atmega328P ?
poojab51296
Sun Aug 20 2017, 10:23 AM
i am intending to interface sd card with STM32F4 and want to write a file in sd card using SPI protocol but using HAL only. Can anyone help me PLEASE!!!!
poojab51296
Sun Aug 20 2017, 10:22 AM
hello
rawat742
Fri Aug 18 2017, 11:37 AM
hi @ angel patel i will attach a file i hope it will be helpfull for you
ExperimenterUK
Mon Aug 14 2017, 09:57 PM
@ angel patel... just log in and post your problem
Mon Aug 14 2017, 01:45 PM
angel patel
hey any one help to make the led scrolling display
desuza6
Sat Jul 29 2017, 07:09 AM
I see the code for step motor h l 298 to rotate 45 degree, but all delay time, if I want to input sensor to h the pulses to stepmotor
rammichael
Thu Jul 27 2017, 12:05 PM
okay fine

Downloads

Comments

bvdb
Wed Oct 18 2017, 01:45 AM
TinkeringJoe
Sun Oct 15 2017, 02:23 AM
Tubai96
Thu Oct 12 2017, 05:30 PM
roberttku
Thu Oct 12 2017, 08:02 AM
Bdavid.sam
Mon Oct 09 2017, 02:23 PM
SUNSHINE
Thu Oct 05 2017, 03:54 AM
Dogg4live77
Wed Oct 04 2017, 01:58 AM
RajeSH190295
Mon Oct 02 2017, 10:08 AM

Online

Guests: 70, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37902
Newest member: bvdb
Forum Activity
bvdb Avatar
Posted By bvdb
Wed Oct 18 2017, 01:50 AM
I purchased the RKitL51 8051 C compiler from Raiso...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Oct 16 2017, 11:44 PM
That looks complicated.Is 8051_BLK a standard 80...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Oct 15 2017, 07:29 PM
According to this, gmail should support POP3.https...
Help Avatar
Posted By Help
Sun Oct 15 2017, 03:21 AM
AT+POP3READ=? +POP3READ: (1-1460) OK AT+POP3READ=...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Oct 14 2017, 08:06 PM
What happens if you ask for the full email ieAT+PO...
Help Avatar
Posted By Help
Sat Oct 14 2017, 02:28 AM
Dear all, AT // OK // 3.1 Bearer profile // Conf...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Oct 12 2017, 01:04 AM
I don't think the 0804 works as it should in Prote...
Bdavid.sam Avatar
Posted By Bdavid.sam
Wed Oct 11 2017, 01:54 AM
Are you simulating in Orcad ?Please post your cod...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Oct 10 2017, 09:43 PM
Are you simulating in Orcad ?Please post your cod...
Bdavid.sam Avatar
Posted By Bdavid.sam
Mon Oct 09 2017, 02:38 PM
Hello, This might be a beginner’s mistake but I a...