Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Lcd coding help!!!! Please asap

Status
Not open for further replies.

neargopie

New Member
Hi, I'm pretty new at concepts of microcontrollers. basically i'm trying to write a assembly program for LCD.

I need to write a 8051 program that performs the following tasks:
 When the system power on, the LCD shows the welcoming message
 When the uP8051 receives the first character, the LCD clears up the screen and shows that character.
 If user presses a key (0-9, a-z, A-Z, space) on the keyboard, the LCD shows that character. When the first line of the LCD is full, it shows on the second line automatically. When the second line is full, it clears up the screen and shows the character on the first line.
 When user presses ‘Backspace’, it deletes one character from the LCD. The ‘Backspace’ function is valid until the cursor is at the first position on the first line.
 When user presses ‘Enter’, if the cursor is on the first line, it will go to the second line. If it is on the second line, it will clear up the screen and go to the first line.
 When user presses ‘Esc’, the LCD shows the welcoming message again.

I've done all that i can i just don't know how to fill in for MAIN:, and SERIAL:

code:
; ----- PORT DEFINATION -----
DB0 EQU P2.0
DB1 EQU P2.1
DB2 EQU P2.2
DB3 EQU P2.3
DB4 EQU P2.4
DB5 EQU P2.5
DB6 EQU P2.6
DB7 EQU P2.7
RS EQU P3.2 ; RS Pin
RW EQU P3.3 ; RW Pin
EN EQU P3.4 ; Enable Pin
OUTPUT EQU P2 ; Output Port

; ----- RAM DEFINATION -----
STARTUP EQU 20H
CNT EQU 30H
OFFSET EQU 31H
CURPOS EQU 32H
KEYIN EQU 33H


; ----- PROGRAM START -----
ORG 00H
LJMP MAIN
ORG 23H
LJMP SERIAL

MAIN:
MOV SP, #5FH
; ------- HELLLPPPP-------------------
MOV

; ------- HELPPP-------------------

LCALL INIT ; Subroutine for LCD INITIZATION
LCALL SHOW_STARTUP ; Subroutine for Showing Startup Message
LJMP $

; ----- INITIZATION LCD -----
LCD_INIT:
MOV A, #00111000B ; SET FUNCTION 8 BIT 2 LINE 5*8
LCALL LCD_WINS
MOV A, #00111000B ; SET FUNCTION 8 BIT 2 LINE 5*8
LCALL LCD_WINS
MOV A, #00111000B ; SET FUNCTION 8 BIT 2 LINE 5*8
LCALL LCD_WINS
MOV A, #00111000B ; SET FUNCTION 8 BIT 2 LINE 5*8
LCALL LCD_WINS
MOV A, #00001000B ; DISPLAY OFF
LCALL LCD_WINS
MOV A, #00000001B ; CLEAR DISPLAY
LCALL LCD_WINS
MOV A, #00000110B ; SET ENTRY MODE
LCALL W_INS
MOV A, #00001111B ; DISPLAY ON, CURSOR ON, BLINKING
LCALL W_INS
RET

; ------ LCD_WINS : This Procedure will send the instruction to LCD---------
LCD_WINS:
LCALL CHECK
CLR EN
CLR RS
CLR RW
SETB EN
MOV OUTPUT, A
CLR EN
RET
;---------------------------------------------------------------

; ----- SHOW STARTUP IMAGE -----
SHOW_STARTUP:
SETB STARTUP
MOV A, #10000000B ; SET CURSOR POSITION 00H, LINE 1, POS 1
LCALL LCD_WINS
MOV CNT, #16
MOV DPTR, #MSG0
LCALL LCD_WSTR
MOV A, #11000000B ; SET CURSOR POSITION 40H, LINE 2, POS 2
LCALL LCD_WINS
MOV CNT, #16
MOV DPTR, #MSG1
LCALL LCD_WSTR
RET
; ------------------------------

; ----LCD_WSTR : This Procedure will output the 16 Characters to the LCD ---
LCD_WSTR:
MOV OFFSET, #0
NEXT:
MOV A, OFFSET
MOVC A, @A+DPTR
LCALL LCD_WDATA
INC OFFSET
DJNZ CNT, NEXT
RET
; --------------------------------------------------------------
; ------ LCD_WDATA : This Procedure will send the data to LCD-----------
LCD_WDATA:
LCALL CHECK
CLR EN
SETB RS
CLR RW
SETB EN
MOV OUTPUT, A
CLR EN
RET
;---------------------------------------------------------------

; ----CHECK : This Procedure will CHECK if LCD is BUSY------------------
CHECK:
PUSH ACC
LCD_BUSY:
CLR RS
SETB RW
SETB EN
MOV OUTPUT, #11111111B
MOV A, OUTPUT
CLR EN
JB ACC.7, LCD_BUSY
POP ACC
RET
;---------------------------------------------------------------
**************** INTERRRUPT SERIAL START HERE ****************
; **************** HELP!!!******************

SERIAL:




RETI
; ----------------------------------------------------------------------------------

MSG0: DB ' ELEC254 Project XD '
MSG1: DB ' By: Team 34 '
NULL: DB ' '
END
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top