Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/04/05 18:34
Read: times


 
#92922 - Code for the LCD
Responding to: ???'s previous message
Hi Prahalad,
    The LCD connections are like this:

Port 1.0 - LCD D0
...
Port 1.7 - LCD D7
Port 0.0 - RS
Port 0.1 - R/W
Port 0.2 - EN

I have also pulled up Port zero using 4.7KOhm resistor network. The Microcontroller is 89c51, @12MHz.

I studied the LCD tutorial in this forum, but I am having a doubt. The initialisation code is given like this:

INIT_LCD:
    CLR RS
    MOV DATA,#38h
    SETB EN
    CLR EN
    LCALL WAIT_LCD
    CLR RS
    MOV DATA,#0Eh
    SETB EN
    CLR EN
    LCALL WAIT_LCD
    CLR RS
    MOV DATA,#06h
    SETB EN
    CLR EN
    LCALL WAIT_LCD
    RET

Well, The all these commands are to be written to LCD. If so, should not we bring R/W line low? Even in the whole program given in final paragraphs of the turorial, the program sequence goes like this:

start:
    LCALL INIT_LCD
    LCALL CLEAR_LCD
    (character sending..)


Both INIT_LCD and CLEAR_LCD routines leave RW pin untouched. If so, as they are externally pulled high and ports will FFh upon reset, I reckon RW line will be high while these two routines do their job. Is this procedure correct? ( I am asking this doubt to everyone, not only to Prahalad !!)

I also found something peculiar. I am using demoversion simulator of Frontline-Electronicsfor simulating this program. I copied down the code from lcd tutorial, assembled and simulated. All the initialisation commands go well. I saw the RW pin's status. It is high while these commands took place. But, WRITE_LCD routine was called, LCD status is always busy and the WAIT_LCD routine just locks up there.

Then I included CLR RW instruction in the INIT_LCD routine. This time, I was amazed. Even the first init command, 38h is not getting accepted; I mean, LCD shows busy always. As this many tug-of-wars go in the simulation process itself, I am totally diffident about the Hardware working. About the whole code what I have used for simulation is:


    stk_bse equ 30h
    DB0 EQU P1.0
    DB1 EQU P1.1
    DB2 EQU P1.2
    DB3 EQU P1.3
    DB4 EQU P1.4
    DB5 EQU P1.5
    DB6 EQU P1.6
    DB7 EQU P1.7
    EN EQU P0.2
    RS EQU P0.0
    RW EQU P0.1
    DATA EQU P1

    org 0000h
    boot: ljmp start

    org 0003h ;IE0 all interupts are returned
    ret

    org 000Bh ;TF0
    ret

    org 0013h ;IE1
    ret

    org 001Bh ;TF1
    ret

    org 0023h ;serial
    ret

    org 0030h
    start:
      mov IE,#00h
      mov SP,#stk_bse
      mov r4,#0ah

    wait:
      lcall delay
      djnz r4,wait
      lcall wait_lcd
      lcall INIT_LCD
      LCALL CLEAR_LCD
      MOV A,#'H'
      LCALL WRITE_TEXT

    here: sjmp here

    INIT_LCD:
      SETB EN
      ;clr RW this is where I tried
      CLR RS
      MOV p1,#38h
      CLR EN
      LCALL WAIT_LCD

      SETB EN
      CLR RS
      MOV p1,#0Eh
      CLR EN
      LCALL WAIT_LCD

      SETB EN
      CLR RS
      MOV p1,#06h
      CLR EN
      LCALL WAIT_LCD
      RET


    WAIT_LCD:

      SETB EN ;Start LCD command
      CLR RS ;It's a command
      SETB RW ;It's a read command
      MOV p1,#0FFh ;Set all pins to FF initially
      MOV A,p1 ;Read the return value
      JB ACC.7,WAIT_LCD ;If bit 7 high, LCD still busy
      CLR EN ;Finish the command
      CLR RW ;Turn off RW for future commands
      RET


    CLEAR_LCD:

      SETB EN
      CLR RS
      MOV p1,#01h
      CLR EN
      LCALL WAIT_LCD
      RET


    WRITE_TEXT:

      SETB EN
      clr RW
      SETB RS
      MOV p1,A
      CLR EN
      setb EN
      LCALL WAIT_LCD
      RET


    delay:
      mov r6,#0ffh

    loop1:
      mov r5,#0ffh

    loop2:
      djnz r5,loop2

      djnz r6,loop1
      ret

    end


  • 99% of the above program is from the LCD tutorial in this forum. I have done little patchs for my hardware


  • Where have I missed it? What might be the problems? I am very sure about my hardware part. Also, as I have bought new LCD module, there is no problem with that also. What keeps me down? I am trying for, literally 6 months to get this LCD to display. Sorry for a lenghtier post.

    Thanks for your patience,
    Regards,
    Vignesh.

    List of 25 messages in thread
    TopicAuthorDate
    datasheet for lcd            01/01/70 00:00      
       datasheet            01/01/70 00:00      
       To Marjan!            01/01/70 00:00      
          is it Mehdi?            01/01/70 00:00      
             Contrast Control.            01/01/70 00:00      
                Code for the LCD            01/01/70 00:00      
                   please read as:            01/01/70 00:00      
                   LCD initialisation is wrong            01/01/70 00:00      
                      I have got it, but..            01/01/70 00:00      
                         READ / WRITE sequence            01/01/70 00:00      
                            thanks Leo            01/01/70 00:00      
             One more hint.            01/01/70 00:00      
                to Prahalad            01/01/70 00:00      
                   LCD Contrast - Vignesh            01/01/70 00:00      
                      oh, fine..            01/01/70 00:00      
                         Oriole LCD Modules            01/01/70 00:00      
                            Re: Oriole ODM.            01/01/70 00:00      
             quick check at the shop before buying            01/01/70 00:00      
             Yes,it is!            01/01/70 00:00      
                Testing : Passed            01/01/70 00:00      
                to Mehdi with love            01/01/70 00:00      
                   Thanks Vignesh !            01/01/70 00:00      
                      Oh with pleasure..            01/01/70 00:00      
       The original datasheet            01/01/70 00:00      
       damaged LCD            01/01/70 00:00      

    Back to Subject List