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.

Nokia 3310 LCD interfacing with 8086 using parallel port

Status
Not open for further replies.

Furki316

Newbie level 3
Joined
May 5, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,369
My code is supposed to draw on the LCD screen using the mouse left click, the same concept used in this page.
http://www.scienceprog.com/connect-nokia-3310-lcd-to-lpt-port/
I have studied the 8544 data sheet. The problem is my LCD screen shows nothing.
There is no problem with the connections or the LCD screen per se. Can anyone check if there's a problem with my code with initialization or the procedure for sending data bytes to the 8544 or maybe... the delay. its soo frustrating? thank you for reading my post.



; Program to draw on a nokia 3310 LCD(pcd 8544) using left mouse


.model small
.stack 100h
.data
bank db ? ; Bank number will get stored here from 0 to 5
rbit db ? ; bit number will be stored from 0 to 7
col db ? ; column number from 0h to 54h (0 - 84 decimal)
oldbank db 6 ; previous RAM bank number
oldrbit db 0 ; previous bit number
oldcol db 89 ; previous column number
row db ? ; contains the true address of row (0-48)
msg1 db "Done", 0ah, 0dh, '$'
msg2 db "Connect the LCD and press any key to start!",0ah, 0dh, '$'
msg3 db "Setting Y address.... ", 0dh, 0ah, '$'
msg4 db "Setting X address.... ", 0dh, 0ah, '$'
msg5 db "Resetting 8544....", 0dh, 0ah, '$'
msg6 db "Setting Vop....", 0dh, 0ah, '$'
msg7 db "Clearing RAM...", 0dh, 0ah, '$'
msg8 db "Normal instruction set", 0ah, 0dh, '$'
msg9 db "Sending data byte...", 0ah, 0dh, '$'
msg10 db "Data byte sent", 0ah, 0dh, '$'
msg11 db "Display control set: Normal mode", 0ah, 0dh, '$'
eight db 08
seven db 07
four db 04
.code
main proc
mov ax, @data
mov ds, ax
mov al, 00h
mov dx, 0378h
out dx, al
mov ah, 09h
LEA dx, msg2
int 21h
mov ah, 01h
int 21h
mov ah,09h
LEA dx, msg5
int 21h
mov dx, 0378h

; Reset 8544
mov al, 0E8h
out dx, al
call DelayProc
mov al, 0F8h
out dx, al
call DelayProc


; Extended instruction set
mov cx, 02
loop2:
mov al, 0F0h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
loop loop2
mov al, 0F2h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
mov cx, 04
loop3:
mov al, 0F0h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
loop loop3
mov al, 0F2h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc



mov ah, 09h
LEA dx, msg6
int 21h
mov dx, 0378h

; set Vop
mov al,0F2h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
mov cx, 2
loop4:
mov al, 0f0h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
loop loop4
mov al, 0f2h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
mov cx, 04
loop5:
mov al, 0f0h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
loop loop5

mov ah,09h
LEA dx, msg8
int 21h
mov dx, 0378h

; Normal instruction set
mov cx, 02
loop6:
mov al, 0F0h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
loop loop6
mov al, 0F2h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
mov cx, 05
loop7:
mov al, 0F0h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
loop loop7



mov ah,09h
LEA dx, msg7
int 21h
mov dx, 0378h

CLEAR_RAM:
; Clear RAM
mov cx, 0fC0h ; fc0h = 4032 bits(pixels)
CLRAM:
mov al, 0f4h
out dx, al
call delay
inc al
out dx, al
call delay
loop CLRAM

mov ah,09h
LEA dx, msg11
int 21h

mov cx, 04h
loop111:
mov al, 0F0h ; inverse mode
mov dx, 0378h
out dx, al
call Delayproc
inc al
out dx, al
call DelayProc
loop loop111
mov cx, 02h
loop12:
mov al, 0F2h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
loop loop12
mov al, 0F0h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
mov al, 0F0h
mov dx, 0378h
out dx, al
call Delayproc
inc al
out dx, al
call DelayProc




mov ah,09h
LEA dx, msg1
int 21h

