CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

LCD Addressing Problems

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

LCD Addressing Problems
PostPosted: Mon Jan 29, 2007 4:07 pm     Reply with quote

Hello All,

I'm fighting with an Okaya RC2004D LCD. The one page datasheet says it has a HD66712U controller... but I'm not so sure.

I've tried PCM's Flex LCD420 driver and neither addressing scheme generates text in the proper places.

I use the following code to test the placement:
Code:

      lcd_gotoxy(1,1);
      printf(lcd_putc, "12345678901234567890");

      lcd_gotoxy(1,2);
      printf(lcd_putc, "abcdefghijklmnopqrst");

      lcd_gotoxy(1,3);
      printf(lcd_putc, "!@#$}^&*()+=;:<>?[]{");

      lcd_gotoxy(1,4);
      printf(lcd_putc, "ABCDEFGHIJKLMNOPQRST");


With the addressing for 'most' LCDs I end up with:
Code:

12345678901234567890
34567890!@#$}^&*()+=
abcdefghijklmnopqrst
mnopqrstABCDEFGHIJKL


When I use the addressing for the 66712, I end up with:

Code:

IJKLMNOPQRST34567890
34567890
!@#$}^&*()+=;:<>?[]{
;:<>?[]{


Any help would be appreciated.

Thanks,

John
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Mon Jan 29, 2007 4:51 pm     Reply with quote

UPDATE:

I don't think it's an addressing problem. Anything after the 13th character gets repeated on line 2? So I'm not sure where to go from here. (That's with the 66712 addressing... I'm going to try the other in just a minute....)

John
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 29, 2007 5:06 pm     Reply with quote

The data sheet on the Okaya site is very limited.

The way I would try to solve this is to do a web search for other drivers
for this LCD or the HD66712 controller. Quite often there is a Linux
driver available. I did a quick check and some of the drivers do
mention an alternate memory map. I don't have time to look at it
right at the moment but I could do so later tonight, if you or someone
else hasn't solved it already.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Mon Jan 29, 2007 5:25 pm     Reply with quote

Thanks PCM, I'd really appreciate that.

I've figured out that that:

1,1 = 0x00

1,2 = 0x40

But anything above 12 or 0x0C gets put at the right spot on line 1 but also gets repeated starting on line 2!?

John

EDIT:

Here is the datasheet:

http://www.lcd-module.de/eng/pdf/zubehoer/hd66712u.pdf

On pdf page 48 they list some commands that enable four line displays. I'm going to work on it some more when I get into the office tonight. But any help from the expert would be much appreciated.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 29, 2007 11:10 pm     Reply with quote

It also might be helpful to do a different test. The program below will
display one line at a time. It clears the screen between lines. This way
we don't have to worry about subsequent lines overwriting previous ones.
I have a short delay of one second in between each line. You might
want to remove the delay and put a call to getc() in there instead, for
each one. This would allow enough time to write down the results for
each line.
Code:

#include <18F452.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000) 

#include "flex_lcd420.c"

//================================
void main()
{
lcd_init();

lcd_putc('\f');     
lcd_gotoxy(1, 1);
lcd_putc("0123456789ABCDEFGHIJ"); 
delay_ms(1000);

lcd_putc('\f');     
lcd_gotoxy(1, 2);
lcd_putc("0123456789ABCDEFGHIJ"); 
delay_ms(1000);
   
lcd_putc('\f');     
lcd_gotoxy(1, 3);
lcd_putc("0123456789ABCDEFGHIJ"); 
delay_ms(1000);

lcd_putc('\f');     
lcd_gotoxy(1, 4);
lcd_putc("0123456789ABCDEFGHIJ"); 
delay_ms(1000);

while(1);
}


You could show the results like this:
Line 1 is displayed as:
Code:

0123456789ABCDEFGHIJ
--------------------
--------------------
--------------------

And then do the same type of drawing for the other three lines.
Show how the LCD appears when each line is written to it.
Of course, show the line number addresses that you were using
for the test.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Tue Jan 30, 2007 1:14 am     Reply with quote

This is just a quickie (from memory), I'm at the office away from all the hardware, etc. I will provide a full, detailed report in the morning.

Line one, using memory 0x00:
Code:

0123456789ABCDEFGHIJ
CDEFGHIJ------------
--------------------
--------------------


It looks like maybe the NW bit needs to be set to enable the 4 line mode? I'll try to figure out how to do that. It looks like it's one of the few commands that needs to have the RE bit high? I'll try to mod the lcd init string and post it for a critique....

Thanks,

John


EDIT:

Okaya sent me a datasheet for the controller. They say it's a 34COM/60SEG:

http://www.trash.net/~luethi/microchip/datasheets/lcd/ks0073.pdf

The LCD data sheet says it's a HD66712. I notice there is a slight difference in the init routines between the two.


Last edited by jecottrell on Tue Jan 30, 2007 3:08 am; edited 1 time in total
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Tue Jan 30, 2007 3:07 am     Reply with quote

OK, I think I'm getting closer but won't be able to try it for a few hours.

Here is a change to the init lcd string that I hope will fix the problem:

Code:

int8 const LCD_INIT_STRING[4] =
{
 0x20 | (lcd_type << 2),  // Set mode: 4-bit, 2+ lines, 5x8 dots
 0xc,                     // Display on
 1,                       // Clear display
 6,                       // Increment cursor
 0b00100100,              // Enable RE (extension register)
 0b00001001,              // Enable four line display mode
 0b00100000               // Disable RE (extension register)
};


Thanks,

John
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Tue Jan 30, 2007 9:40 am     Reply with quote

PCM,

The change to the init string didn't have any result.

Here is the output of you test program:

Code:


0123456789ABCDEFGHIJ
CDEFGHIJ------------
--------------------
--------------------


--------------------
--------------------
89ABCDEFGHIJ--------
--------------------


--------------------
--------------------
0123456789ABCDEFGHIJ
CDEFGHIJ------------


89ABCDEFGHIJ--------
--------------------
--------------------
--------------------


These are in order and addresses for lines 1 through 4 are 0x00, 0x20, 0x40, 0x60.

Thanks,

John
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Tue Jan 30, 2007 10:36 am     Reply with quote

OK, the problem is enabling the four line mode. When I use the following kludged lcd_init modeled after the exact sequence in the datasheet (with the addition of the 3 bytes/6 nibbles to enable four line mode) everything appears to work. If anyone would like to offer some help on making it less ugly, I'd appreciate it. I don't have time to figure out the difference between my previous post and this one and why one worked and the other didn't. But it could be the delay after power-up. The datasheet recommends a healthy 30mS in low power system (2.7V).

Code:

void lcd_init() {
    BYTE i;
    set_tris_lcd(LCD_WRITE);
    lcd.rs = 0;
    lcd.rw = 0;
    lcd.enable = 0;
    delay_ms(40);
    //for(i=1;i<=3;++i) {
       lcd_send_nibble(2);
       delay_ms(5);
       lcd_send_nibble(2);
       delay_ms(5);
       lcd_send_nibble(0x08);   // 0x00 = 1 line, 0x08 = 2 line mode
       delay_ms(5);
       lcd_send_nibble(0);
       delay_ms(5);
       lcd_send_nibble(0x0C);
       delay_ms(5);
       lcd_send_nibble(0);
       delay_ms(5);
       lcd_send_nibble(0x01);   // clear display
       delay_ms(5);
       lcd_send_nibble(0);
       delay_ms(5);
       lcd_send_nibble(6);
       delay_ms(5);
       
       lcd_send_nibble(2);
       delay_ms(5);
       lcd_send_nibble(4);      // enable RE
       delay_ms(5);
       
       lcd_send_nibble(0);
       delay_ms(5);
       lcd_send_nibble(9);      // enable four line mode
       delay_ms(5);
       
       lcd_send_nibble(2);
       delay_ms(5);
       lcd_send_nibble(0);      // disable RE
       delay_ms(5);
       
    //}
    //lcd_send_nibble(2);
    //for(i=0;i<=3;++i)
      // lcd_send_byte(0,LCD_INIT_STRING[i]);
}


Thanks,

John
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group