LCD_AnyPin.pbp


Results 1 to 40 of 109

Thread: LCD_AnyPin.pbp

Threaded View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default LCD_AnyPin.pbp

    This has come up several times, and likewise, I've tried to approach it several times...

    After a 6 month pause from working on it, suddenly all my problems were staring me right in the face, leaving me to wonder ... "What the Hell was I thinking!" Or, maybe Not thinking.

    After fixing the now obvious mistakes ...
    Finally, "A Winner!"

    Here's a viable solution to ...

    "How do I scatter the pins of the LCD data bus across multiple ports with PicBasic Pro?"

    First, let me show you what a sample program might look like...
    Code:
    ;----[ Change these to match your LCD ]--------------------------------------- 
    LCD_DB4    VAR PORTA.0 
    LCD_DB5    VAR PORTB.3 
    LCD_DB6    VAR PORTB.7 
    LCD_DB7    VAR PORTC.1 
    LCD_RS     VAR PORTD.4 
    LCD_E      VAR PORTA.1 
    LCD_Lines  CON 2 ' # of Lines on LCD, 1 or 2 (Note: use 2 for 4 lines) 
    LCD_DATAUS CON 50 ' Data delay time in us 
    LCD_COMMANDUS CON 2000 ' Command delay time in us 
    INCLUDE "LCD_AnyPin.pbp" ; *** Include MUST be AFTER LCD Pin assignments ****
    
    ;----[ Your Main program starts here ]---------------------------------------- 
    LoopCount VAR WORD
    PAUSE 500 : LCDOUT $FE,1 : PAUSE 250 ; Initialize LCD (You may not need this, 
                                         ; but some displays are picky) 
    
    Main: 
        LCDOUT $FE,1 ; clear screen 
        LCDOUT $FE,$87,"Hello,",$FE,$C8,"From DT!"
    
        FOR LoopCount = 0 TO 65535 
            LCDOUT $FE,$80, IDEC LoopCount 
            LCDOUT $FE,$C0, IHEX4 LoopCount 
        NEXT LoopCount
    GOTO Main
    Pretty simple ey?

    Just assign the Pins, Include the file, and away you go, using LCDOUT just like you always have.

    Ok, so now for the other Simple part that can go tragically wrong if you're not careful.
    Yes, ... that's right, ... I'm modifying the Library again.

    Or, more accurately, ... "You" are modifying the Library.
    And before "You" change anything, ...
    "MAKE SURE" you have a backup of the file.
    Don't blame me if it gets messed up and you don't have anything to restore it with.
    And, I will apologize to MeLabs Support ahead of time for the extra support calls this will generate.
    Back it up! and they won't have a problem.


    In your PBP folder (the one with PBPW.EXE in it), open the Library file for the type PIC you are using.

    For 16F's open PBPPIC14.lib with Notepad.
    For 18F's open PBPPIC18.lib

    Search for this string ";* LCDOUT ". That's "semicolon star space LCDOUT space".
    You should see a section that looks like this ...
    Code:
    ;****************************************************************
    ;* LCDOUT     : Send char to LCD                                *
    ;*                                                              *
    ;* Input      : W = char                                        *
    ;* Output     : None                                            *
    ;*                                                              *
    ;* Notes      :                                                 *
    ;****************************************************************
     
        ifdef LCDOUTJ_USED
      LIST
    LCDOUTJ    movf    FSR, W    ; Jumpman entry
      NOLIST
    LCDOUT_USED = 1
        endif
     
        ifdef LCDOUT_USED
    ; NEW Code goes here...
      LIST
    LCDOUT  movwf   R3 + 1          ; Save char
    That one is from PBPPIC14.lib, for PBPPIC18.lib the only difference is it will show FSR0L, instead of FSR.

    Insert this code into the spot marked ; NEW Code goes here...
    It's very important that you get the EXACT line. Be careful ...
    Code:
    ;****************************************************************
    ;*               Added for HighJack                             *
    ;****************************************************************
    HIGHJACK_USED = 1                                              ;*
    LCDOUT_HIGHJACKED = 1                                          ;*
        ifdef HJ_LCDOUT                                            ;*
      LIST                                                         ;*
    LCDOUT                                                         ;*
            L?GOTO  HJ_LCDOUT                                      ;*
      NOLIST                                                       ;*
        else                                                       ;*
    ;****************************************************************
    Now, scroll down past the LCDOUT code, and you should see this ...
    Code:
      NOLIST
    DUNN_USED = 1
    PAUSEUS_USED = 1
        endif
    ; Second piece of NEW Code goes here ...
     
    ;****************************************************************
    ;* LOOK2      : Get data from any register                      *
    ;*                                                              *
    ;* Input      : R0 address / constant                           *
    ;*            : W data type                                     *
    ;* Output     : R0 result                                       *
    ;*                                                              *
    ;* Notes      :                                                 *
    ;****************************************************************
    Insert this code into the spot marked ; Second piece of NEW Code goes here ...
    Code:
    ;****************************************************************
    ;*               Modified for HighJack                          *
    ;****************************************************************
        endif
    If you got it right, you can now use your HD44780 LCD on any pins you wish.
    If you got it wrong, restore the file you backed up (You did back it up, right?). Then try again. It work's. Really! Trust me!

    GoodNote: This modification will NOT interfere with your normal PBP LCDOUT routines.
    In order to invoke the Custom LCD port routines, the main file must have the statement ...

    INCLUDE "LCD_AnyPin.pbp"
    If that statement is NOT included in your program, the LCDOUT commands will work the same way they always have.

    There are 2 files required to implement this approach ...

    LCD_AnyPin.pbp
    VirtualPort.bas -- (Included from the LCD_AnyPin.pbp file)

    Both files are included in the Zip file below. Extract them to your PBP folder.
    Attached Files Attached Files
    Last edited by Darrel Taylor; - 6th September 2012 at 04:05.
    DT

Members who have read this thread : 3

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts