MicroController Pros Home Page My Account  Cart Contents  Checkout  

****Note: We no longer process and ship international orders. Only orders from USA and Canada are now accepted.****
You can place international orders for our products on E-Bay. Just copy the item's title description from our website and paste it into the search box on E-Bay and place your order there.

  Store » PCAM+ 8051 Tutorial 6 My Account  |  Cart Contents  |  Checkout   
Quick Find
 
Enter keywords to find the product you are looking for in the Quick Find field above

or use
Advanced Search
Categories
Accessory Boards->
8051->
ADI Blackfin
Arduino->
ARM->
Atmel AVR->
Cypress PSoC
Freescale->
FTDI->
Locktronics
Microchip PIC->
MIPS
Parallax->
Renesas
Silicon Labs
ST Microelectronics->
Texas Instruments->
Tibbo->
Books->
Displays->
E-Blocks->
EEPROM/EPROM/FLASH
Embedded Ethernet->
Embedded Software->
I/O Modules->
Parts & Components->
Pick & Place Tools
Programmable Logic (PLD)
Prototype PCBs->
Robotics
ROM/Flash Emulators
Test & Measurement->
Tutorial Software
Universal Programmers->
Wireless->
Information
Intro to Embedded Tools
Embedded News Digest
Useful Resources
Shipping & Returns
Warranty & Liability
Privacy Notice
Conditions of Use
Contact Us
PCAM+ 8051 Tutorial 6: Scrolling LCD Text

Back to PCAM+ page.


Back to Chapter 5

Scrolling LCD Text with the 89S52 Microcontroller

This chapter further explains interfacing the LCD with the 89S52 microcontroller using assembly syntax. Now, we'll make the text scroll left and right.

Let's start with the connections. First, mount the LCD onto the PCAM+ board. Next, use the single-pin connecting wires to make following connections:

  • Connect P0 of the 89S52 (all 8 pins in sequence from 0 to 7) to the LCD section's 0 through 7 pins. See the marking near the LCD pins for identification.
  • Connect P2.0 to RS pin of LCD section.
  • Connect P2.1 to RW pin of LCD section.
  • Connect P2.2 to EN pin of LCD section.

Write the following program using 8051IDE:

EN      EQU     P2.2    ;change as per your connections
RS      EQU     P2.0    ;change as per your connections
RW      EQU     P2.1    ;change as per your connections
PDATA   EQU     P0      ;change as per your connections

START:
        LCALL INIT_LCD
        LCALL CLEAR_LCD
        LCALL PRINT_MESSAGE

END_LESS_LOOP:
        LCALL ROTATE_LEFT
        LCALL ROTATE_LEFT
        LCALL ROTATE_LEFT
        LCALL ROTATE_LEFT
        LCALL ROTATE_RIGHT
        LCALL ROTATE_RIGHT
        LCALL ROTATE_RIGHT
        LCALL ROTATE_RIGHT
SJMP END_LESS_LOOP

INIT_LCD:
        CLR RS
        MOV PDATA,#00110100b
        SETB EN
        CLR EN
        LCALL WAIT_LCD

        CLR RS
        MOV PDATA,#00111100b
        SETB EN
        CLR EN
        LCALL WAIT_LCD

        CLR RS
        MOV PDATA,#0Ch
        SETB EN
        CLR EN
        LCALL WAIT_LCD

        CLR RS
        MOV PDATA,#06h
        SETB EN
        CLR EN
        LCALL WAIT_LCD
RET

;NOTE: Copy character to be displayed in A
WRITE_TEXT:
        SETB RS
        MOV PDATA,A
        SETB EN
        CLR EN
        LCALL WAIT_LCD
RET

CLEAR_LCD:
        CLR RS
        MOV PDATA,#01h
        SETB EN
        CLR EN
        LCALL WAIT_LCD
RET

WAIT_LCD:
        CLR EN
        CLR RS
        SETB RW
        MOV PDATA,#0FFh
        SETB EN
        MOV A,PDATA
        JB ACC.7,WAIT_LCD
        CLR EN
        CLR RW
RET

