Character LCD (24x2) not writing to the 2nd line

Discussion in 'The Projects Forum' started by Kaoshae, Jan 18, 2011.

  1. Kaoshae

    Thread Starter New Member

    Jan 18, 2011
    LCD data sheet for reference:

    I have this LCD working, able to print characters to the first row, but the 2nd line refuses to display anything other than the cursor.

    My LCD initialization is the following:

    Code ( (Unknown Language)):
    1.    command(0x30);
    2.    command(0x30);
    3.    command(0x30);
    4.    command(0x38);
    5.    command(0x10);
    6.    command(0x0f);
    7.    command(0x06);
    8.    command(0x01);
    (Where "command" means RS = 1, R/W = 0, and the 0x__ code is DB7~DB0 in hexadecimal)

    When I use
    Code ( (Unknown Language)):
    1.    command(0xc0);
    to move the cursor to position 64 (the first position on the 2nd line), I see the cursor blinking at the start of the second line. If I try to print a string of characters, I see the cursor move along the 2nd row of the display as if it were responding. No characters appear on the 2nd row, even when this exact string prints to the 1st row perfectly.

    I have my code giving the LCD commands at a rate of about 4 commands/second, so timing shouldn't be an issue.

    Does anyone have any idea what could possibly be wrong?
  2. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    No need to go through all of that hassle.

    You will need to adjust your clock speed in delay.h and set your various output pins in lcd,h.

    It is for the C18 compiler but you should be able to adjust for your compiler.

    It uses the 4 bit option on the lcd.

    You should have put this in the embedded forum.
      File size:
      2.5 KB
  3. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    Here is some sample code:

    Code ( (Unknown Language)):
    3.     char string[16];
    4.     LCD_Init();
    6.     sprintf(string,(const far rom char*)"Hello",0);  
    7.     LCD_string(string,1);        
    8.     sprintf(string,(const far rom char*)"World",0);  
    9.     LCD_string(string,2);        

    It is for 16x2 but you can just modify the code.
  4. Kaoshae

    Thread Starter New Member

    Jan 18, 2011
    Thanks... but for the sake of understanding my hardware, does anyone know why it's behaving like this?