PDA

View Full Version : LCD_AnyPin.pbp



Darrel Taylor
- 3rd September 2007, 05:39
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. :o

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

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...
;----[ 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. :eek:

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
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 ...
;************************************************* ***************
;* 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 ...
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 ...

;************************************************* ***************
;* 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.

Ioannis
- 3rd September 2007, 07:04
Amazing!

Congratulations Darrel!

I am very impressed! Really!

Thank you very much.

Ioannis

Darrel Taylor
- 3rd September 2007, 07:56
Thanks Ioannis!

Really!<hr>
Lesson Learned, when it gets too tough.
Set it aside for awhile.

It might look easier when you come back to it later.
Just make sure you come back to it. :)

<br>

Ioannis
- 3rd September 2007, 08:42
Yes you are right about that. It happens alot to me too!

Since I'm more the hardware guy, is a little confussing to really understand what you are doing. But as long as it works, thats fine!

Anyway you write great piece of code. I really appreciate your offers.

Ioannis

Kamikaze47
- 3rd September 2007, 18:23
Needed to do this on one of my projects the other day. This will be very useful. Thanks Darrel.

Darrel Taylor
- 3rd September 2007, 22:45
Oops!

Apparently, not ALL my problems were staring me in the face. :o

I had PAUSEs in the LCD_Init: routine, and they were changing the system registers.
So I Changed them to DelayUS, which doesn't use system registers.

It worked OK before, but now it works right. Or, at least more behaved when Initializing.

I've updated the LCD_AnyPin.zip file in the first post.
Version 2.1
<br>

Archangel
- 3rd September 2007, 22:47
<h1> * * * * Another Home Run Darrel ! * * * *</h1>
<p>
<font color=red><h2> THANK YOU !</font color></h2><p>
JS

mackrackit
- 3rd September 2007, 23:53
Thanks Darrel, it will come in handy.

Josuetas
- 4th September 2007, 01:21
Thanks Darrel once again,

To be completely honest: When i have a new doubt in PBP i donŽt just think iŽll post it on the forum... i really really think:
"HE will now, i`ll better ask him" ;)

sayzer
- 4th September 2007, 08:08
....

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.

<br>

Darrel,

I appreciate you sharing the code with us; and respect your knowledge. Thank you.

BTW;
Even though you clearly stated it, you will get this question anyway.

Question from an UnKnown user:
Hi Darrel, I tried to apply your "LCD_AnyPin" code into my project. I followed your instructions exactly as you stated. But, it did not work and now my LCDOUT command does not work at all. Can you collaborate me to solve this problem? because I don't see any problem on my side. I think your code is not ready for everyone, yet. Didn't you test it before releasing it?

Darrel Taylor
- 4th September 2007, 08:30
Reply to UnKnown user:

You were warned.
You didn't follow directions.
You Blew It!
Not my problem!

And by the way, there's a copy of the file on the CD you got when you bought PBP. :p
<br>

Ioannis
- 4th September 2007, 08:31
..... I think your code is not ready for everyone, yet. Didn't you test it before releasing it?

Ohh, come on Sayzer, don't be to pessimistic! 8-)

Ioannis

Emil G
- 4th September 2007, 20:26
Thanks Darrel.

Regards
Emil

kezuke
- 6th September 2007, 17:22
thank you very much!!!

Josuetas
- 7th September 2007, 05:09
This is great stuff no doubt, it should be a suggestion to improve the PBP compiler in the future, i am sure we all had this nibble problem before.

But it is not backwards compatible is it? all of my previous code will be impossible to compile with this change, am i wrong?

Is it impossible to ask for backwards compatibility? Some magic from the magician please ;D.
Being completely ignorant about this: IF LCD_E is not defined then use original LCDOUT command else use DTs version. (Most surely not possible :p)

An obviuos solution is to have a whole new folder for the PBP modified and one for the original PBP, but in the end it will tend to give trouble, i am almost sure. I know i can handle it but this could be really dangerous code for newbies.

Just my thought

Again, thanks a lot DT


DJC

Ioannis
- 7th September 2007, 08:04
Your answer is on the first post by Darrel explaining that all programs will work as before.

Read it carefully from top to bottom.

Ioannis

sayzer
- 7th September 2007, 09:08
Ohh, come on Sayzer, don't be to pessimistic! 8-)

Ioannis

....
.......
..........


Your answer is on the first post by Darrel explaining that all programs will work as before.

Read it carefully from top to bottom.

Ioannis


...
.....
........


Ioannis, do you see what I meant?

:)

Ioannis
- 7th September 2007, 09:47
Yes, I see... No comments!

Ioannis

Josuetas
- 11th September 2007, 15:32
You dont have to be such.......

Thanks for the nice answer Ioannis

Ioannis
- 11th September 2007, 20:35
You are welcome!

Ioannis

sayzer
- 6th November 2007, 12:06
Now, scroll down past the LCDOUT code, and you should see this ...



NOLIST
DUNN_USED = 1
PAUSEUS_USED = 1
endif



I just realized that in my file, it is



DONE_USED = 1

Darrel Taylor
- 6th November 2007, 21:29
Then they must sell a different version in Turkey.

Because it's definitely DUNN_USED = 1 here
<br>

sayzer
- 7th November 2007, 08:28
Darrel,

There is nothing like "DUNN" in the file.

Here is a piece from the code.



....
.......
endif

movlw LCD_DATAUS ; Wait for data operation to complete
call PAUSEUS
bsf STATUS, C ; Set no timeout for Serout2mod
return
NOLIST
DONE_USED = 1
PAUSEUS_USED = 1
endif

;************************************************* ***************
;* LOOK2 : Get data from any register *
;* *
;* Input : R0 address / constant *
;* : W data type *
;* Output : R0 result *
;* *
;* Notes : *
;************************************************* ***************

ifdef LOOK2_USED
LIST
LOOK2 iorlw 0 ; Check for constant
btfsc STATUS, Z
goto DONE ; Constant so all set
movwf R4 ; Save type
movf R0, W ; Set FSR for translate
movwf FSR ; Put address in FSR
btfsc R0 + 1, 0 ; Long address?
bsf STATUS, IRP ; Yes
clrf R0 ; Clear the result
clrf R0 + 1
btfsc R4, 7 ; Check type
goto look2bit ; Bit type
movf INDF, W ; Get low byte of data
movwf R0 ; Store it
btfss R4, 1 ; Byte or word?
goto DONE ; Byte
incf FSR, F ; Point to high byte
movf INDF, W ; Word - get high byte
movwf R0 + 1 ; Store high byte
goto DONE
look2bit call CONVBIT ; Change bit to mask
andwf INDF,W ; Isolate bit
btfss STATUS, Z ; Bit / no bit?
incf R0, F ; Bit
goto DONE
NOLIST
CONVBIT_USED = 1
DONE_USED = 1
endif




