PDA

View Full Version : LCD issue with EasyPIC5



manwolf
- 14th June 2008, 19:46
Following mister_e's suggestion, I decided to run the examples included with the board.

I don't use their compiler, but they include a HEX file and the code.



' *
' * Project name
' Lcd_Test (Simple demonstration of the LCD Library functions)
' * Copyright
' (c) MikroElektronika, 2005-2008
' * Description
' This is a simple demonstration of LCD library functions. LCD is first
' initialized, then some text is written at the first row.
' * Test configuration
' MCU PIC16F887
' Dev.Board EasyPIC5
' Oscillator HS, 08.0000 MHz
' Ext. Modules LCD 2x16
' SW mikroC v8.0
' * NOTES
' None.
' *

program Lcd_Test

dim text as string[16]

main:
ANSEL = 0 ' Configure AN pins as digital I/O
ANSELH = 0
text = "mikroElektronika"
Lcd_Config(PORTB,3,2,1,0,PORTB,4,7,5) ' Lcd_Init_EP5, see Autocomplete

LCD_Cmd(LCD_CLEAR) ' Clear display
LCD_Cmd(LCD_CURSOR_OFF) ' Turn cursor off
LCD_Out(1,1, text) ' Print text to LCD, 1st row, 1st column
Delay_ms(1000)
LCD_Out(2,6,"mikroE") ' Print text to LCD, 2nd row, 6th column
end.



Loaded this up and to my surprise nothing, zip, nada. LCD has blocks, LEDs off.

Using PIC16F887 included with the board.

But if I load one of their other LCD examples it works.

So I fired up PBP and wrote this.


' PicBasic Pro program to display a message on LCD

' Define LOADER_USED to allow use of the boot loader.
' This will not affect normal program operation.
'Define LOADER_USED 1
define OSC 8

' Define LCD registers and bits
Define LCD_DREG PORTB
Define LCD_DBIT 0
Define LCD_RSREG PORTB
Define LCD_RSBIT 4
Define LCD_EREG PORTB
Define LCD_EBIT 5

TRISB = 0
Low PORTB.4 ' LCD R/W line low (W)
Pause 250 ' Wait for LCD to start up


loop: Lcdout $fe, 1 ' Clear screen
Pause 250 ' Wait .5 second

Lcdout $FE, $80, "16F84 Working"
Pause 500 ' Wait .5 second

Lcdout $fe, $c0, "Board : 8MHz"
Pause 2000 ' Wait .5 second

Goto loop ' Do it forever
End


No luck with the 887 PortB.4 LED lights and stays on, but if I change to 16F84 it works fine so I know I'm not too crazy.

I have set the config bits every way I can think of, no luck.

I am sure I am over looking something. I am thinking about downloading MikoBasic but don't really see any point.
Can someone rub my nose in it?

skimask
- 14th June 2008, 20:20
Define LCD_RSREG PORTB
Define LCD_RSBIT 4

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

No luck with the 887 PortB.4 LED lights and stays on, but if I change to 16F84 it works fine so I know I'm not too crazy.

So, is PortB.4 the RS pin or the R/W pin?

Acetronics2
- 14th June 2008, 20:54
Hi, Manwolf

The '887 has ANALOG pins on PortB ... I believe.

sooooooo ....

I miss something in your listing.

Alain

