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 support@ccsinfo.com

DIP204-4x LCD DISPLAY with KS0073 chipset

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
benoitstjean



Joined: 30 Oct 2007
Posts: 299
Location: Ottawa, Ontario, Canada

View user's profile Send private message

DIP204-4x LCD DISPLAY with KS0073 chipset
PostPosted: Thu Apr 05, 2012 7:27 am     Reply with quote

This is not a reply to other posts related to the DIP204-4x LCD displays but rather a confirmation of *working* code. After finding a very few posts regarding this specific LCD display, each post had a few bits of code where the author said "this works" but more tailoring had to be done. So, below is exactly the code I added/changed in the original lcd.c file:

For the first line below, find the original <BYTE const LCD_INIT_STRING> line and change it to this:
Code:

BYTE const LCD_INIT_STRING[7] = {0x20,0x24,0x9,0x28,0xf,0x1,0x6};

If this line is not changed, what will happen is that whatever is written on the LCD's first line will partially appear on the following line.

Next, the code was taken from another post, is a bit ugly but who cares, it works. So, change the original <void lcd_init()> function to this code:
Code:

void lcd_init()
{
    BYTE i;
    set_tris_lcd(LCD_WRITE);
    lcd.rs = 0;
    lcd.rw = 0;
    lcd.enable = 0;

    delay_ms(40);

    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);
}       

Last, the lcd_gotoxy( x, y ) function is the one causing the issue. The original driver expects to see the COLUMN number to be anything between 1 and 40 and line Y as either 1 or 2. But the KS0073 chipset doesn't like that. Therefore, the true addressing of the DIP204 LCD is really a single line (Y = 1 ) and the characters are:

Line 1: 1-20
Line 2: 33-52
Line 3: 65-84
Line 4: 97-116

So, change the <void lcd_gotoxy( BYTE x, BYTE y )> function to this:
Code:

void lcd_gotoxy( BYTE Col, BYTE Line )
{
   BYTE address;

   if(( Col >= 1 && Col <= 20 ) && Line == 2 )
   {                                             
      Col += 32;
      Line = 1;                                     
   }
   else
   {
      if(( Col >= 21 && Col <= 40 ) && Line == 1 )
      {
         Col += 44;
      }
      else
      {                         
         if(( Col >= 21 && Col <= 40 ) && Line == 2 )
         {
            Col += 76;                                         
            Line = 1;
         }
      }
   }

   if( Line != 1 )
   {
      address = lcd_line_two; //0x40
   }
   else
   {
      address = 0;
   }
   
   address += Col - 1;
   
   lcd_send_byte( 0, 0x80 | address );
}

So, now, you can keep all your original code with, for example, lcd_gotoxy (15, 2) and the function will translate it to the proper position for that particular LCD display.

I suggest you make a copy of your original LCD.C file and rename it to something like LCD_DIP204-4.c then make the changes so you have an LCD driver for the Hitachi HD44780 chipset along with a driver for the KS0073 chipset.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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