Hi…
Sorry, I was not clear in stating my problem.
Infact, I am confused with screen & cursor shift also, besides my above problem.
The command for cursor/screen shift is- 000001 I/O S
The data sheet says –
I/O = 1/0: Cursor R/L, Screen L/R
S = 1/0: Shift screen/cursor
Now I send 06 or 04 as the command word, & text as “Hello” starting from address 87H, then ‘H’ is displayed at 87H, ‘e’ at 88H & so on till ‘o’ at 8BH. The display is the same whether I send command word as 06 or 04.
On the other hand, if I send command word as 07 or 05 (result same for both), ‘o’ is displayed at 86H, ‘l’ at 85H & so on till ‘H’ at 82H. Thus it progressively moves in the left direction, if address is 87H, as each character is sent. Note that when I send first ‘H’ to 87H in this left shift mode, it is displayed at a previous address, i.e. 86H & then it progressively shifts left, as I send ‘e’,’l’,’l’,’o’.
06,04 = right shift
05,07=left shift
Since I wanted to make a scrolling display (like marquee in html), I sent the string ‘Hello’ at address 90H, so that it starts shifting left from address 8Fh. And I am using a sufficient delay between sending two characters, to give the impression of movement. This worked fine as long as my string was short like ‘Hello’.
But when I sent – “Hello, How r u? I am fine here” – Note that ‘n’ in ‘fine’ is the 24th character. So it does the scrolling in the first line as expected upto ‘n’. But the character ‘e’ starts in the second line.
So ultimately the final display looks as shown (last 16 characters present at any instant)
? I am fin
_______e here
(Discard the underscore, it is just to push ‘e here’ after ‘fine’).
Here is the code that I am using –
RS equ P1.2
RW equ P1.1
E equ P1.0
FLAG equ P2.7
DATAPRT equ P2
lcd:
mov A,#38h
acall Command
mov A,#0Ch
acall Command
mov A,#07
acall Command
mov A,#01h
acall Command
mov A,#90h
acall Command
;Display starts here
mov dptr,#Character
Back2:
clr A
movc A,@A+dptr
jz Here
acall Display
inc dptr
sjmp Back2
here:
sjmp here
Command:
acall Ready
clr E
mov DATAPRT,A
clr RS
clr RW
setb E
clr E
ret
Display:
acall Ready
clr E
mov DATAPRT,A
setb RS
clr RW
setb E
clr E
acall Delay
ret
Ready:
push A
clr A
clr E
setb RW
clr RS
mov DATAPRT,#0FFh
Wait:
setb E
clr E
dec A
jz Out
jb FLAG,Wait
Out:
pop A
ret
Delay:
mov R2,#02h
again2:
mov R0,#0FFh
again1:
nop
mov R1,#0FFh
back1:
djnz R1,back1
djnz R0,again1
djnz R2,again2
ret
Character:
db 'Hello, How r u? I am fine here',0
end
Sorry for such a long post. Please do spare time to read & answer my doubt.
Thanks a lot...