So instead of DUNN_USED = 1, I have DONE_USED = 1.


Anyone else has the same?

Melanie
- 7th November 2007, 10:00
I can confirm what Sayzer is saying...

Just randomly picking PBPPIC14.LIB from my PBP2.46 there is no DUNN_USED but DONE_USED...

however...

PBPPIC18.LIB does have DUNN_USED...

So my British version is mid-way between Darrels American version, and Sayzers Turkish version... yup... about right on the Atlas too... so Alain will have a greater probability of being DONE than DUNN, and Ioannis and Luciano will almost certainly be DONE at sometime...

Acetronics2
- 7th November 2007, 11:03
Hi, Mel

I've "DONE" in Pbpic14.lib and "DUNN" in Pbpic18.lib ...

just like you !

Buuuuuut ... is it really important ??? ( LOL ...); if I understood Darrel ... It's just to show the place where to include a piece of code.

What ??? I did say something stupid ??? ... I apologize, then ! Acoording to Khomeiny Ayatollah ( and Sayzer ! ) ... What's the cost ?

Alain

sayzer
- 7th November 2007, 11:40
Hi, Mel

I've "DONE" in Pbpic14.lib and "DUNN" in Pbpic18.lib ...

just like you !

Buuuuuut ... is it really important ??? ( LOL ...); if I understood Darrel ... It's just to show the place where to include a piece of code.

What ??? I did say something stupid ??? ... I apologize, then ! Acoording to Khomeiny Ayatollah ( and Sayzer ! ) ... What's the cost ?

Alain


Alain,

You are making jokes, but I am sure only you are having some kind of smile on your face.

I prefer not to fill this thread with your strange ongoing discussion.

But, if you like to continue, then lets jump into OFF TOPIC section and see what you got there. Are you in?

Ioannis
- 7th November 2007, 11:46
On my old 2.40 compiler I can confirm what Melanie stated:

PBPBIC12.lib: DONE_USED
PBPPIC14.lib: DONE_USED
PBPPIC17.lib: DUNN_USED
PBPPIC18.lib: DUNN_USED

Also note that on the last two libraries there are some ifdef SERIN2DONE_USED that are strange to me.

Ioannis

Melanie
- 7th November 2007, 11:55
> Buuuuuut ... is it really important ??? ( LOL ...); if I understood Darrel ... It's just to show the place where to include a piece of code.

I would think yes, because the clueless outnumber the clued ten to one on this forum. There's folks starting projects that are way beyoned their understanding or ability levels and stumbling over which way around a Resistor should be soldered in (oh, and yes, I do teach people that there is a proper way to insert Resistors and all non-polarised components).

sayzer
- 7th November 2007, 12:36
Although I am already using Darrel's LCD at any pin modification, I saw some difference and posted here.

So that those "clueless" firends can also give it some meaning as to see "why?", and go on.

Maybe this way, Melanie's students will not ask her whether the difference in their file creates any issue.

If I see more difference I will post again.
Alain will jump in and make some jokes and smile on his own -again.




-----------------------

Melanie
- 7th November 2007, 13:21
I don't count you amongst the clueless Sayzer, I do consider you're amongst the living rather than the comatose... and your flagging the anomaly is both valid and worthwhile noting - if just for those that will follow us reading this thread and wonder why their files are different.

I don't teach people PICBasic, although I do point out to those down in the production department that there is a right-way and a wrong-way of doing things... and when you do it properly, it makes a difference. For example, I mentioned Resistors... yes you can put them in any way you want (there are exceptions), but if you align them all the same way, so you can read the values left-to-right or top-to-bottom, such a simple thing doesn't half make a board look neater.

Acetronics2
- 7th November 2007, 13:53
Hi, Sayzer

To close the ( this tremendous ) subject ...

1) "Anonymous user" DID NOT Follow "exactly" what to do ... instead of what you stated.

2) No, I don't smile at all to those ... make me rather sad ...

3) I Always respect real efforts to understand ...

Take it easy ... making jokes is one of the best ways to remember something !!!

Alain

Darrel Taylor
- 7th November 2007, 22:08
ROFL,

A comical list of mistakes on my part. :o
It all still works, but I can definitely see the confusion.

Apparently when making the first Post, I used the beginning of LCDOUT from the PBPPIC14.lib.
Then I was checking for differences between the 14 and 18.libs and didn't see any, so I copied the end of LCDOUT from the PBPPIC18.lib file. Then after Sayzer's post, I only looked at the 18.lib (which had DUNN), DOH!

Thanks for the help Sayzer, and the confirmation from everyone else.

I need to make new instructions for the installation of HighJack routines anyhow.
Now there's LCD_AnyPin, PC064PYL, LCD_Shift and others that will use the same Modification.
So I need to see if I can work out the confusion during installation.
<br>

sean-h
- 15th February 2009, 16:01
Hi Darrel and thx for the great hack.

I have had it working fine on 16F Pics and 18F pics, but today I tried it on a USB 18F2550 and it tells me the Hijacked-LCDOUT not found.

As well as modifying the pbppic14.lib and pbppic18.lib , I also added it to the pbppi18l.lib as this seems to be called from PBPUSB18.LIB but no joy and get the error.

Is it because it uses different files in the USB18 folder?

Cheers

Sean.

Darrel Taylor
- 15th February 2009, 17:33
Is it because it uses different files in the USB18 folder?

I don't think so.
It ends up using the same library as non-USB programs.

Do you have any LCDOUT statements in the program yet?
Or are you trying to get it to compile before adding any?

I ask because it won't add that portion of code until there are LCDOUTs.
<br>

sean-h
- 15th February 2009, 18:18
I don't think so.

Do you have any LCDOUT statements in the program yet?
Or are you trying to get it to compile before adding any?

I ask because it won't add that portion of code until there are LCDOUTs.
<br>

Spot on, that was it I had them Rem'ed out while setting up code.
Now LCDOUT command in code, it compiles perfectly :)

Many thanks Darrel, Good Stuff.

PICn-It
- 13th November 2009, 05:09
I hate to sound like a noob (but I am) so here goes.... :o

I needed to do exactly this in a project, move the LCD data bus to different pins that is, I did the edit, saved the files (yes w/backup) and placed the example snippet of code into my BAS file.

When I compile I'm getting this error:

Error: unable to execute mpasmwin.Error[113]
"symbol not previously defined (_LCD_DATAUS)"
"symbol not previously defined (_LCD_COMMANDUS)"

if I remove the lines:

LCD_DB4 VAR PORTB.5
LCD_DB5 VAR PORTB.4
LCD_DB6 VAR PORTB.3
LCD_DB7 VAR PORTB.2
LCD_RS VAR PORTB.7
LCD_E VAR PORTB.6