getMouse:
MOV AX,5 ; 5 in AX tells INT 33 to get mouse button info
INT 33h ; get mouse button info
CMP AX,1 ; this compares AX (button status) with 1
JL getMouse
JA exit
mov ax, cx ; move cursor's horizontal position into ax
div seven ; scaling of columns
mov col, al ; store column number
mov ax, dx ; move cursor's vertical position into ax
div four ; scaling of rows
mov row, al ; row contains the true address of row (0-48)
mov ah,00h
div eight ; divide row address by 8 to get bank no. of 8544 RAM.
mov bank, al ; get bank number from al(quotient)
mov rbit, ah ; get bit number from ah(remainder)



mov al, oldcol ; compare with the previous cursor position
cmp col, al
JNZ nomatch
mov al, oldrbit
cmp rbit, al
JNZ nomatch
mov al, oldbank
cmp bank, al
JE getMouse


nomatch:

mov ah,09h
LEA dx, msg3
int 21h


; Set Y address
mov al, 0F0h
mov dx, 0378h ; Start sending command byte to set Y address
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
mov cx, 3
snd3z:
mov al, 0F0h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
Loop snd3z
mov al, bank
SHR al, 1 ; Shift right to get Y2 to position of bit 1(for SDIN)
AND al, 02h ; get 000000Y0
OR al, 0F0h
out dx, al ; send 111100Y(2)0
call DelayProc
inc al
out dx, al
call DelayProc
mov al, bank
AND al, 02h
OR al, 0f0h
out dx, al ; send 111100Y(1)0
call DelayProc
inc al
out dx, al
call DelayProc
mov al, bank
SHL al, 1
AND al, 02
OR al, 0F0h
out dx, al ; send 111100Y(0)0
call DelayProc
inc al
out dx, al
call DelayProc



mov ah,09h
LEA dx, msg4
int 21h
mov dx, 0378h

; Set X address
mov al, 0F2h
out dx, al
call DelayProc
inc al
out dx, al ; send data bit 7(D7) as 1
call DelayProc
mov cx, 05
shftl:
mov al, col ; loop sends X6, X5, X4, X3 and X2
SHR al, cl
AND al, 02h ; 000000X0
OR al, 0F0h
out dx, al
call DelayProc
inc al
out dx, al
call DelayProc
Loop shftl
; get X1
mov al, col
AND al, 02h ; 000000X(1)0
OR al, 0F0h
out dx, al ; send X1
call DelayProc
inc al
out dx, al
call DelayProc

mov al, col
SHL al, 1
AND al, 02h
OR al, 0F0h
out dx, al ; send X0
call DelayProc
inc al
out dx, al
call DelayProc

mov ah, 09h
LEA dx, msg9
int 21h


cmp rbit, 07 ; Process the data byte for sending
mov ax, 07h
JE setRow
cmp rbit, 06
mov ax, 06h
JE setRow
cmp rbit, 05
mov ax, 05h
JE setRow
cmp rbit, 04
mov ax, 04h
JE setRow
cmp rbit, 03
mov ax, 03h
JE setRow
cmp rbit, 02
mov ax, 02h
JE setRow
cmp rbit, 01
mov ax, 01h
JE setRow
cmp rbit, 00
mov ax, 00h
JE setRow



setRow: ; Sending data byte
push ax
mov cx, 7
sub cx, ax
mov dx, 0378h
cmp ax, 07h
JE MSB1
snd0:
mov dx, 0378h
mov al, 0f4h ; send "0" bit to SDIN and 0 to clck
out dx, al
call DelayProc ; CHECK THROUGH DELAY
mov al, 0f5h
out dx, al ; "0" bit is clocked in on positive egde of clck(i.e when it goes 1)
call DelayProc ; CHECK THROUGH DELAY
Loop snd0
MSB1:
mov al, 0f6h
out dx, al ; "1" bit data with 0 clock
call DelayProc ; CHECK THROUGH DELAY
inc al
out dx, al ; "1" bit data is clocked in on the positive edge(when clock goes high)
call DelayProc
pop cx ; pop into cx what was pushed out of ax(the number of 0s after 1)
cmp cx, 00h
JE LSB1
snd0_2:
mov dx, 0378h
mov al, 0f4h
out dx, al
call DelayProc
inc al
out dx, al
Call DelayProc
Loop snd0_2
LSB1: ; code after sending last bit
mov ah,09h
LEA dx, msg10
int 21h
mov al, col ; save cursor's position (columns and rows) for comparison
mov oldcol, al
mov al, bank
mov oldbank, al
mov al, rbit
mov oldrbit, al
JMP getMouse ; sense for another mouse click
exit: ; Clear RAM and exit
mov ah, 09h
LEA dx, msg7
int 21h
mov cx, 0fC0h ; fc0h = 4032 bits(pixels)
mov dx, 0378h
CLERAM:
mov al, 0f4h
out dx, al
call delay
inc al
out dx, al
call delay
loop CLERAM

