# Intel 8085 microprocessor

#### vincent19-mas

Joined Dec 27, 2012
83
Hey guys,

I will be doing a project using this microprocessor.

My title is Temperature sensor using ADC 0804 and display it in a LCD.

So, I have tried to interface the LCD with 8 bit mode of operation with the following coding :
Rich (BB code):
CPU "8085.TBL"
ORG 2000H
LXI SP,3FF0H

MVI A,80H
OUT 83H

MVI A,38H
CALL WR_CMD
MVI A,38H
CALL WR_CMD
MVI A,38H
CALL WR_CMD
MVI A,0CH
CALL WR_CMD
MVI A,06H
CALL WR_CMD
MVI A,80H
CALL WR_CMD
LXI H,MSG_LINE1

LINE1: MOV A,M
CPI 0
JZ NEXT_LINE
CALL WR_CHAR
INX H
JMP LINE1

NEXT_LINE: MVI A,0C0H
CALL WR_CMD
LXI H,MSG_LINE2

LINE2: MOV A,M
CPI 0
JZ EXIT
CALL WR_CHAR
INX H
JMP LINE2
EXIT: RST 1

WR_CMD: OUT 80H
MVI A,00000100B
OUT 82H
MVI A,00000000b
OUT 82H
CALL DELAY2
RET

WR_CHAR: OUT 80H
MVI A,00000101B
OUT 82H
MVI A,00000001B
OUT 82H
CALL DELaY1
RET

DELAY1: MVI C,40
LOOP_1: DCR C
JNZ LOOP_1
RET

DELAY2: MVI C,255
LOOP_2: DCR C
JNZ LOOP_2
RET

MSG_LINE1: DFB "8085 DEVELOPMENT",0
MSG_LINE2: DFB "SYSTEM-KUKUM",0
END
The output of this code that dispay on the LCD is :
8085 DEVELOPMENT
SYSTEM-KUKUM

Now, because 8255 PPI IC have only Port A, B and C each 8 ports respectively, I might be suffer from insufficient IO pins to be used. So I plan to interface the LCD with only 4 bit.

Anyone knows how am I able to interface a 2x16 LCD(controller: HD47780) using 4 bit mode ?

Thanks and appreciate your help !

#### MrChips

Joined Oct 2, 2009
21,682
Yes. Most people do it this way. It is explained in the data sheet.

#### t06afre

Joined May 11, 2009
5,934
A thing that strike me. Is that it is much simpler to interface both the LCD and the ADC directly to the CPU using a memory or IO mapped approach. If you use some kind of premade 8085 development board. I guess using the IO mapped approach will be preferable. Do you have to use the 8255 for device interface? In any way it would be helpful to see a drawing on how you plan to interface the LCD and ADC

#### vincent19-mas

Joined Dec 27, 2012
83
A thing that strike me. Is that it is much simpler to interface both the LCD and the ADC directly to the CPU using a memory or IO mapped approach. If you use some kind of premade 8085 development board. I guess using the IO mapped approach will be preferable. Do you have to use the 8255 for device interface? In any way it would be helpful to see a drawing on how you plan to interface the LCD and ADC
Suggested ways of interface

I plan to just connect 4 pins of Data pins of LCD so that I will have more ports to be used

Any guidance ?

Thanks!

#### Attachments

• 47.7 KB Views: 77

#### vincent19-mas

Joined Dec 27, 2012
83
Well, Thanks!

Just to ask, besides the initialization part that I should change, probably change the 38H to 20H for 5x7 dot matrix 2x16 LCD , what else should I change ?

Thanks!

#### t06afre

Joined May 11, 2009
5,934
Well, Thanks!

Just to ask, besides the initialization part that I should change, probably change the 38H to 20H for 5x7 dot matrix 2x16 LCD , what else should I change ? Thanks!
Can you be more specific on where the change from 38H to 20H is in the process.

#### vincent19-mas

