Connect with us

8051 LCD asm code

Discussion in 'Electronic Design' started by Marco Ferra, Sep 26, 2004.

Scroll to continue with content
  1. Marco Ferra

    Marco Ferra Guest

    I have coded a little routine to operate a LCD (16x2 HD44780U) through a
    8051 (at89s51) micro-controller and I haven't tested it yet, but I'm
    afraid that it won't work properly.

    Besides watching the busy flag signal of the LCD is there any other
    preocupation about timings? Or checking other pins?

    In the code below, is it possible to "jb" directly a pin like p1.7? The
    assembler (asem51) doesn't complain but I'm not sure.

    Thanks for your time
    Marco

    dt equ p1
    en equ p3.7
    rs equ p3.6
    re equ p3.5

    start:
    acall lcd_set
    ret

    lcd_espera:
    setb en
    setb re
    clr rs
    jb p1.7,lcd_espera
    clr en
    clr re
    ret

    lcd_data:
    setb en
    clr rs
    mov dt,a
    clr en
    call lcd_espera
    ret

    lcd_clear:
    mov a,#01h
    call lcd_data
    ret

    lcd_set:
    mov a,#38h
    call lcd_data

    mov a,#0eh
    call lcd_data

    mov a,#06h
    call lcd_data

    mov a,#'X'
    call lcd_data

    mov a,#'Y'
    call lcd_data
    ret

    end
     
  2. I'm not going to check your code, however comments below.
    The power-on initialization of these things is crucial. You'll need to
    implement delay routines that don't depend on the busy flag to get
    this to work succesfully. Follow the HD44780 data sheet procedure to
    the letter. You can also Google for code examples, some of which
    actually work reliably. Watch the worst-case strobe timing (data setup
    and hold time) if you are using a fast processor.
    Yes, both the bit-addressable portion of RAM and any bit of any SFR
    that is bit-addressable (which includes P0, P1, P2)

    Best regards,
    Spehro Pefhany
     
  3. Marco Ferra

    Marco Ferra Guest

    Yes I'll follow the HD44780 data sheet precisely.
    Thank you very much for enlighten me.

    Marco
     
  4. Rich Grise

    Rich Grise Guest

    Then it probably won't.
    I don't know. What does the data sheet say?
    I don't know. What does the data sheet say?

    Good Luck!
    Rich
     
  5. Tim Mitchell

    Tim Mitchell Guest

    Yes you can do jb p1.7, it jumps if the pin is high

    Depending on the speed you are running the micro at, your program may
    not work as it may be too fast for the display. They are quite slow old
    things. You might have to put in some "nop" (no operation) commands in
    between setting enable pins and setting data bus values.
     
  6. Tim Mitchell

    Tim Mitchell Guest

    Have you ever tried to read a Hitachi LCD controller data sheet? They
    are very badly translated and difficult to understand. Somewhere on the
    web, I can't remember where, someone has done an interpretation job on
    it.
     
  7. What's so hard to read about this?

    http://www.sparkfun.com/datasheets/LCD/HD44780.pdf


    Best regards,
    Spehro Pefhany
     
  8. Tim Mitchell

    Tim Mitchell Guest

  9. Ah, that looks a lot better than the old one, made on that
    old typewriter, and then scanned highly skewed, with the
    bread crums and pizza toppings sprinkled all over the pages.
     
  10. Yeah, I remember that original one. I think the distributor turned out
    a cruddy hard copy for me on a copy machine. But the one I posted the
    link to is from ca. 1999, so maybe it's time to get over it. ;-)

    The main remaining source of potential confusion is that the chip data
    sheet is not exactly congruent with the data sheet for the typical
    module (which is all most designers need), but you can't really blame
    Hitachi for that. Heck, it's not even their chip in there any more, a
    lot of the time.


    Best regards,
    Spehro Pefhany
     
  11. Rich Webb

    Rich Webb Guest

    With that in mind, there is something I've never quite been able to
    understand in the character LCD data sheets.

    For example, in the canonical Optrex manual
    http://www.optrex.com/pdfs/Dmcman_full.pdf
    on page 15 (section 1.7.5), and many others where they show the bit
    contents of a control byte, there is a row of numbers below the byte; in
    this example "123 14444244443 14444424444443".

    I'm sure this is crystal clear to everyone but me, but I just can't seem
    to decode the meaning. I've implemented drivers for several 8-bit micros
    without "getting" it but it is frustrating not to know. Any ideas?
     
  12. Looks like a typesetting/font/parsing problem. I guess the idea was to
    print a symbol like a horizontal '{' but stretched over the columns
    of the subfield. Replace the '1' with a '`', '4' with '-', '2' with '.'
    and '3' with a '''

    So, 144424443 means something like: `----.----'

    But you got me puzzled for a minute too ;)
     
  13. I think Frank is right. A data sheet created in Microsoft Word- WTF do
    you expect!!

    Maybe some mixup with symbol fonts.


    Best regards,
    Spehro Pefhany
     
  14. John Fields

    John Fields Guest

     
  15. Rich Webb

    Rich Webb Guest

    Dang! Thank you, Frank. I can see it now and that makes perfect sense.
    All this time I've been trying to interpret the digits as being
    associated with signal timing or the like. Trying too hard to make
    things too complicated...
     
  16. Rich Grise

    Rich Grise Guest

    But it was done by MICROS$~1 - they're republicans, so they can do
    anything they want.

    Cheers!
    Rich
     
  17. I've been thinking about it. Without any doubt, it looked fine when the
    sheet was created in MS-Word. I tend to blame it on the pdf converter.

    When you google for 144424443 it seems to happen frequently.

    In Dutch we call such a symbol an accolade. I don't know the English
    word for it. Anyway, it is just below my curiosity treshold to investigate
    further. Font issues can get very complicated.

    Maybe it has something to with fonts used in Asia. Sometimes I get an
    email from Asia, and these are always in a very 'typewriter' style font.

    Damn, the old typewriter again ;)
     
  18. Aha. If you search for it in this file:
    http://www.amscopub.com/free_downloads/sol_geo/unit2.pdf

    It shows up on page 2, for example, and views as a horizontal curly
    bracket under the words that are being emphasized. However the font is
    something called "BlackDotMT-Extra".

    That file was created on a Mac in Quark Xpress 4.1 and distilled to PS
    on the Mac.
    The English characters included in Asian fonts have quite a
    characteristic look to them. For example, the MingLiU Chinese font.

    http://www.speff.com/MingLiU.pdf


    Best regards,
    Spehro Pefhany
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-