PDA

View Full Version : Please help...



karenhornby
- 9th April 2008, 12:31
I've done a stupid thing, I'm trying to learn how to program PIC's and thought I was doing well by getting a copy of PicBasicPro
All every well, then I needed someway of programming the pic to try it out, so me being a smartass went and got the EasyPic5 development board as it included sockets for various Pic's and also came with a 2 X 16 LCD
Great board, but it uses MikroBasic and unless you spend another £99 your limited to 2k in your program....ARGHH
I Hate MikroBasic!
I've been trying to get this working (untill I can sell the easypic5 board) by writing and compiling the program in PBP and then programming the pic on the easypic board by using the programming software that came with it
btw if anyone wants an almost new Easypic5 board, contact me, it's going cheap and only used for this one thing!

This SEEMS to work fine, but I've a problem.
Going back to basics, I've tried writing the "Hello World" program, it compiles fine, seems to load fine but just wont display anything on the pic

The Pic is a 16F677A with an 8Mhz xtal
The LCD is connected on the board as follows:
RS RB4
RW Vss/Ground/0V
E RB5
D7 RB3
D6 RB2
D5 RB1
D4 RB0



Here is my code:
Code:
'LCD DEFINATION**************************************** *************************


DEFINE LCD_DREG PORTB ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus i.e, PortD.4-PORTD.7
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 4 ' Set LCD Register Select bit i.e, PORTC.5
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 5 ' Set LCD Enable bit i.e, PORTE.4
DEFINE LCD_BITS 4 ' Set LCD bus size ot 4 bit Upper Nibble (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD to 4 Lines
DEFINE LCD_COMMANDUS 2000 ' Set command delay time in us
DEFINE LCD_DATAUS 50 ' Set data delay time in us

'************************************************* ******************************
Pause 500 ' Wait for LCD to startup

loop: Lcdout $fe, 1 ' Clear LCD screen
Lcdout "Hello" ' Display Hello
Pause 500 ' Wait .5 second

Lcdout $fe, 1 ' Clear LCD screen
Lcdout "World"
Pause 500 ' Wait .5 second

Goto loop ' Do it forever

What Am I doing wrong? I'm sure its something really stupidly simple but I've spent so much time on this its frying my brain!
The board and LCD both work fine, I know because I've loaded several of the samples written already in Mikrobasic such as the one showing the lcd working and the temperature readout using the DS1820 both work fine.

Acetronics2
- 9th April 2008, 12:55
Hi, Karen

1) you just should place a " DEFINE OSC 8 " to tell PbP you use a 8Mhz clock and then respect the LCD Timings.

Note yo can use another 4 Mhz Xtal instead of the genuine 8 Mhz ...

I think that simple thing will allow your LCD to work properly ...


Considering your purchase ... why would it be an error ??? You can write and compile with PbP ( w. MPLAB or MICROCODE IDE ) ... and use EasyPic as a Programmer and Breadboard ...

Just use directly " PicFlash" ( load HEX ) instead of opening MkE IDE ...

Alain

karenhornby
- 9th April 2008, 13:02
Thanks for the suggestion, I changed the code to
DEFINE OSC 8
DEFINE LCD_DREG PORTB ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus i.e, PortD.4-PORTD.7
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 4 ' Set LCD Register Select bit i.e, PORTC.5
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 5 ' Set LCD Enable bit i.e, PORTE.4
DEFINE LCD_BITS 4 ' Set LCD bus size ot 4 bit Upper Nibble (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD to 4 Lines
DEFINE LCD_COMMANDUS 2000 ' Set command delay time in us
DEFINE LCD_DATAUS 50 ' Set data delay time in us but all I get is the same, a row of blocks on the 1st line of the LCD same as when you plug it in first with no program in the pic

Acetronics2
- 9th April 2008, 13:24
GASP ...

I've forgotten to tell you to set the OSC to HS ...

and then ... works fine !!! ... on my Easy 5 !!!

Alain

PS, works also with OSC set to XT ( default ) ... IF there's problem ... check Hardware ...

karenhornby
- 9th April 2008, 13:33
GASP ...

I've forgotten to tell you to set the OSC to HS ...

and then ... works fine !!! ... on my Easy 5 !!!

Alain

YAY Success :)
Thanks I owe you one :)

Acetronics2
- 9th April 2008, 13:36
One what ???

karenhornby
- 9th April 2008, 13:58
A drink:P

Is there any way of setting the OSC to HS in the program itself rather than having to change it on the programmer each time?

Acetronics2
- 9th April 2008, 14:14
Depends on the IDE you're using ...

For MPLAB :




@ __config _HS_OSC



For µCode Studio




@ DEVICE pic16F877a,HS_OSC



Alain

karenhornby
- 9th April 2008, 14:24
Depends on the IDE you're using ...

MicroCode Studio

Acetronics2
- 9th April 2008, 14:48
sooooo,

For µCode Studio




@ DEVICE pic16F877a,HS_OSC



Regards
Alain

karenhornby
- 9th April 2008, 14:58
Its really wierd...
It wont accept that or any of the other suggestions, the only way I could get the HS_OSC in the code so it produced no errors was to use DEFINE pic16F877a,HS_OSC
However, although this gives no errors when you compile it, when you try and program it using Picflash it still sets Oscillator to XT and not HS
guess i'll just have to keep an eye on it and change it whenever I program it

Acetronics2
- 9th April 2008, 15:03
DEFINE only sets PbP internal values ... doesn't deal with Pic Registers.

I think there is a consistent thread about that on the Forum, Written by Melanie.

A SEARCH will be welcome ...

Alain

mister_e
- 9th April 2008, 15:06
From post 1 to 5

Presetting Configuration Fuses (PIC Defines) into your Program
http://www.picbasic.co.uk/forum/showthread.php?t=543

Copy'nPaste
- 11th April 2008, 06:19
"I've been trying to get this working (untill I can sell the easypic5 board)"

Why sell ?
PicFlash is one of the fastest programmers out there, EP5 one of the most versatile dev boards you can find.

You just need to figure out how to use it properly :-)

mister_e
- 11th April 2008, 10:16
Seems the problem have been solved in another thread.
http://www.picbasic.co.uk/forum/showthread.php?t=8501&page=2

karenhornby
- 11th April 2008, 15:38
Seems the problem have been solved in another thread.
http://www.picbasic.co.uk/forum/showthread.php?t=8501&page=2

Whoops, sorry should have said here b4 now that it's been sorted

jellis00
- 13th September 2009, 06:24
btw if anyone wants an almost new Easypic5 board, contact me, it's going cheap and only used for this one thing!


It is available and still for sale, I would be interested. If still for sale, how much?
Drop me an email at [email protected].