Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Microcontroller interfacing with LCD 16x1

Status
Not open for further replies.

IamNew

Newbie level 6
Joined
Dec 7, 2011
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,374
Hi there,

I am doing a microcontroller project which utilizing AT 89S52 and a LCD 16x1. I have problem when trying to display letter of 'N' to the LCD. I could have the display on the LCD display but it only give me the LCD backlight and show me the black boxes. My microcontroller is tested fine.

Below is the codes that I programmed into my microcontroller
Code:
	ORG	0
	MOV	A,#38H;
	ACALL	COMNWRT;
	ACALL	DELAY;
	MOV	A,#0EH;
	ACALL	COMNWRT;
	ACALL	DELAY;
	MOV	A,#01H;
	ACALL	COMNWRT;
	ACALL	DELAY;
	MOV	A,#06H;
	ACALL	COMNWRT;
	ACALL	DELAY;
	MOV	A,#84H;
	ACALL	COMNWRT;
	ACALL	DELAY;
	MOV	A,#'N';
	ACALL	DATAWRT;
	ACALL	DELAY;
AGAIN:	SJMP	AGAIN;
COMNWRT:	MOV	P2,A;
	CLR	P3.0;
	CLR	P3.1;
	SETB	P3.2;
	CLR	P3.2;
	RET
DATAWRT:MOV	P2,A;
	SETB	P3.0;
	CLR	P3.1;
	SETB	P3.2;
	CLR	P3.2;
	RET
DELAY:	MOV	R3,#50;
HERE2:	MOV	R4,#255;
HERE:	DJNZ	R4,HERE;
	DJNZ	R3,HERE2;
	RET
	END

The Schematic of my circuit:
IR_Adc_color_port2.jpg

Please guide me if I am wrong somewhere in the circuit or the code.
 

Attachments

  • IR_Adc_color_port2.jpg
    IR_Adc_color_port2.jpg
    290.6 KB · Views: 103
Last edited:

it simply means that you are not able to initiallise the lcd,,
plz. do read the datasheet of your lcd, the command for the activity to begin is sent more than one time,, i.e. mov a,#38h
so as to properly make the lcd listen to the command...
you may refer other some other posts regarding this topic on the forum too...
 

see this code,this is for 89s52. this code print ABCD and shift it.
you didn't initialize your Ports to which lcd are connected.

ORG 0000H
JMP MAIN
MAIN:
MOV P1,0
CLR P2.0
CLR P2.1
CLR P2.2
ACALL DELAY
ACALL DELAY
MOV A,#0x38
ACALL COMWRT
ACALL DELAY
MOV A,#0x0C
ACALL COMWRT
ACALL DELAY
MOV A,#0x01
ACALL COMWRT
ACALL DELAY
MOV A,#0x85
ACALL COMWRT
ACALL DELAY
MOV A,#'A'
ACALL DATWRT
MOV A,#'B'
ACALL DATWRT
MOV A,#'C'
ACALL DATWRT
MOV A,#'D'
ACALL DATWRT
MOV A,#'E'
ACALL DATWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY

S5:JMP S5

COMWRT:
MOV P1, A
CLR P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET

DATWRT:
MOV P1,A
SETB P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET

DELAY:
MOV R5,#50

WAIT0:
MOV R6,#50

WAIT1:
MOV R7,#100

WAIT2:
DJNZ R7,WAIT2
DJNZ R6,WAIT1
DJNZ R5,WAIT0
RET

END
 

In addition to all above, you may try adding some delay to enable pulse as shown below


DATAWRT:MOV P2,A;
SETB P3.0;
CLR P3.1;
SETB P3.2;
Try adding delay here
CLR P3.2;
RET
 

Hi there,
I do try the code below with compiler asem51:

see this code,this is for 89s52. this code print ABCD and shift it.
you didn't initialize your Ports to which lcd are connected.

ORG 0000H
JMP MAIN
MAIN:
MOV P1,0
CLR P2.0
CLR P2.1
CLR P2.2
ACALL DELAY
ACALL DELAY
MOV A,#0x38
ACALL COMWRT
ACALL DELAY
MOV A,#0x0C
ACALL COMWRT
ACALL DELAY
MOV A,#0x01
ACALL COMWRT
ACALL DELAY
MOV A,#0x85
ACALL COMWRT
ACALL DELAY
MOV A,#'A'
ACALL DATWRT
MOV A,#'B'
ACALL DATWRT
MOV A,#'C'
ACALL DATWRT
MOV A,#'D'
ACALL DATWRT
MOV A,#'E'
ACALL DATWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY
MOV A,#0x1C
ACALL COMWRT
ACALL DELAY

S5:JMP S5

COMWRT:
MOV P1, A
CLR P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET

DATWRT:
MOV P1,A
SETB P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET

DELAY:
MOV R5,#50

WAIT0:
MOV R6,#50

WAIT1:
MOV R7,#100

WAIT2:
DJNZ R7,WAIT2
DJNZ R6,WAIT1
DJNZ R5,WAIT0
RET

END

But I get the errors as below.
Asem51.jpg
 

This code is written in Keil IDE. I don't know which assembler you are using.
 

Referring the code below in relation to hex representation

ORG 0000H
JMP MAIN
MAIN:
MOV P1,0
CLR P2.0
CLR P2.1
CLR P2.2
ACALL DELAY
ACALL DELAY
MOV A,#0x38 change to MOV A,#038H
ACALL COMWRT
ACALL DELAY
MOV A,#0x0C change to MOV A,#0CH

this will resolve most of the errors
the asm51 user manual is attached for reference
A Raoof Khan
 

Attachments

  • asm51.pdf
    300.5 KB · Views: 77

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top