it compiles (assembles?) w/o error. I can't find _LCD_DATAUS or _LCD_COMMANDUS in any readable files in my PBP folder.


also if I leave those lines in, and just rem the INCLUDE "LCD_AnyPin.pbp" it compiles fine.

(it's a 16F883 I'm working with on PBP 2.6)

Darrel Taylor
- 13th November 2009, 06:40
LCD_DATAUS and LCD_COMMANDUS are constants that you must declare in your program. Shown in the first post of this thread.

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

They are not optional.
<br>

PICn-It
- 14th November 2009, 00:44
LCD_DATAUS and LCD_COMMANDUS are constants that you must declare in your program. Shown in the first post of this thread.

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

They are not optional.
<br>

I'm sorry, I should have posted a code snippet for you to see, I already did define them, is a "declaration" different that this?:


; Define LCD registers and bits
DEFINE LCD_DREG PORTB ;
DEFINE LCD_DBIT 4 ;
DEFINE LCD_RSREG PORTB ;
DEFINE LCD_RSBIT 0 ;
DEFINE LCD_EREG PORTB ;
DEFINE LCD_EBIT 1 ;
DEFINE LCD_COMMANDUS 2000 ; Set command delay time in uS
DEFINE LCD_DATAUS 50 ; Set data delay time in uS
DEFINE LCD_BITS 4 ; Set LCD buss size (4-bit or 8-bit)
DEFINE LCD_LINES 2 ; Set number of lines on LCD

LCD_DB4 VAR PORTB.5
LCD_DB5 VAR PORTB.4
LCD_DB6 VAR PORTB.3
LCD_DB7 VAR PORTB.2
LCD_RS VAR PORTB.7
LCD_E VAR PORTB.6
;INCLUDE "LCD_AnyPin.pbp" ; this include MUST be AFTER LCD Pin assignments

I tried this in PBP 2.46 and it does compile, but my MPLAB chokes because of some file missing or unsupported (COD file I think)

Darrel Taylor
- 14th November 2009, 02:20
Go back up to the first post and take another look at the highlighted code example.

There are no DEFINEs, only VAR and CON.
It must be exactly as shown (except for the actual pins used).

Don't improvise or over think it. Just copy/paste and modify for your pins.
<br>

PICn-It
- 14th November 2009, 23:24
Go back up to the first post and take another look at the highlighted code example.

There are no DEFINEs, only VAR and CON.
It must be exactly as shown (except for the actual pins used).

Don't improvise or over think it. Just copy/paste and modify for your pins.
<br>

I must have some other issue at hand then if it's really that simple.

Just for the sake of it I created a new project with the following minimal code, it still fails:
(again MPLAB v8.40, PBP v2.60, PIC16F883)




CLEAR ; standard opening move
;DEFINE OSC 4 ; set oscillator speed

LCD_DB4 VAR PORTB.5
LCD_DB5 VAR PORTB.4
LCD_DB6 VAR PORTB.3
LCD_DB7 VAR PORTB.2
LCD_RS VAR PORTB.7
LCD_E VAR PORTB.6
INCLUDE "LCD_AnyPin.pbp" ; this include MUST be AFTER LCD Pin assignments

PAUSE 500

TRISA = %11111111
TRISB = %00000000
ADCON1=%00000111

DO
loop:

LCDOUT $FE, 1
PAUSE 250
LCDOUT "Hello"
LCDOUT $FE, $C0
LCDOUT "World"
PAUSE 250

END


...and this is my output spew:

Executing: "D:\PBP\PBPMPLAB.BAT" -ampasmwin -k# -p16F883 "Untitled.bas"
Executing: "D:\PBP\PBPW.EXE" -ampasmwin -k# -p16F883 "Untitled.bas"
PICBASIC PRO(TM) Compiler 2.60, (c) 1998, 2009 microEngineering Labs, Inc.
All Rights Reserved.
Pass 1:
Pass 2:
Code Gen:
Macro Pass:
mpasmwin /o- "D:\PIC Projects\Untitled.ASM"

ERROR: Unable to execute mpasmwin.Error[113] D:\PIC PROJECTS\UNTITLED.ASM 244 : Symbol not previously defined (_LCD_DATAUS)
Error[113] D:\PIC PROJECTS\UNTITLED.ASM 244 : Symbol not previously defined (_LCD_DATAUS)
Error[113] D:\PIC PROJECTS\UNTITLED.ASM 244 : Symbol not previously defined (_LCD_COMMANDUS)Halting build on first failure as requested.
BUILD FAILED: Sat Nov 14 14:08:14 2009

Sorry to bother you about this, and than you for taking the time to replay to my posts. Pardon me as I'm a noob to PIC programming and have not developed any intuition with this environment yet.

If this code indeed works for you, as shown, it should work for me but isn't.
(yet)

Darrel Taylor
- 14th November 2009, 23:44
http://www.pbpgroup.com/files/dejected.gif

Don't improvise or over think it. Just copy/paste and modify for your pins.
<br>

PICn-It
- 15th November 2009, 05:19
http://www.pbpgroup.com/files/dejected.gif

Don't improvise or over think it. Just copy/paste and modify for your pins.
<br>

Ah... got it!

Sorry for the apparent trouble Darrel. Thanks for walking me through it, I appreciate your time very much, and I appreciate your work on this code.

PICn-It
- 15th November 2009, 08:43
Darrel, so I cut-n-pasted your exact code into a new project, changed only the LCD VARs, and am now getting much farther than before...but...

Now I'm getting stuck when LCD_Anypin.pbp compiles, the code is cut from your 1st post, my only change was:



LCD_DB4 VAR PORTB.5
LCD_DB5 VAR PORTB.4
LCD_DB6 VAR PORTB.3
LCD_DB7 VAR PORTB.2
LCD_RS VAR PORTB.7
LCD_E VAR PORTB.6




and here is my latest spew:
(MPLAB v8.4/PBP v2.6)


