Don't improvise or over think it. Just copy/paste and modify for your pins.
<br>
Don't improvise or over think it. Just copy/paste and modify for your pins.
<br>
DT
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:
Code: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)Is the error on line 87 something I've done/not-done?
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
Last edited by PICn-It; - 15th November 2009 at 08:46.
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.
I'm still not getting anywhere with this.
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:
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)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
Please x'cuse me while I go pull what's left of my hair out....
Is the RW pin on the LCD connected to the PIC, or is it grounded?
<br>
DT
Yes, when I plug it into another pic controlled unit I get both lines of verbiage expected.
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.
Schematic attached.
(Note that in the code I'm not doing anythng with the sensor yet, and it's disconected from AN0 right now)
Last edited by PICn-It; - 19th November 2009 at 16:21.
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?
In your code above, you have MCLRE enabled.
But in the schematic you don't have a pull-up on MCLR (Pin 1).
<br>
DT
I'll try adding that, thank you. I'm sorry to keep bugging you about this.
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.
Unless Darrel has done this routine in C, I think you won't find a solution in other places...
Ioannis
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/atta...1&d=1259222341
Last edited by sayzer; - 26th November 2009 at 09:06. Reason: typo
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
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.
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.
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?
Yessiree!
That's what you should get.
And the numbers should be counting.
Congratulations!
<br>
DT
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.
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).
For the config error, see this page ...
http://melabs.com/support/config_defaults.htm
DT
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.
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
DT
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.
Is there something I can do that will make LCD_AnyPin work with PBPL?
This is the test code im using.
It compiles and works fine with regular PBP, but I get this error when I use PBPL:Code: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
Any ideas? I suspect I'll need to edit another PBP file, but i'm not sure.Code:ERROR: (HighJacked-LCDOUT Not found in PBPPIC??.LIB)
"I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams
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.
Read the sample code and comments here
http://www.picbasic.co.uk/forum/show...3345#post43345
1 = 2
2 = 4
Dave
Always wear safety glasses while programming.
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!
Woohoo!
Nice work Guido!
I copied your post to the LCD's with Shift Registers, and LCDOUT thread too.
DT
Thanks Darrel for the "nice work", but i would like to thanks for the outstanding base you did.
Best regards.
Guido
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
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.
DT
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
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
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.
DT
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
Last edited by Acetronics2; - 1st November 2010 at 21:22.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks