PDA

View Full Version : LCD and 16F88



G-R-C
- 4th February 2007, 04:04
Hello all
Recently made the to switch from MBasic to PBP.

Here my trouble, my project is using a 16F88 with the 4MHz bootloader.
(So cool you can now use a bootloader with a 16 pin PIC)
Can download/read just fine with the hardware setup(Max232 chip,etc)
Even did a test program to blink an LED to check bootloader function.

However following the example in the book for LCDs (16f84) the LCD will
only display a solid black line. All connections have checked, rechecked
and then checked some more. Not a connection problem.

Here is the section that defines port/pins used for PIC to LCD.
Believe I has port A set to digital

Define LOADER_USED 1

Define LCD_DREG PORTA
Define LCD_DBIT 0
Define LCD_RSREG PORTA
Define LCD_RSBIT 4
Define LCD_EREG PORTB
Define LCD_EBIT 3
'Define LCD_BITS 4
'Define LCD_LINES 2
Define LCD_COMMANDUS 2000
Define LCD_DATA

' Allocate variables
command var byte ' Storage for command
i var byte ' Storage for loop counter
temp var word ' Storage for temperature
DQ var PORTB.7 ' Alias DS1820 data pin
DQ_DIR var TRISB.7 ' Alias DS1820 data direction pin

CMCON = 7'<===========BELEIVE THIS TURNS THE COMPATOR OFF!!

ADCON1 = 7 ' Set PORTA and PORTE to digital

Low PORTA.4 ' LCD R/W line low (W)
Pause 1000 ' Wait for LCD to start

Lcdout $fe, 1, "Temp in degrees C"' Display sign-on message


For some reason the "DEFINE" changed to "Define" when coping and pasting to
this post. In my code they are all capitol, etc "DEFINE"
What am I doing wrong.
Gordon

Archangel
- 4th February 2007, 04:17
Hello G-R-C,
the 16f88 has more going on than a 16f84. you need all 3 of these for this chip:
ADCON1 = 7 ' or ADCON1 = %00000111 'Disable A/D converter
ANSEL=%00000000 ' set all analog pins to digital
CMCON=7
Hope this helps
JS
edit: also look at this currant thread and follow the VB Highlighted tags.
http://www.picbasic.co.uk/forum/showthread.php?t=5646

G-R-C
- 4th February 2007, 04:24
Wow! Joe that was fast reply.

I'm going to try your suggestion right now. The

ANSEL=%00000000 ' set all analog pins to digital

is what I think is the missing piece.
Will let know how this goes.
Thanks for your help.
Gordon

G-R-C
- 4th February 2007, 04:28
Tried the

ANSEL=%00000000 ' set all analog pins to digital

still no luck. Just the solid black line across the
top of the LCD. Any other suggestions/ideas.

Thanks in advance.

G-R-C
- 4th February 2007, 04:48
Got going Joe.
Thanks for the tips and the link to the thread. Found it was a huge
help.

Thanks again, now I can move forward with this project.

Archangel
- 4th February 2007, 05:01
Hi Gordon,
It's like being married, it's not that you did anything wrong, maybe sometimes just not enough :)
I would add some housekeeping code like:


TrisA = %11110110 ' make port 0 and 4 outputs for lcd
TrisB = %11110000 ' make lower 4 bits outputs for lcd

I would add code to set the config fuses so as not to have to remember
when programming. I would temporaraly add an lcdout to run once at startup, something like:


start: ' this goes after your defines and adcon, ansel etc . . .
Lcdout $fe, 1, "Gordon's Thermometer"
pause 1000

main:
all of your other code goes here


goto main
end

just to make sure the lcd is working and I would add a pause 1000 just before that to allow lcd time to initialize.
If you do not see the splash screen, you won't see anything else, and then you know to check wireing, contrast etc . . .

savnik
- 4th February 2007, 10:22
Low PORTA.4 ' LCD R/W line low (W)
Pause 1000 ' Wait for LCD to start