Executing: "D:\PBP\PBPMPLAB.BAT" -ampasmwin -k# -p16F883 "Untitled.bas"
Executing: "D:\PBP\PBPW.EXE" -ampasmwin -k# -p16F883 "Untitled.bas"
PICBASIC PRO(TM) Compiler 2.60, (c) 1998, 2009 microEngineering Labs, Inc.
All Rights Reserved.
Pass 1:
Pass 2:
Code Gen:
Macro Pass:
mpasmwin /o- "D:\PIC Projects\Untitled.ASM"
COFF Pass:
Executing: "D:\PBP\PBPMPLAB.BAT" -ampasmwin -k# -p16F883 "D:\PBP\VirtualPort.bas"
Executing: "D:\PBP\PBPW.EXE" -ampasmwin -k# -p16F883 "D:\PBP\VirtualPort.bas"
PICBASIC PRO(TM) Compiler 2.60, (c) 1998, 2009 microEngineering Labs, Inc.
All Rights Reserved.
Pass 1:
Pass 2:
Code Gen:
Macro Pass:
mpasmwin /o- D:\PBP\VirtualPort.ASM
COFF Pass:
Executing: "D:\PBP\PBPMPLAB.BAT" -ampasmwin -k# -p16F883 "D:\PBP\LCD_AnyPin.pbp"
Executing: "D:\PBP\PBPW.EXE" -ampasmwin -k# -p16F883 "D:\PBP\LCD_AnyPin.pbp"
PICBASIC PRO(TM) Compiler 2.60, (c) 1998, 2009 microEngineering Labs, Inc.
All Rights Reserved.
Pass 1:
D:\PBP\LCD_ANYPIN.PBP ERROR Line 87: Bad expression.
Line 00087: LOW LCD_RS : HIGH LCD_E ; Start with RS LOW and Enable High
D:\PBP\LCD_ANYPIN.PBP ERROR Line 87: Bad expression.
Line 00087: LOW LCD_RS : HIGH LCD_E ; Start with RS LOW and Enable High
Pass 2:
Code Gen:
Macro Pass:
Halting build on first failure as requested.
BUILD FAILED: Sat Nov 14 23:28:52 2009
Is the error on line 87 something I've done/not-done?

PICn-It
- 15th November 2009, 17:14
Sorry, never mind that last post.

I realized that I included the files LCD_AnyPin.pbp and VirtualPort.bas (in the files applet) rather than just having them referenced from my *.bas, and that was causing MPLAB to try compiling them. :o

PICn-It
- 18th November 2009, 20:10
I'm still not getting anywhere with this. :o

At this point I've tried so many things I can't tell where I'm at anymore. :(

I think the LCD_Anypin code is working, it compiles w/o error and when I probe the circuit (the 16F883 is in) with my oscilloscope while its supposed to be running, I am seeing the "E" pin going up and down, but not seeing anything on the data pins LCD_DB4 through LCD_DB7.

I'm trying to get this LCD onto PortB. I understand the 16F883 has a comparator on pins 22-(aka; RB1) and pin 24-(aka; RB3) and that can be a problem so I've tried to use CM1CON0=%00000000 to disable them.

I'm trying to get my LCD (H44780 type) to be hooked up to the 16F883 as follows:

RB7->RS
RB6->E
RB5->D4
RB4->D5
RB3->D6
RB2->D7

so far no joy.

In many threads here and elsewhere I see people saying I should have my own __CONFIG line instead of relying on the default PBP one, so I tried that. Also people say to disable the WDT so I tried that too.

My PICKit2 programmer and software seem to working properly, it can run the tests fine and seems to read/write to the PIC.

When I switch on my test circuit all I get on the 16x2 LCD is the first row of pixel-blocks and nothing else...ever.

Any help would be very much ppreciated, I'm just starting out with PIC programming I'll appologise in advance if I'm doing something stupid in my code:




@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _CP_OFF & _HS_OSC

CLEAR
DEFINE OSC 4 ; set oscillator speed

; Setup Ports and Pins
PORTA = %00000000
TRISA = %00000011 ; set AN0 and AN1 to inputs
PORTB = %00000000
TRISB = %00000000 ; set all PORTB pins to outputs
IOCB = %00000000 ; disable IOCB on PortB
PORTC = %00000000
TRISC = %00000000 ; set all PORTC pins to outputs

; Initialize I/O
ADCON0 = %00000111 ; enable and set up AN0 input as ADC
ADCON1 = %10000000 ; right justify and use power rails as Vref
ANSEL = %00000001 ; A/D enabled for ANS0, disabled for ANS1->ANS7
ANSELH = %00000000 ; A/D disabled for ANS8->ANS13
CM1CON0 = %00000000 ; Disable comparators
CM2CON0 = %00000000 ; These default to disabled at POR, but just in case

; Initialize your Hardware first, set CONFIGs, OSC, Turn off A/D etc
;----[ Change these to match your LCD ]---------------------------------------
LCD_DB4 VAR PORTB.5
LCD_DB5 VAR PORTB.4
LCD_DB6 VAR PORTB.3
LCD_DB7 VAR PORTB.2
LCD_RS VAR PORTB.7
LCD_E VAR PORTB.6
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 ****

;HIGH PORTB.6

;----[ Your Main program starts here ]----------------------------------------

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
PAUSE 2000
LCDOUT $FE, $87, "Hello,", $FE, $C8, "From DT!"
PAUSE 2000

GOTO Main

END


I'd love to just hook up the LCD like PBP normally wants it, but I have no control over the PCB it's an existing design and I have to get it to work as-is (LCD on PortB:RB2-7)

Please x'cuse me while I go pull what's left of my hair out....

Ioannis
- 18th November 2009, 20:37
Are you sure LCD is OK?

Ioannis

Darrel Taylor
- 18th November 2009, 22:45
Is the RW pin on the LCD connected to the PIC, or is it grounded?
<br>

PICn-It
- 18th November 2009, 23:06
Are you sure LCD is OK?

Ioannis

Yes, when I plug it into another pic controlled unit I get both lines of verbiage expected.


Is the RW pin on the LCD connected to the PIC, or is it grounded?
<br>

The circuit board has the RW line hard-wired to ground.

Would it be better to re-post this Q over in the regular part of the forum since it's doesn't seem related directly to the LCD_Anypin extension? my thinking is it might be something peculiar to the 16F883 that someone may see and chime-in about.

PICn-It
- 19th November 2009, 16:16
Schematic attached.
(Note that in the code I'm not doing anythng with the sensor yet, and it's disconected from AN0 right now)

PICn-It
- 25th November 2009, 17:27
(sound of crickets chirping....)

Melanie
- 25th November 2009, 19:08
Just curious why you have LCD Data on RB2,3,4 & 5. If you simply moved them up two pins and moves E and RS down, you could use the standard PICBasic product with no modifications. I can understand if you have a PIC which doesn't have four consecutive pins available on a port, but why go to all the inconvenience when there is no need?

Darrel Taylor
- 25th November 2009, 19:13
In your code above, you have MCLRE enabled.

But in the schematic you don't have a pull-up on MCLR (Pin 1).
<br>

PICn-It
- 26th November 2009, 04:47
In your code above, you have MCLRE enabled.

But in the schematic you don't have a pull-up on MCLR (Pin 1).
<br>

I'll try adding that, thank you. I'm sorry to keep bugging you about this.