PS: I already saw that on a ME "C" Forum ... LoL !!! ( you're not the only one !!! )

Alain

BobP
- 14th June 2008, 21:51
Hi Manwolf,

When using their hex files with their programming software (PicFlash) it somethines uses default fuses.
Check oscillator is set to HS not 'XT' on the programming software?
Also the link settings on the board are set ok?

The suplied hex file works ok on my EP5

Bob

manwolf
- 14th June 2008, 23:05
So, is PortB.4 the RS pin or the R/W pin?

According to their schematic RS Ski

skimask
- 14th June 2008, 23:22
According to their schematic RS Ski
Ok, you've got it described as both of them...it's just a note.
No harm done in setting the R/W pin permanently at the write level, unless you plan on using it's internal CGRAM for a bit of extra ram.

manwolf
- 15th June 2008, 00:10
Skimask- they have R\W hardwired to GND on this board.

Well, Acetronics gets the cookie today.

Adding:

INTCON = 0
ANSEL = 0
ANSELH = 0

Gets what I wanted on the LCD. Can't fix the EasyPic5 example code(yet). First learn how to crawl, then with luck I might be able to stand up.

So far I have been working with 3 different chips, 16F877A, 877, and 84 on two different boards. Should I continue that way or try to focus more on one combination until I get on my feet?

After spending a few nights reading posts here I saw most common problem was getting the darn chip configured and the ports set properly. I figured using 3 different MCUs would give me more chances to learn setting things up or break them as case may be. :o

I want to Thank all of the members who have responded to my posts, don't give up hope.
I may learn how to read the datasheets. Right now half is in english and the rest is in some ancient dialect that totally escapes me. :p

skimask
- 15th June 2008, 00:17
So far I have been working with 3 different chips, 16F877A, 877, and 84 on two different boards. Should I continue that way or try to focus more on one combination until I get on my feet?
Which PICs do you actually have on hand?

manwolf
- 15th June 2008, 00:30
Which PICs do you actually have on hand?

16F84
16F628
16F877
16F887

skimask
- 15th June 2008, 00:53
16F84
16F628
16F877
16F887

If it were me, I'd stick with the 16F887. (also pay attention with the older chips, whether or not they're the A version or not) The 84, 628, and 877 are old school. Nothing wrong with them at all.

The '887 is comparatively new, has a lot of features that the 877(A) doesn't have.
If you get used to the '887, everything it does/has easily translates down to the smaller PICs.
AND...everything the '887 does/has, can be ported to the higher end, faster, bigger, more complex 18Fxxx series.
As an example that I've used a few times with others...I build an MP3 player awhile back, started off with a 16F877A, ran out of code space, plugged in an 18F452 (double the code space), ran out of code space with that, plugged in an 18F4620.......All without physically changing ANYTHING in the circuit, just a few registers here and there needed to be changed.
In addition to that, I started out my latest project with an 18F4620, recently moved up to an 18F4685.
So...in summation:
PIC16F877A = 16K, PIC18F452 = 32K, PIC18F4620 = 64K, PIC18F4685 = 96K.
It's all about the toys :D

manwolf
- 15th June 2008, 01:15
It's all about the toys :D

ROFLMAO

So true, all older chips are A version.

Thanks for your advise I will focus on the 16F887. Time to break out the old checkbook and get a couple of spares. Guess I might pick up a couple of the 18Fs as well.

skimask
- 15th June 2008, 01:21
Thanks for your advise I will focus on the 16F887. Time to break out the old checkbook and get a couple of spares. Guess I might pick up a couple of the 18Fs as well.
Yep, get to know that '887.
As far as the 18F, if it was me...I'd grab a couple of 18F4550 (USB) and 18F4685 (lotsa code space + CAN). And if you want the smaller 28 pin package, 18F2550 and 18F2685.
There are newer ones out there...but I don't have any use for them at the moment so I can't comment on those.

Acetronics2
- 15th June 2008, 09:17
Can't fix the EasyPic5 example code(yet).
:p

Hi, Manwolf

Want to translate the MKE " LCD Test" you showed ad first post ???

Really Interesting to see the MKB and PbP differences for LCD commands ...

Now, for your LED ... Outputs are BISTABLE ... If you "tell" them to be High ... they stay high !!! ( stupid thing ! )

you also must "tell" them to turn LOW ...

Also remember you can't use LCD on PortB AND the PortB Leds on EasyBoards at the same time ... ( a look at the board scheme will lit your light )

You must use another Port for your Leds ...

A quick tour into PbP Manual seems useful ... you to see how " main" commands work.

Alain