MOV AH,4Ch
INT 21h
main endp




DelayProc proc near
push dx
push cx
push ax
mov cx, 30 ; delay time 1(decimal) equals 14ms, 70(decimal) equals 1 second
mov dx,3dah
loop11:
push cx
l1:
in al,dx
and al,08h
jnz l1
l2:
in al,dx
and al,08h
jz l2
pop cx
loop loop11
pop ax
pop cx
pop dx
ret
DelayProc endp


delay proc near
push cx
mov cx, 03 ;1 in decimal is 0.7ms
dlay0:
push cx
mov cx, 0ffffh
dlay:
mov bx, 0fh
dlay2:
dec bx
cmp bx, 00h
JNZ dlay2
loop dlay
pop cx
loop dlay0
pop cx
ret
delay endp
end main
 

This is urgent. I'm sure the problem is very simple..perhaps with setting Vop. I just cant figure out whats wrong with the code. I read and followed the 8544 manual.

Can I get some simple assembly language(x86) code to display a dot or a letter on the LCD? maybe then I'll figure out whats wrong with my code. ANY help is appreciated.

Regards,
Furki
 

It is little bit difficulty to trace your ASM code.

Anyway did you check the LPT (parallel port) output, I mean write a small ASM program to check this first to verify it.

And other thing is, any operating system if you used?
 

Thank you very much for replying.

I wish I could simplify it by writing and calling different procedures but I cant rewrite it because I have very little time.

Heres how I send a data byte 00011111 (D1 of parallel port is connected to SDIN and D0 is connected to SCLK). underlined bit is SDIN
mov al, 0f4h ;11110100
mov dx, 0378h
out dx, al ;vdd vdd vdd res sce d/c sdin sclk 11110100
call DelayProc ; a delay of 42ms( I vary it)
inc al ; LSB goes 1 11110101
out dx, al ;SCLK(LSB) goes 1. MSB of data byte is clocked in
call DelayProc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is how I send the first bit 0(MSB). When SCLK goes from low to high, data bit gets in.
I used a similar procedure to send the remaining seven bits. Is this code good?



I did check the parallel port. I checked the voltages by my own code and ran some .exe file to check the LCD screen connected to parallel port. It was ok.

I am using Windows XP Pro.
 

If you are trying to do this on a Windows XP platform, it won't work as you expected.

Did you try this code in DOS?

If you wish to test your hardware modules on Windows XP platform, then you may follow the link below

#1240768

regards
bassa
 

I've tried it in command prompt. I run Userport.exe while running my code so I can access parallel port. I also checked the voltages through a voltmeter, my code changes pin voltages from low to high and vice versa just fine.
 

Anyway You may try to decode the pascal program in your reference design

here some example for "procedure lcd reset"

Code:
mov al,0xe8
mov dx, 0x378
out dx,al
call DelayProc
mov al, 0xf8
out dx,al
call DelayProc

and relevant pascal code as below according to the reference given
Code:
lcd_rst;
lcd_wrbyte_c($21);
lcd_wrbyte_c($04+(0 and $03));
lcd_wrbyte_c($10+(0 and $07));
lcd_wrbyte_c($80+(0 and $7F));
lcd_wrbyte_c($20);

lcd_wrbyte_c($80+(10 and $7F));
lcd_wrbyte_c($40+(1 and $3F));
lcd_wrbyte_c($0C);


lcd_redraw;

for i:=0 to 40 do
lcd_setpix(i,i);

repeat
reg.ax:=3;
intr($33,reg);
mb:=reg.bx;
mx:=reg.cx div 8;
my:=reg.dx div 8;
if (mx<>mx_old) or (my<>my_old) then begin
lcd_invpix(mx_old,my_old);
lcd_invpix(mx,my);
mx_old:=mx;
my_old:=my;
end;

if (mb and $02>0) then lcd_setpix(mx,my);
if (mb and $01>0) then lcd_clrpix(mx,my);

until xkeypr;


hope your comments

regards
bassa
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top