Just curious why you have LCD Data on RB2,3,4 & 5. If you simply moved them up two pins and moves E and RS down, you could use the standard PICBasic product with no modifications. I can understand if you have a PIC which doesn't have four consecutive pins available on a port, but why go to all the inconvenience when there is no need?

The circuit board is an existing design, I'd love to move things but I have to go with the produced PCB. The next thing one might wonder is how a person like me ends up with this on his plate? well I have VB, C, C++, MFC and C# experience and someone, in their infinite wisdom thought I'd be good to take this on as a "challenge". What I have absolutely zero experience with is PIC microcontrollers which seems to be a long-shot away from Windows programming.

I'm sorry if I'm testing anyone's patience over this, perhaps PBP isn't the right tool for this task, perhaps I'll look into some C implementations for achieving this task.

Ioannis
- 26th November 2009, 08:25
Unless Darrel has done this routine in C, I think you won't find a solution in other places...

Ioannis

sayzer
- 26th November 2009, 09:02
I touched nothing on your code.

Just compiled it as is.

And it works with no problem as seen in the simulation (attached).



http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3806&stc=1&d=1259222341

Darrel Taylor
- 26th November 2009, 09:43
WooHoo!
Now there's a $1000 simulation. http://www.picbasic.co.uk/forum/images/icons/icon14.gif
<br>

PICn-It
- 29th November 2009, 16:00
I touched nothing on your code.

Just compiled it as is.

And it works with no problem as seen in the simulation (attached).



http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3806&stc=1&d=1259222341

Actually I see you have a pull-up on pin 1 and also have pin 7 tied low.

I don't see how pin 7 can be any problem for me but looking at the PCB I notice it doesn't have the pull-up on pin 1.

Existing (pre-programmed) 16F883's I have on my bench are working fine when inserted into this PCB so I have reservations thinking that's the problem at hand.

Thanks for your responses everyone.

Pic_User
- 29th November 2009, 16:35
Actually I see you have a pull-up on pin 1 and also have pin 7 tied low.

I don't see how pin 7 can be any problem for me but looking at the PCB I notice it doesn't have the pull-up on pin 1.

Existing (pre-programmed) 16F883's I have on my bench are working fine when inserted into this PCB so I have reservations thinking that's the problem at hand.

Thanks for your responses everyone.
See Darrel's Question...

In your code above, you have MCLRE enabled.

But in the schematic you don't have a pull-up on MCLR (Pin 1).
<br>

Is the RW pin on the LCD connected to the PIC, or is it grounded?
<br>

PICn-It
- 30th November 2009, 16:46
See Darrel's Question...

I'm sorry I don't understand your post, but I tried it with MCRLE_OFF and it makes no difference. I must have some other issues I'm yet unaware of. I have ordered a proper dev board so when that comes maybe I can get a handle on the problem.

I had set MCRLE_ON from trying to interpret the data sheet:

Page-212:
MCLRE: RE3/MCLR pin function select bit(4)
1 = RE3/MCLR pin function is MCLR
0 = RE3/MCLR pin function is digital input, MCLR internally tied to VDD

Page-215 (14.2.2)
An internal MCLR option is enabled by clearing the
MCLRE bit in the Configuration Word Register 1.

When MCLRE = 0, the Reset signal to the chip is generated
internally. When the MCLRE = 1, the RA3/MCLR pin
becomes an external Reset input. In this mode, the
RA3/MCLR pin has a weak pull-up to VDD.

These data sheets are a long read and at times I'm having trouble interpreting some of the pages.

PICn-It
- 12th December 2009, 06:04
Ok, making great progress.

I recieved my development board, plugged everyting in and coded up the demo example again ....and I'm getting text! :)
(woo-hoo!)

I'm getting:

#numbers Hello,
$hex From DT!

is this correct?

Darrel Taylor
- 12th December 2009, 19:08
Yessiree!
That's what you should get.
And the numbers should be counting.

Congratulations! http://www.picbasic.co.uk/forum/images/icons/icon14.gif
<br>

Peter.
- 3rd July 2010, 23:06
Darrel,

Top thanks to you for sharing such nifty code. Like your Bargraph code, I got it to work first time.
If by chance that you are still running this thread, would you perhaps let me know what I'm doing wrong when I hook all 6 LCD lines to the same Port? It works fine when I hook E and RS to separate Ports.
This is my first time with MPASM. I had to comment-out the config line, else it doesn't assemble.

Thanks again.
Respect for knowing all what you know about PICs.

Darrel Taylor
- 4th July 2010, 19:18
Hi Peter,

I'm not sure what the problem is, but I ran your program on a 16F877a with all the LCD pins on PORTB, and everything worked fine.
Although, with the pinout you are using ... you don't really need the LCD_AnyPin program (the data bus is on RB4-7).


4592

For the config error, see this page ...
http://melabs.com/support/config_defaults.htm

Peter.
- 4th July 2010, 21:18
I'm gobsmacked.
Many thanks for taking the time to do that just on my account. Really appreciated.

Your photo has given me a good clue; I see that you are using B.2 and B.3. Up til now I'd been using B.0 and B.1 only.
It turns out that it only works from B.1 onwards (with both PBP *and* LCD_AnyPin). I thought it might be because of a hardware fault, but B.0 is fine with a temporary LED.
It's all rather strange because the PBP manual implies that any PortB pin should work.

Do you mind if I trouble you for one more question, pse?
Could you have a look at my CONFIG and perhaps let me know why MSC gives an error when I try to compile without the semicolon?

Thanks again to you for doing all that work on my account.

Darrel Taylor
- 5th July 2010, 09:23
Well, I moved E and RS to RB0 and RB1 ... it still works.

You might try turning that LED around and see if PORTB.0 will drive the output both ways.
It could be that half of the output stage is toasted.

And for the config error, you just need to comment the default configs in the .inc file.
See this page ... http://melabs.com/support/config_defaults.htm

Peter.
- 15th July 2010, 19:01
It could be that half of the output stage is toasted.


Thanks again, Darrel.

You will no doubt be chuffed to hear that your prognosis was 100% correct.
I tried your LED suggestion and can confirm that PortB.0 was indeed dead - both ways. I've just taken delivery of some new '877s. Your LCD_AnyPin and all Ports are now working perfectly.

I think I owe you an apology for sending you all around the houses in the first place; I really should have had the noodle to check that port with a LED before bothering you. For what it's worth, I'm sorry for wasting your time, but I do appreciate you coming back just the same.

From myself, and on behalf of all the other members here, top thanks to you for sharing your work, and top thanks for sharing your much-appreciated know-how.

Thanks also for the heads-up regarding the Config thing.

Kamikaze47
- 4th August 2010, 15:10
Is there something I can do that will make LCD_AnyPin work with PBPL?

