1. BrendanCarroll

    Thread Starter New Member

    Jan 20, 2009
    8
    0
    Hello all
    I cannot write text to the second line of a 2 x 40 LCD. Does anyone have a working example or help on this issue. I am using an 8051 microcontroller and an LM108L (HD44780)LCD.
    I am writing the code in assembly.
    I have attached my code and any help would be greatly appreciated.
    HELP
    Thanks all

    Brendan
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
  3. BrendanCarroll

    Thread Starter New Member

    Jan 20, 2009
    8
    0
    I have read through this site and others but still to no avail. I am declaring all variables but still cannot get the cursor onto the second row of the LCD. I have directed the cursor to goto the HEX number corresponding to the second row and again it will not run. Please help. I can forward the code if anyone wishes.

    Thanks again

    Brendan
     
  4. Dutar

    Member

    Jan 27, 2009
    13
    0
    The LCD RAM address for the second line is 0x40. Start from there, and you should be able to write to 2nd line.
     
  5. BrendanCarroll

    Thread Starter New Member

    Jan 20, 2009
    8
    0
    Tried this and also tried to write to other locations on row2 but still no joy.
    Any other suggestions
     
  6. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    A method we use here at work is to declare a 32-byte message (our displays are 2x16), such as "****DISARMED**** READY TO ARM " and send that, letting the display worry about wrap-around. This does lead to "byte-rulers"
    Code ( (Unknown Language)):
    1.  
    2. ;            0123456789ABCDEF0123456789ABCDEF
    3. Msg1: .byte '****DISARMED****  READY TO ARM  '
    4.  
    Note the trailing spaces to wipe any message that was previously on the display.

    --Rich
     
  7. Dutar

    Member

    Jan 27, 2009
    13
    0
    Check your LCD initialization code. Normally DB3 in function set refers to number of lines with 0 for 1 line and 1 for 2 lines

    Hope this would help
     
  8. Dutar

    Member

    Jan 27, 2009
    13
    0
    I checked your code in the attached file and looks like you are setting the 2 line mode. But you seems to be sending function control and display control in a single word. In my case I use 4-bit word mode so I use the sequence:
    LCD_INIT[4] = {0x28, 0x08, 1, 6}
    I send each of them with a 40us gap and it works fine with me. Good luck!
     
  9. BrendanCarroll

    Thread Starter New Member

    Jan 20, 2009
    8
    0
    Hey Dutar I am not 100% sure what you mean. I am using 8 bit word mode and I really don't know what you mean by the following
    LCD_INIT[4] = {0x28, 0x08, 1, 6}
    Would there be any chance I can see the relevant part of your code as I would greatly appreciate it as I do appreciate your replies.
    I have been trying to egt characters onto line 2 for a whole month and its driving me mad so I would be forever grateful for help.

    Many thanks

    Brendan
     
  10. Dutar

    Member

    Jan 27, 2009
    13
    0
    Hey Brendon, that syntax is in C, but anyway you also do the same in your code. I was referring to the function INIT_LCD in your code (it is in page 6 of your attachment). I attached the C code I use with dsPIC (lcd.txt). With dsPIC, TRIS refers to the direction setting register and LATE refers to the data I/O register E. I'm using 4-bit word mode so I'm seding data as nibbles.

    Dushyantha
     
    • lcd.txt
      File size:
      3.2 KB
      Views:
      34
  11. jnvarsha

    New Member

    Jan 21, 2009
    3
    0
    Hi brendan,This is varsha, I read the thread mails between u & dutar. What he is saying is a 4- bit interfacing for data transfer .i also did the same thing for 40x4 LCD but in C. BUT I HAVE A CODE in asm language for 40x4 lcd. so from that u can take just the data transfer part i.e 4 bit interfacing. But for this u need to change the hardware too .U have to use onlt 4 data lines in this case .The other 4 data line ie from DB0-DB3 need not be connected. If its ok with u ,let me know i will send u the code.I am attaching the file in which there is code for data tranfer. I haven't send the whole code. just c if it can help u. But h/w modification is must.
     
  12. BrendanCarroll

    Thread Starter New Member

    Jan 20, 2009
    8
    0
    Hi Varsha,

    Thank you for your reply. I have sorted out the problem that was going on for so long. In my code I declared it was a 2 line LCD but I was supposed to declare this twice (once for each line). Thankfully it is working well and I would like to say thanks again to yourself and Dutar who replied to my mail.

    Brendan
     
Loading...