Shop OBEX P1 Docs P2 Docs Learn Events
PropBASIC-4x20 LCD in 4 bit mode — Parallax Forums

PropBASIC-4x20 LCD in 4 bit mode

camelot2camelot2 Posts: 54
edited 2011-04-17 13:51 in Propeller 1
I'm searching for a PropBASIC program to run a 4x20 LCD in 4 bit mode
which has the HD44780 controller chip on board.
Any help in locating the code would be greatly appreciated - thanks

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-04-12 10:23
    Just because nobody jumped in so far ... (I don't know PropBASIC)

    Is it possible to run PASM code with PropBASIC? Then the easiest solution might be to use a PASM driver. Mine (to be found in ObEx) has not much SPIN code - the code only copies HD44780 commands to the communication buffer of the PASM driver. Would be easy to write that function in BASIC and then add some comford functions.
  • martinhmartinh Posts: 58
    edited 2011-04-12 10:38
    MagIO2 wrote: »
    Just because nobody jumped in so far ... (I don't know PropBASIC)

    Is it possible to run PASM code with PropBASIC? Then the easiest solution might be to use a PASM driver. Mine (to be found in ObEx) has not much SPIN code - the code only copies HD44780 commands to the communication buffer of the PASM driver. Would be easy to write that function in BASIC and then add some comford functions.

    Yes that is easy (to include PASM), PropBASIC has a ASM ... ENDASM construct for inlining PASM code.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-04-13 02:05
    What's the status? Did it help?

    I've had a quick glance into PropBASIC and for me it seems to be easily doable.
  • camelot2camelot2 Posts: 54
    edited 2011-04-13 04:30
    hi, thanks for the reply. I downloaded your file from ObEx and
    spent several hours looking over the 7 .spin files. The best I
    can figure out is that the BenkyLCDdriver.spin is the file that
    has to be inserted into my PropBASIC file using ASM and ENDASM.
    This is where I am really lost that is how to convert all the
    PUB sections and dat section. I know nothing about spin.

    Any help in translating your code to PropBASIC would be greatly
    appreciated - thanks again
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-04-13 05:55
    Ok, I'll have a look at it this evening.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-04-13 14:25
    And here it is ... the first proof of concept ;o)

    It's far away from being a usefull piece of BASIC code, but it shows the first text on the LCD.


    PS: To be honest I don't know how it works in detail, because I made my first experience with propBASIC ;o) So, currently I believe that the buffer used to communicate with the PASM-code is found by accident. Why can't PAR be passed to a task?

    PPS: Check the PIN assignments.
    PIN 5 is a LED in my setup which was used as a heartbeat in my first tests, to see that BASIC works as I expect it to work.
    PIN15 is switching on the LCD backlight in my setup. Propably you don't need that!?
  • camelot2camelot2 Posts: 54
    edited 2011-04-13 15:35
    gee that was fast, thanks for the PropBASIC file. As soon as I get the breadboard wired I will try it. I am assuming that the line "BASE_PIN CON 8" refers to P8 (device pin13) and that R/W, E, D4,D5,D6 and D7 go on P9,P10,P11,P12,P13 and P14 respectively. thanks again for all your help
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-04-14 14:01
    Wiring is described in the BenkyLCDdriver.spin, as the PASM code is exactly the same
    P8 = RS
    P9 = R/W
    P10 = E
    P11..14 = D4..D7

    Here is a new version of the BASIC-file. It now contains the subroutines
    LCDClear
    LCDChar
    LCDString
    LCDMove
    LCDHex

    Maybe you want to write LCDBin and LCDDec by yourself? You can have a look into BenkyLCDInterface.spin how I implemented these functions in SPIN.
  • camelot2camelot2 Posts: 54
    edited 2011-04-14 14:59
    thanks again for the 2nd file, since I got the breadboard wired and ran the
    first file I will now try the 2nd.
    I'll give it my best shot trying to write the LCDBin and LCDDec but no
    guarantees
  • camelot2camelot2 Posts: 54
    edited 2011-04-17 04:52
    hi MagIO2, I'm having some problems that I can not resolve.
    1. I am trying to print "01234567890123456789" to line 3 or
    line 4 but it is being displayed on two lines and broken
    up. I can not find in the file where you change to a 4
    line display. Works fine on line 1 or 2. Any clues??
    2. still trying to convert the LCDBin and LCDDec with zero
    results
    thanks again for all your help
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-04-17 06:29
    You can have a look into the BenkyLCDdriver.spin ... there is a description for LCD displays ... the instructions you can send and the start address of the lines. For the 2 line displays the start addresses are:
    $00 for line 1
    $40 for line 2
    that's why the basic code has the line
    __param1 = __param1 << 6

    For a 4 line display it's
    $00 for line 1
    $40 for line 2
    $14 for line 3
    $54 for line 4
    as a workaround you can simply add $14 to the x coordinate in case you want to use line 3 (y set to 1) and 4 (y set to 2).

    I'll be back at home this evening and then I can change the basic-code. Then I can also take care of the LCDBin and LCDDec.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-04-17 13:51
    Ok ... here is the next iteration ;o)

    Important is to set the constant STG_LINE_WIDTH according to your display. LCDMove now expects row and column number to start from 0. (Before they started from 1.)

    Have fun!


    MyFirst.pbas
Sign In or Register to comment.