PRINT_MESSAGE:
        MOV A,#'E'
        LCALL WRITE_TEXT

        MOV A,#'M'
        LCALL WRITE_TEXT

        MOV A,#'B'
        LCALL WRITE_TEXT

        MOV A,#'E'
        LCALL WRITE_TEXT

        MOV A,#'D'
        LCALL WRITE_TEXT

        MOV A,#'D'
        LCALL WRITE_TEXT

        MOV A,#'E'
        LCALL WRITE_TEXT

        MOV A,#'D'
        LCALL WRITE_TEXT

        MOV A,#'M'
        LCALL WRITE_TEXT

        MOV A,#'A'
        LCALL WRITE_TEXT

        MOV A,#'R'
        LCALL WRITE_TEXT

        MOV A,#'K'
        LCALL WRITE_TEXT

        MOV A,#'E'
        LCALL WRITE_TEXT

        MOV A,#'T'
        LCALL WRITE_TEXT

;This is how to print characters on second line of the LCD

        CLR RS
        MOV PDATA,#0C4h
        SETB EN
        CLR EN
        LCALL WAIT_LCD
        MOV A,#'H'
        LCALL WRITE_TEXT

        CLR RS
        MOV PDATA,#0C5h
        SETB EN
        CLR EN
        LCALL WAIT_LCD
        MOV A,#'E'
        LCALL WRITE_TEXT

        CLR RS
        MOV PDATA,#0C6h
        SETB EN
        CLR EN
        LCALL WAIT_LCD
        MOV A,#'L'
        LCALL WRITE_TEXT

        CLR RS
        MOV PDATA,#0C7h
        SETB EN
        CLR EN
        LCALL WAIT_LCD
        MOV A,#'L'
        LCALL WRITE_TEXT

        CLR RS
        MOV PDATA,#0C8h
        SETB EN
        CLR EN
        LCALL WAIT_LCD
        MOV A,#'O'
        LCALL WRITE_TEXT

        CLR RS
        MOV PDATA,#0C9h
        SETB EN
        CLR EN
        LCALL WAIT_LCD
        MOV A,#'.'
        LCALL WRITE_TEXT

        CLR RS
        MOV PDATA,#0CAh
        SETB EN
        CLR EN
        LCALL WAIT_LCD
        MOV A,#'.'
        LCALL WRITE_TEXT

        CLR RS
        MOV PDATA,#0CBh
        SETB EN
        CLR EN
        LCALL WAIT_LCD
        MOV A,#'.'
        LCALL WRITE_TEXT
RET

ROTATE_RIGHT:
        CLR RS
        MOV PDATA,#1Eh
        SETB EN
        CLR EN
        LCALL WAIT_LCD
        LCALL DELAY
RET

ROTATE_LEFT:
        CLR RS
        MOV PDATA,#18h
        SETB EN
        CLR EN
        LCALL WAIT_LCD
        LCALL DELAY
RET

DELAY:
        MOV R5,#100D
        LOOP1:
                MOV R6,#25D
        LOOP2:
                MOV R7,#100D
        DELAY_LOOP:
                DJNZ R7,$
                DJNZ R6,LOOP2
                DJNZ R5,LOOP1
RET

When assembled and downloaded, this code should display EMBEDDEDMARKET on the first line and HELLO... on the second line as in an earlier chapter, but this time the text scrolls left & right.

Proceed to Chapter 7


Back to PCAM+ page.

Shopping Cart more
0 items
What's New? more
SAMD21 Dev Breakout, Arduino-M0 Compatible, Battery Connector
SAMD21 Dev Breakout, Arduino-M0 Compatible, Battery Connector
US$15.95
Bestsellers
01. 2x5 (10-pin) 0.05" pitch IDC Connector Flat Ribbon Cable, 20cm
02. 2x5 (10-pin) 0.05" pitch IDC Connector Flat Ribbon Cable, 12cm
03. 5-pin Press-Fit Header Strip, Breakaway Pins, 2.54mm Pitch
04. Parallel to USB Adapter: Connect USB printer to LPT port
05. 2x10 (20-pin) 0.1" pitch IDC Connector Flat Ribbon Cable, 15cm
06. 8-pin Press-Fit Header Strip, Breakaway Pins, 2.54mm Pitch
07. USB Universal In-Circuit Programmer PIC AVR ARM MSP 8051 EEPROM
08. 2x5 (10-pin) 0.1" pitch IDC Connector Flat Ribbon Cable, 15cm
09. ARM JTAG Debugger & Programmer, parallel port
10. Power Supply 3-12V DC, U.S. plug, 6 connection tips
Reviews more
I think that this is a very good board if you would like use ..
4 of 5 Stars!
  Tuesday 19 March, 2024   List of all our Products

Copyright © 2003-2017 MicroController Pros LLC
Powered by osCommerce