This is the test code im using.


LCD_DB4 VAR PORTA.4
LCD_DB5 VAR PORTA.2
LCD_DB6 VAR PORTA.3
LCD_DB7 VAR PORTB.0
LCD_RS VAR PORTA.0
LCD_E VAR PORTA.1
LCD_Lines CON 2
LCD_DATAUS CON 50
LCD_COMMANDUS CON 2000

INCLUDE "LCD_AnyPin.pbp"

LCDOut $FE,1,$FE,2,"Hello World!"

END

It compiles and works fine with regular PBP, but I get this error when I use PBPL:


ERROR: (HighJacked-LCDOUT Not found in PBPPIC??.LIB)

Any ideas? I suspect I'll need to edit another PBP file, but i'm not sure.

ScaleRobotics
- 4th August 2010, 15:21
Is there something I can do that will make LCD_AnyPin work with PBPL?
Any ideas? I suspect I'll need to edit another PBP file, but i'm not sure.

You are right. You need to edit pbppi18l.lib as you did pbppic18.lib, and it should work. Don't forget to save a copy, just in case.

Kamikaze47
- 4th August 2010, 17:03
You are right. You need to edit pbppi18l.lib as you did pbppic18.lib, and it should work. Don't forget to save a copy, just in case.

Thanks scalerobotics. That worked :)

sinoteq
- 16th October 2010, 12:15
Hi
I am running out of pins so it is time to implement LCD_Anypin but I have a question. Do I need the standard PBP defines also? You know the DEFINE LCD_REG, DEFINE LCD_BITS and so on.

I want to interface a 4 lines 16 characters display to my project using a 4 bit databus.
My guess is I need DEFINE LCD_BITS 4 and DEFINE LCD_LINES 4


This will be the second DT code I include, the fist one is of course DT-Interrupts :):) and I bet LCD_Anypin will be equally usefull.

mackrackit
- 16th October 2010, 14:32
Read the sample code and comments here :p
http://www.picbasic.co.uk/forum/showthread.php?t=7038&p=43345#post43345

1 = 2
2 = 4

naginar
- 25th October 2010, 09:09
Using the Darrel Taylor LCD_AnyPin.pbp as a template i adapted the 2 wires idea of M. Predko to be used in PICBASIC. (LCDOUT)
The new .pbp patch is not so professional as the original (maybe Mr Darrel Taylor can fix it), but is working.
Only two pins (any) of the uC are neded to drive the LCD display (44780 type).
The example is for 16F628A uC.
Some time is very useful to have more pins available.

Guido

Hope the attachment PBP_2WSLCD.zip is inserted correctly!

Darrel Taylor
- 25th October 2010, 14:04
Woohoo!
Nice work Guido! http://www.picbasic.co.uk/forum/images/icons/icon14.gif

I copied your post to the LCD's with Shift Registers, and LCDOUT (http://www.picbasic.co.uk/forum/showthread.php?t=7139) thread too.

naginar
- 25th October 2010, 16:25
Thanks Darrel for the "nice work", but i would like to thanks for the outstanding base you did.
Best regards.
Guido

Acetronics2
- 27th October 2010, 17:21
Woohoo!
Nice work Guido! http://www.picbasic.co.uk/forum/images/icons/icon14.gif

I copied your post to the LCD's with Shift Registers, and LCDOUT (http://www.picbasic.co.uk/forum/showthread.php?t=7139) thread too.

Hi, Darrel

as " LCD on anypin " was ... not intended for 8 pins Pic 12 series

But now, as only two pins are needded ...

is "LCD on anypin" compatible with PBPPIC12.lib .... ???

Alain

Darrel Taylor
- 28th October 2010, 18:20
I had a look at the Library and NOPE ...

No way to do it on a chip with only 2 stack levels (12-bit core).

There are several other 8-pin pics with 14-bit cores. 12F629, 675, 683 ...
It'll work fine on those.

Acetronics2
- 1st November 2010, 09:39
I had a look at the Library and NOPE ...

No way to do it on a chip with only 2 stack levels (12-bit core).

There are several other 8-pin pics with 14-bit cores. 12F629, 675, 683 ...
It'll work fine on those.

Hi, Darrel

thanks for the point.

So, ... in this case THIS would be a solution to test, avoiding the " Backpacks"
http://www.romanblack.com/shift1.htm

Alain

Darrel Taylor
- 1st November 2010, 14:52
That's pretty neat.

But with the new PIC's costing $1 or less, and could do a full 8-bit interface on a back-pack with an internal OSC.
That one seems pretty expensive with all the extra parts.

Acetronics2
- 1st November 2010, 21:17
That's pretty neat.

But with the new PIC's costing $1 or less, and could do a full 8-bit interface on a back-pack with an internal OSC.
That one seems pretty expensive with all the extra parts.

Hi, Darrel

you just need the serial to // 8 bits register ( 74xx164, or 595 w/ latch if I'm right ...) and caps & resistors, not the whole 12$ board !!!

that's much closer to a small Pic cost ...

I used this kind of config for my R/C decoders ... 30 years ago. nothing really new under the sun ... ;)

Alain

bogdan
- 18th November 2010, 03:50
Is there something I can do that will make LCD_AnyPin work with PBPL?

This is the test code im using.


LCD_DB4 VAR PORTA.4
LCD_DB5 VAR PORTA.2
LCD_DB6 VAR PORTA.3
LCD_DB7 VAR PORTB.0
LCD_RS VAR PORTA.0
LCD_E VAR PORTA.1
LCD_Lines CON 2
LCD_DATAUS CON 50
LCD_COMMANDUS CON 2000

INCLUDE "LCD_AnyPin.pbp"

LCDOut $FE,1,$FE,2,"Hello World!"

END

It compiles and works fine with regular PBP, but I get this error when I use PBPL:


ERROR: (HighJacked-LCDOUT Not found in PBPPIC??.LIB)

Any ideas? I suspect I'll need to edit another PBP file, but i'm not sure.

I have the same problem (ERROR: (HighJacked-LCDOUT Not found in PBPPIC??.LIB) with a 16F1933 using pbp2.60 ... are there any other things wich have to be changed into the libraries ?

Best Regards,
Bogdan

Darrel Taylor
- 18th November 2010, 04:27
Each family of PIC's has it's own library.

PBPPIC14.lib is for the normal 14-bit cores (12, 16F).
PBPPIC18.lib is for the 18F's.
PBPPI18L.lib is for 18F's with PBPL (longs).
And PBPPI14E.lib is the enhanced 14-bit cores.

The HighJack routines should be installed in the corresponding .lib file for the PIC you want to use LCD_AnyPin with.

Once again ... make a copy of the file before editing it !!!!

bogdan
- 18th November 2010, 13:05
Thank You,
I was changing the PBPPIC14.LIB instead of the PBPPI14E.LIB .... NOW IS FINE

once again Thank You

bogdan
- 19th November 2010, 01:12
Do you think is a way to use LCDOUT (using LCD_AnyPin) to a HD66717 lcd module considering the diferences from HD44780 ?

4954

Darrel Taylor
- 19th November 2010, 02:19
Yes.

That should be easy to do.

Dave
- 19th November 2010, 12:45
bogdan , It sound like 8 bit instead of 4 bit mode....

Dave Purola,
N8NTA

sayzer
- 8th February 2011, 15:50
Each family of PIC's has it's own library.

PBPPIC14.lib is for the normal 14-bit cores (12, 16F).
PBPPIC18.lib is for the 18F's.
PBPPI18L.lib is for 18F's with PBPL (longs).
And PBPPI14E.lib is the enhanced 14-bit cores.

The HighJack routines should be installed in the corresponding .lib file for the PIC you want to use LCD_AnyPin with.

Once again ... make a copy of the file before editing it !!!!


For PIC16F737, I am getting "ERROR: (HighJacked-LCDOUT Not found in PBPPIC??.LIB"

The HighJack routine is in all the files needed.

What am I missing?

Thank you.

Darrel Taylor
- 8th February 2011, 16:47
Do you have more than 1 installation of PBP?
MCS or MPLAB may be looking at a different folder.

Or the routines may be inserted in the wrong lines of the .lib file.

sayzer
- 8th February 2011, 17:02
Hi Darrel,

It is compiling it for other PICs with no problem.

And checking the lines of the files for inserted codes, they are all ok.

Darrel Taylor
- 8th February 2011, 19:42
The library file used with the PIC16F737 is PBPPIC14.lib
If it compiles for other 16F's like an 877a then I don't see a reason for it to not compile for the 737.

Do you have any LCDOUT commads in your program? Or are you trying to compile the include by itself?

If there are no LCDOUT statements, the HighJack routines will not be included.

sayzer
- 9th February 2011, 07:43
The library file used with the PIC16F737 is PBPPIC14.lib

If there are no LCDOUT statements, the HighJack routines will not be included.

There is the issue.

In fact, it was among my notes, but I missed it.

Problem solved.

Thank you Darrel.

pmacleod
- 16th February 2011, 08:50
Is it possible to take this 1 step further and support LCDs with 2 Enable pins?

Darrel Taylor
- 16th February 2011, 15:56
Yes, we've done that.

If you don't need to scatter the data bus pins, you can do it with this ...
http://www.picbasic.co.uk/forum/showthread.php?t=626&p=2388#post2388

Or if the data bus need to be scattered, there's this thread ...

In particular post #35 (http://www.picbasic.co.uk/forum/showthread.php?t=7596&p=47417#post47417), but read the whole thread.
http://www.picbasic.co.uk/forum/showthread.php?t=7596

Ziko87
- 18th July 2011, 18:55
Hi,

I have try with succes the library but I have a strange error. I have compiled this simple part of code:



LCD_DB4 var PORTB.1
LCD_DB5 vAR PORTB.2
LCD_DB6 VAR PORTB.3
LCD_DB7 VAR PORTB.4
LCD_RS VAR PORTB.5
LCD_E VAR PORTC.5
LCD_LINES CON 1
LCD_DATAUS CON 50
LCD_COMMANDUS CON 1500
OSC con 20

TRISA.0 = 1
TRISB = 0
TRISC = 0

INCLUDE "LCD_AnyPin.pbp"

pause 500
lcdout $FE,1
pause 250

Main:
lcdout $FE, $80, "Abcdef"
Ever:
high PORTA.1
PAUSE 500
LOW PORTA.1
PAUSE 500
GOTO Ever


When I run this I see odd things like "AAdfg" or " dAfg" etc etc. I think that is a timing error, you have suggestion for this kind of error?

Thank you (and sorry for my bad english).

sayzer
- 18th July 2011, 19:14
What is this "OSC con 20" doing in there?

Ioannis
- 18th July 2011, 21:08
Also use these:



DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 100


NOT these:


LCD_DATAUS CON 50
LCD_COMMANDUS CON 1500


Ioannis

Darrel Taylor
- 18th July 2011, 22:48
It should be the constants, not the defines.

But Sayzer is right. OSC con 20 will not compile if you have used DEFINE OSC 20.
Which means PBP thinks your PIC is running at 4Mhz.

Ziko87
- 19th July 2011, 09:50
It should be the constants, not the defines.

But Sayzer is right. OSC con 20 will not compile if you have used DEFINE OSC 20.
Which means PBP thinks your PIC is running at 4Mhz.

Sorry you guys, I wrote:

OSC WITH 20

but I had to write:

DEFINE OSC 20

I could not understand the error because it compiled correctly. Thanks to all.

jellis00
- 27th July 2011, 00:18
Was LCD_AnyPin included in PBP version 2.6 as was suggested a couple of times in this thread? If not, why not?

jellis00
- 11th August 2011, 01:34
Now that PBP3 is released let me re-phrase my above question: Was LCD_AnyPin included in PBP3 and if not, why not?

mister_e
- 11th August 2011, 01:36
Not it's not, because it's not a common and frequent way to use an LCD.

Darrel Taylor
- 11th August 2011, 06:52
The mechanism used in LCD_ANYPIN that overrides library commands was used in PBP3.

However, it was used in the HPWM command due to necessity.
Microchip changed the 18FxxK80 parts so much that the CCP modules were not compatible with the old HPWM library code.

So Jeff wrote some new HPWM routines, I came up with a way to replace the existing library routines (borrowing from LCD_AnyPin), then Charles did the actual implementation on a chip by chip basis in the .pbpinc files. Really cool stuff.

We've talked about it alot, and as long as no bad side affects are found with the K80 HPWM commands ... one possibility is to allow overriding many of the library functions with new routines, and I'm sure LCD_AnyPin will be one of the first if that happens.

Steve,
In another thread you mentioned PBP_HARDWAREDEF.
That's part of the library override.

In the .pbpinc file for a K80, that macro is declared.
It is simply a #include, that adds the new code for HPWM.

A #define is added too (HPWM_OVERRIDE).
The old library code is wrapped with IFNDEF HPWM_OVERRIDE, so with the define ... the old routines are eliminated and the new included routines take over.

Imagine overriding HSERIN/HSEROUT to use buffers. :)

mister_e
- 11th August 2011, 07:08
Thanks for the explanation, still waiting the user command (whatsoever it is called) explanation ;)