Joined Dec 27, 2012
83
Can you be more specific on where the change from 38H to 20H is in the process.
This is the initialization for 8 bit mode where 38H is used.
How about when in 4 bit mode ?

Thanks !

#### Attachments

• 42.8 KB Views: 50
• 48.5 KB Views: 43

#### t06afre

Joined May 11, 2009
5,934
This is the initialization for 8 bit mode where 38H is used.
How about when in 4 bit mode ?

Thanks !
yes I see. Take a look at this PDF. It show how to do the correct 4 bit mode setting. Note the timing. Also it is only after the 4. command that you need to write 2x4 bits

#### Attachments

• 175.7 KB Views: 25
Last edited:

#### vincent19-mas

Joined Dec 27, 2012
83
So does that means I convert the 6 bit number to hex ? DB7, BB6,DB5,DB4, RS and E ?

Anyway, when dealing with ADC 0804, I have to convert the temperature sense in analog to digital then convert it to ASCII then display it on a LCD. I am pretty confuse in binary to ASCII conversion. Let say the temperature it sensed is 30 degree celcius. How am I able to display this 30 to the LCD ? Can provide me some example ?

Thanks !

Anyway, do you mind providing more hints/example coding to deal with LCD in 4 bits ?

Thanks !

#### t06afre

Joined May 11, 2009
5,934
RS and E are more like control signal. Given that you only want to write to the LCD the R/W pin can be tied low. Then you have a low to high transition on the E pin The LCD will read the data on the databus. Then you write to the LCD after setting it in 4 bits mode. You write the upper 4 bits data first to D7-D4, then give a low to high transition on E. Then write the lower 4 bits to D7-D4 and give give a low to high to low transition on E.

#### vincent19-mas

Joined Dec 27, 2012
83
Means I need to modify my wor_cmd and wr_char function ??? Thanks

Can you provide me with a simple example ? Thx

#### t06afre

Joined May 11, 2009
5,934
Means I need to modify my wor_cmd and wr_char function ??? Thanks

Can you provide me with a simple example ? Thx
Yes those functions must be changed to fit the four bits mode. As for the example. I can not help much. I did a lot of code on the Z80, but never on the 8085. Was not very fond of 8086 either.

#### vincent19-mas

Joined Dec 27, 2012
83
How about the 38H??? I should change to 20H?? 38H = 0000111000 which the sequence is RS,R/W, DB7, DB6,DB5,...DB1,DB0.it is 10 bit consisting of 8 data bit and 2 control pins.So for 4 bi data mode, how can I define the binary number ??? RS, R/W, DB7, DB6, DB5,DB4 then it is 6 bit binary number ??? Confuse about this..thanks

#### MrChips

Joined Oct 2, 2009
21,682
Here is my initialization for 4-bit mode. Send the following as high nybble, low nybble:

0x28
0x28
0x06
0x0C
0x10

#### vincent19-mas

Joined Dec 27, 2012
83
So for the wr_char and wr_cmd function , I have to mask lower and upper bit ?

#### vincent19-mas

Joined Dec 27, 2012
83
Here is my initialization for 4-bit mode. Send the following as high nybble, low nybble:

0x28
0x28
0x06
0x0C
0x10
I am not sure how to change the wr_cmd and wr_char function. Any advice ?

Thanks !

#### t06afre

Joined May 11, 2009
5,934
You could also put the LCD and the ADC on the same port. Then use the E(LCD) and CS(ADC) lines to control which device that is accessed on the common port

#### vincent19-mas

Joined Dec 27, 2012
83
You could also put the LCD and the ADC on the same port. Then use the E(LCD) and CS(ADC) lines to control which device that is accessed on the common port
How can I do that ?

Thanks !

#### vincent19-mas

Joined Dec 27, 2012
83
Here is my initialization for 4-bit mode. Send the following as high nybble, low nybble:

0x28
0x28
0x06
0x0C
0x10
How do I send it as high nybble and low nybble ?

I am pretty stuck in this!