Delete the first line and add a pullup ressistor to RA4

sayzer
- 4th February 2007, 10:35
What about the contrast POT of the LCD?

May be it is working but because it is too dark, you see nothing but blocks!

Trim the POT until you see something on LCD.

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

mister_e
- 4th February 2007, 12:12
or the LCD R/W pin is left floating or set to high. In your first code example you said

Low PORTA.4 ' LCD R/W line low (W)

As A.4 is actually the LCD RS bit, it can't work.. or i miss something?

BTW, i've tested it here, with your current setting, and it's working.


DEFINE LOADER_USED 1

Define LCD_DREG PORTA
Define LCD_DBIT 0
Define LCD_RSREG PORTA
Define LCD_RSBIT 4
Define LCD_EREG PORTB
Define LCD_EBIT 3
Define LCD_BITS 4
Define LCD_LINES 2
Define LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50

CMCON = 7 ' disable analog comparator
ANSEL = 0 ' disable ADCs
Pause 500 ' LCD start up delay

Lcdout $fe, 1, "LCD Test"

Here: goto here ' spin here forever

G-R-C
- 4th February 2007, 19:19
Hi All
I'm happy to say my LCD is up and running. I'm impressed by the number of
quick responses to my question.

Thanks to all for the replies and tips. You guys are great.
Gordon

mister_e
- 4th February 2007, 19:23
You're welcome!


You guys are great.
Yeah we know :D

Just to satisfy my own curiosity... what was the problem???

G-R-C
- 4th February 2007, 19:44
The problem was a couple of issues. The port wasn't set to digtal (ANSEL),
Another was the pull-up resistor was omitted. I checked the data sheet
to make sure the CMCON was turned off, but somehow didn't realize the
ANSEL register needed to be set to 0. Bet I wont forget about this register
in the furture.

Thanks again all.
Gordon

mister_e
- 4th February 2007, 19:55
Just to set the record. For this device and by the datasheet, PORTA.4 is not an open drain as some suggested. It's really a full CMOS output pin. So you don't even need the pull-up resistor.

But YES, you have to disable the internal analog comparators and ADCs.


Bet I wont forget about this register
Learning opportunity :D

Archangel
- 5th February 2007, 00:51
Just to set the record. For this device and by the datasheet, PORTA.4 is not an open drain as some suggested. It's really a full CMOS output pin. So you don't even need the pull-up resistor.

But YES, you have to disable the internal analog comparators and ADCs.


Learning opportunity :D
For the record, I checked the data sheet before telling him to put in ANSEL and is why I did not say to use pullup, and for the record I was surprised it did not need one.

mister_e
- 5th February 2007, 07:39
For the record :D, i was refering to post #7 (http://www.picbasic.co.uk/forum/showpost.php?p=32051&postcount=7)

But i have to agree, many pin have an open-drain output on this pin.

savnik
- 5th February 2007, 11:43
For the record :D, i was refering to post #7 (http://www.picbasic.co.uk/forum/showpost.php?p=32051&postcount=7)

But i have to agree, many pin have an open-drain output on this pin.
A half mistake. I learn from my error.

mister_e
- 5th February 2007, 18:25
As everybody should do, there's no problem at all.

Archangel
- 6th February 2007, 00:13
A half mistake. I learn from my error.
:) Mistakes are why I learn something everyday :)

G-R-C
- 6th February 2007, 03:07
Hey Guys.
In the PBP manual there is a circuit diagram with a 10K resistor (pull-up)
connected to +5 and A4. Also some of the portA pins require
pull-ups, though don't recall which ones. I'd have to read the data
sheets for both the 16F84(this is the PIC in the example drawn) and the
16F88. More than likely there are going to be differences between
the two.

Once again, thanks guys for getting this LCD working. The F88s are slick.
Bootloader and 4K of code space all in a small 18 pin DIP.

Gordon