Maker Pro
Maker Pro

HD44780 Set Cursor Position Problem

D

Dan Piponi

I'm doing some stuff with a 2x16 HD44780 display. Most things seem to
work fine. I can clear the screen, reset the cursor to the top left,
write characters, set the thing to scroll mode and so on.

But one thing always fails: set the cursor to the start of the second
row. This is supposed to be instruction 0xc0(=0x80+0x40 for 2nd row).
Instead it either does nothing or outputs a space. I don't think it's a
timing issue: my timing loops seem to work fine for other instructions.
Has anyone else seen this problem?

Is there some precondition I need to set before I can start setting the
cursor position - something I need to do during initialisation?

Thanks...
 
T

tim gorman

Dan said:
I'm doing some stuff with a 2x16 HD44780 display. Most things seem to
work fine. I can clear the screen, reset the cursor to the top left,
write characters, set the thing to scroll mode and so on.

But one thing always fails: set the cursor to the start of the second
row. This is supposed to be instruction 0xc0(=0x80+0x40 for 2nd row).
Instead it either does nothing or outputs a space. I don't think it's a
timing issue: my timing loops seem to work fine for other instructions.
Has anyone else seen this problem?

Is there some precondition I need to set before I can start setting the
cursor position - something I need to do during initialisation?

Thanks...

If you can display char's and everything I don't the timing is the problem.

Are you sure the LCD is good? Do you have a spare you could try? Be a real
irritation to find out the LCD has a bad char in the second row, 1st
position!

Tim
 
D

Dan Piponi

I know the LCD itself is good as I now have a workaround: I notice that
if you print 40 characters on the first line you wrap and start on the
second row. So I can get to the second row by sending 24 padding
characters after filling row 1. Not entirely satisfactory but it'll
have to do. Seems bizarre I can get every function to work but one! I
did have a hunch that maybe I was accidentally masking the top bit of
the instruction in my code (as every other instruction I use <0x80) but
after checking my code I don't think that's it.
 
D

Dennis

Dan said:
I know the LCD itself is good as I now have a workaround: I notice that
if you print 40 characters on the first line you wrap and start on the
second row. So I can get to the second row by sending 24 padding
characters after filling row 1. Not entirely satisfactory but it'll
have to do. Seems bizarre I can get every function to work but one! I
did have a hunch that maybe I was accidentally masking the top bit of
the instruction in my code (as every other instruction I use <0x80) but
after checking my code I don't think that's it.

Did you init it to 2 line mode when you set it up? If you don't do a
Function Set command the default is 8 bit interface, 1 line, 5x8
characters. Single line mode is 80 bytes linear addressing. Two line
mode splits the addressing to line 1 at offset 0, and line 2 starting at
offset x'40'
 
D

Dan Piponi

That sounds exactly like what I must be doing wrong. But how do I set
to two line mode? I can't see anything about 2 line mode in the hd44780
docs I can find on the web.
 
D

Dennis

Dan said:
That sounds exactly like what I must be doing wrong. But how do I set
to two line mode? I can't see anything about 2 line mode in the hd44780
docs I can find on the web.
Look for the Function Set command 001DNFxx
D - interface data length 1 = 8 bit, 0 = 4 bit
N - number of lines 1 = 2 lines, 0 = 1 line
F - font 1 = 5x10, 0 = 5x8
xx - don't care

Default is 00100000

you want 00110000 (0x30)
 
D

Dan Piponi

Dennis said:
Default is 00100000
you want 00110000 (0x30)

This doesn't seem quite right. To get two line mode I need N=1. And I'm
not sure if D should be 0 or 1. Anyway, 0x20, 0x28, 0x30 and 0x38 all
fail to make the command to write to line 2 work. Looks like I'm just
going to have to go with my workaround of writing padding characters.
 
Top