EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Topics / assembly code for Lcd display

assembly code for Lcd display

|

Microcontroller › 8051 › assembly code for Lcd display

  • This topic has 6 replies, 3 voices, and was last updated 8 years, 5 months ago by ved.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • March 16, 2014 at 5:07 am #2948
    ved
    Participant

    I have  assembly code for lcd display I want to display letter on lcd (keil compiler )but letters are not scrolling.
    code is here
         ORG 0H
    MOV A,#38H ;INIT. LCD 2 LINES, 5X7 MATRIX
    ACALL COMNWRT ;call command subroutine
    ACALL DELAY ;give LCD some time
    MOV A,#0EH ;display on, cursor on
    ACALL COMNWRT ;call command subroutine
    ACALL DELAY ;give LCD some time
    MOV A,#01 ;clear LCD
    ACALL COMNWRT ;call command subroutine
    ACALL DELAY ;give LCD some time
    MOV A,#06H ;shift cursor right
    ACALL COMNWRT ;call command subroutine
    ACALL DELAY ;give LCD some time
    MOV A,#84H ;cursor at line 1, pos. 4
    ACALL COMNWRT ;call command subroutine
    ACALL DELAY
    MOV A,#18H
    ACALL COMNWRT
    ACALL DELAY ;give LCD some time
    MOV A,#’J’ ;display letter J
    ACALL DATAWRT ;call display subroutine
    ACALL DELAY ;give LCD some time
    MOV A,#’D’ ;display letter D
    ACALL DATAWRT ;call display subroutine
    AGAIN: SJMP AGAIN ;stay here
    COMNWRT: ;send command to LCD
    MOV P1,A ;copy reg A to port 1
    CLR P2.0 ;RS=0 for command
    CLR P2.1 ;R/W=0 for write
    SETB P2.2 ;E=1 for high pulse
    ACALL DELAY ;give LCD some time
    CLR P2.2 ;E=0 for H-to-L pulse
    RET
    DATAWRT: ;write data to LCD
    MOV P1,A ;copy reg A to port 1
    SETB P2.0 ;RS=1 for data
    CLR P2.1 ;R/W=0 for write
    SETB P2.2 ;E=1 for high pulse
    ACALL DELAY ;give LCD some time
    CLR P2.2 ;E=0 for H-to-L pulse
    RET
    DELAY: MOV R3,#50 ;50 or higher for fast CPUs
    HERE2: MOV R4,#255 ;R4 = 255
    HERE: DJNZ R4,HERE ;stay until R4 becomes 0
    DJNZ R3,HERE2
    RET
    END

    March 17, 2014 at 3:03 am #11311
    Ashutosh Bhatt
    Participant

    ur code seems to be correct. check out for ur hardware connections

    March 17, 2014 at 4:30 am #11312
    ved
    Participant

    I know my code is correct but I want some massage scrolling all time how to do?

    March 17, 2014 at 6:54 am #11313
    Ashutosh Bhatt
    Participant

    use command to shift entire display left or right in continuous loop

    March 17, 2014 at 1:31 pm #11319
    ved
    Participant

    I don’t know how to create continous loop

    March 18, 2014 at 3:01 am #11321
    SHAH DISHANT H.
    Participant

    Hi,

     

    For scrolling you have to give command 0x18 and you have given that also.

    But you have to give this command after you have displayed data. here you are giving command before displaying data.

     

    Correct this and it will work for sure.

     

    All the ebst.

    March 18, 2014 at 6:22 am #11324
    ved
    Participant

    you mean this code

                                     ORG 0H
    MOV A,#38H ;INIT. LCD 2 LINES, 5X7 MATRIX
    ACALL COMNWRT ;call command subroutine
    ACALL DELAY ;give LCD some time
    MOV A,#0EH ;display on, cursor on
    ACALL COMNWRT ;call command subroutine
    ACALL DELAY ;give LCD some time
    MOV A,#01 ;clear LCD
    ACALL COMNWRT ;call command subroutine
    ACALL DELAY ;give LCD some time
    MOV A,#06H ;shift cursor right
    ACALL COMNWRT ;call command subroutine
    ACALL DELAY ;give LCD some time
    MOV A,#84H ;cursor at line 1, pos. 4
    ACALL COMNWRT ;call command subroutine
    ACALL DELAY

    MOV A,#’J’ ;display letter J
    ACALL DATAWRT ;call display subroutine
    ACALL DELAY ;give LCD some time
    MOV A,#’D’ ;display letter D
    ACALL DATAWRT ;call display subroutine
    MOV A,#18H
    ACALL COMNWRT
    ACALL DELAY ;give LCD some time
    AGAIN: SJMP AGAIN ;stay here
    COMNWRT: ;send command to LCD
    MOV P1,A ;copy reg A to port 1
    CLR P2.0 ;RS=0 for command
    CLR P2.1 ;R/W=0 for write
    SETB P2.2 ;E=1 for high pulse
    ACALL DELAY ;give LCD some time
    CLR P2.2 ;E=0 for H-to-L pulse
    RET
    DATAWRT: ;write data to LCD
    MOV P1,A ;copy reg A to port 1
    SETB P2.0 ;RS=1 for data
    CLR P2.1 ;R/W=0 for write
    SETB P2.2 ;E=1 for high pulse
    ACALL DELAY ;give LCD some time
    CLR P2.2 ;E=0 for H-to-L pulse
    RET
    DELAY: MOV R3,#50 ;50 or higher for fast CPUs
    HERE2: MOV R4,#255 ;R4 = 255
    HERE: DJNZ R4,HERE ;stay until R4 becomes 0
    DJNZ R3,HERE2
    RET
    END

    I tried but letters are not scrolling all time

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • How to power up two stereo audio amplifiers from a single source of power supply August 16, 2022
  • Need help for diy ups project August 16, 2022
  • Is there a discord for this forum? August 16, 2022
  • cadence transient and pss simulation August 16, 2022
  • Digital Display Information August 16, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools