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.
![Embarrassment](images/smilies/redface.gif)
After fixing the now obvious mistakes ...
Finally, "A Winner!"
![Big Grin](images/smilies/biggrin.gif)
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...
; Initialize your Hardware first, set CONFIGs, OSC, Turn off A/D etc ;----[ 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
Just assign the Pins, Include the file, and away you go, using LCDOUT just like you always have.<hr>
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.
![EEK!](images/smilies/eek.gif)
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 ...
;**************************************************************** ;* 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
Insert this code into the spot marked ; NEW Code goes here...
It's very important that you get the EXACT line. Be careful ...
;**************************************************************** ;* Added for HighJack * ;**************************************************************** HIGHJACK_USED = 1 ;* LCDOUT_HIGHJACKED = 1 ;* ifdef HJ_LCDOUT ;* LIST ;* LCDOUT ;* L?GOTO HJ_LCDOUT ;* NOLIST ;* else ;* ;****************************************************************
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 : * ;****************************************************************
;**************************************************************** ;* Modified for HighJack * ;**************************************************************** endif
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!<hr>
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.<hr>
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.
<br>
Re: Any faster option than USART 115,200?
no, divide by 10, 8 data + start + stop bits
richard Today, 03:16