I can imagine a load of override AND overload without any problem...I also have no problem to imagine why people think we are so excited about that. And, finally, I have no problem to imagine how many rants & questions this will bring as well... :cool: maybe we can finally get rid of those "WHY my LED do not blink on PORTA" questions? :D

mister_e
- 11th August 2011, 07:12
; Additional header code to accommodate device-specific library routines
#header
#define HPWM_OVERRIDE 1
PBP_HARDWAREDEF macro
#include PBP_PATH\HPWM_K80_1.HWLIB
endm
#endheader
Hhhhhhhhhhha! Another thing to chew on... even if it's just fow HPWM now....

HPWM "Hello", 13,10 :D

sougata
- 5th November 2011, 04:28
Hi,

Another weird proposition.

LCDOUT is a blocking command if I am not wrong and it would be great if a task/que scheduler like app could be designed. During command delay it wastes 2 ms. I believe a whole LCD update/refresh within 200ms should be acceptable.

So the idea is keeping a buffer equal to the total number of LCD character and updating the LCD from it character by character at 2ms interval, through an ISR. So a LCDOUT $FE, 1 just clears the buffer and LCDOUT puts the character in buffer rather than sending it directly to LCD I/Os. Making the timebase 1ms maybe through a compare module may couple other functions as well. RTC for example, non-blocking interrupt compatible delays, MUX options on the LCD lines etc. Use of 2 dimensional arrays makes it possible to have different LCD display screens ready to called just by a pointer may be automatically, sequentially, unattended.....

Hey I am not drunk ........I did it a couple of years back in a hard way. LCD being handled entirely in ASM and not compatible with LCDOUT.

Can't afford 2ms delays in my sinewave inverter (Work in Progress for a PBP WiKi)

tasmod
- 27th January 2012, 15:56
Hi,

I'm trying to use LCD_Anypin with an external clock but I'm not having success. Pic 16f819 (Posted in another thread in PBP Pro)

I wrote some code incorporating LCD_Anypin and ran it on a development board with a 10Mhz crystal oscillator. I used one odd pin for the LCD.

It compiled with DEFINE OSC 10 and it ran perfectly on the development board.


I then placed the chip into a working board using an external 10Mhz clock input and set the fuses accordingly. This was the only change in hardware.

Software wise I tried DEFINE EXTCLK_OSC and the same plus 10 on end, I also tried OSC 10 as well. Both these produced an output on the LCD but very oddly.

4 line display. As a test I did LCDOUT $FE,$80,"TEST" and LCDOUT $FE,$94,"AAAA"

resulted in:-

1st Line has a flashing cursor at the end of the line.
2nd line blank
3rd line has ooo<
4th line blank

Adding charactrs to the LCDOUT matches character count on 3rd line. i.e AAAAAA produces ooooo<

I wondered if there was something specific timing wise that LCD_Anypin wouldn't work correctly with an external clock?

Anyone any ideas why I get the gobbledegook output with ext clk and correct text with xtal input??

Thanks

RCtech
- 30th May 2014, 18:22
Hello.
Old thread but so useful !
Thanx to Darrel.

Fyi this mod seems not working with SPLC780D / 4 lines / 20char.
It compiles but the screen show various contrasts.

I'll try with a HD44780 next week and will confirm.

RCtech
- 2nd June 2014, 09:27
I'checked today and did a try vith an LCD 2 lines and same issue.
Then I suppose the problem doesnt come from the screen.

PIC : 16F685
PBP : 2.60C
Modded files : pbppic14.lib pbppi14e.lib pbppic18.lib pbppi18l.lib
Added files in PBP dir : LCD_AnyPin.pbp & VirtualPort.bas
Shematic is exactly identical in case one and 2.

Case one - The code below works with modded files but without use AnyPin function :


@ device PIC16F685, intrc_osc_NOCLKOUT, wdt_off, pwrt_on, mclr_off, protect_off, bod_on

ANSEL = %00000000 ' Set pin AN0 to AN7
ANSELH = %0000 ' Set pins AN8 to AN11

'================================================= ==============================
Define LCD_COMMANDUS 2000 ' Command Delay (uS)
Define LCD_DATAUS 50 ' Data Delay (uS)

DEFINE LCD_DREG PORTB ' Set LCD Data on PORTB
DEFINE LCD_DBIT 4 ' Set starting Data bit on PORTB.4 (0 or 4) if 4-bit bus i.e, PortB.4-PORTB.7
DEFINE LCD_RSREG PORTC ' Set LCD Register Select on PORTA
DEFINE LCD_RSBIT 6 ' Set LCD Register Select bit on PORTA.4 (PORTA.3 is only in input mode)
DEFINE LCD_EREG PORTC ' Set LCD Enable on PORTC
DEFINE LCD_EBIT 7 ' Set LCD Enable bit on PORTC.7
DEFINE LCD_BITS 4 ' LCD in 4 bit mode
DEFINE LCD_LINES 2 ' 4 lines LCD display
'================================================= ==============================

;----[ 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
PAUSE 1000
LCDOUT $FE,"Starting..."
PAUSE 1000

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


Case two - The code below doesnt work with modded files and using AnyPin function :


@ device PIC16F685, intrc_osc_NOCLKOUT, wdt_off, pwrt_on, mclr_off, protect_off, bod_on

ANSEL = %00000000 ' Set pin AN0 to AN7
ANSELH = %0000 ' Set pins AN8 to AN11

'================================================= ==============================
'Pins free assignment with Hijack by Darrel Taylor [http://www.picbasic.co.uk/forum/showthread.php?t=7038]
LCD_DB4 VAR PORTB.4
LCD_DB5 VAR PORTB.5
LCD_DB6 VAR PORTB.6
LCD_DB7 VAR PORTB.7
LCD_RS VAR PORTC.6
LCD_E VAR PORTC.7
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"
'================================================= ==============================

;----[ 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
PAUSE 1000
LCDOUT $FE,"Starting..."
PAUSE 1000

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


In both cases, it compiles well without error but with AnyPin, the screen seems not initializing.

Cause AnyPin was realised before the 2.60C PBP ver., is there a compatibility issue ?

Thanx a lot for any help.

Darrel Taylor
- 2nd June 2014, 19:14
LCD_AnyPin works with all versions of PBP from 2.46 and later.

But you'll need to use the MPASM assembler.
Which means you also need to change your @ DEVICE statement.

@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOR_ON & _IESO_OFF & _FCMEN_OFF
Don't forget to comment the default __config line in the 16F685.inc file in your PBP folder.

And you have started a command sequence in your LCDOUT line ... but there's no command.

LCDOUT $FE,"Starting..."

That will do strange things to the LCD.

After assembling with MPASM, and removing the LCDOUT line ... this is what I get with a 16F685 and PBP 2.60 ...

http://support.melabs.com/DT/LCD_AnyPin_16F685.gif