Jump to content
Sign in to follow this  
Bannas

Lcd_driver.h

Recommended Posts

Bannas,

 

The is already one for a 4bit display.

 

If you install in the default place it can be found in:

 

C:\Program Files\SourceBoost\Samples\C\BoostC\boost4bit.c

 

Um, the name of this project doesn't help much does it :(

 

Regards

Dave

Share this post


Link to post
Share on other sites

I am struggling to understand (it's early days) how to configure the Ports for LCD libraries. My intention eventually is to use a PIC16F877A and an LCD in 4bit mode. If I load boost4bit.__c project and I want to use the SourceBoost LCD plugin how should I configure it? I mean what ports? I can see that trisa is set to outputs and that

#define LCD_E    0   
#define LCD_RW   2   
#define LCD_RS   1

 

I cannot however figure out what I should set DB4,5,6 & 7 to on the plugin. I know that DB0, 1,2 & 3 should be Vss in 4 bit mode. Initially I can experiment with a PIC16F84A but I have to avoid the use of RB0 because I need to count interrupts on that pin.

 

I expect that I will use LCDs a lot in the future so mastering how to use and adapt the library will be useful.

 

Conrad

Share this post


Link to post
Share on other sites

This thread is precisely what I'm working on.

 

I grabbed boost4bit.c, but whenever I build it, I get an error that says: "failed to generate expression" for every line in boost4bit.c that references something in lcd_driver.h. It's like the compiler doesn't even read lcd_driver.h, but if I put some syntactical junk in lcd_driver.h it finds it and fails on it. ;)

 

All I have in my project is these two files. I'm building for the P18F452.

 

Thanks,

 

Dan

Share this post


Link to post
Share on other sites

danmc77,

 

There where a number of little problems with the LCD driver code.

I have revisited the code and fixed them, I also improved the comments ;)

 

These changes will be available in the next release, or if you send a mail to support@picant.com I can send you the update now.

 

Regards

Dave

Share this post


Link to post
Share on other sites

To everyone,

 

I see that people are suffering with the old LCD code.

 

So until the next BoostC release is available I will maintain the following links:

 

Daves temporary LCD link

 

Please post here if you have success (or not) with the improved code.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Could not get the new LCD code to run in simulator. :( Compiled with the standard complaints about delay arguments.

 

*************************************************************

BoostC Optimizing C Compiler Version 2.0.1 Beta (for PIC16 architecture)

http://www.picant.com/c2c/c.html

Copyright© 2004-2005 Pavel Baranov

Copyright© 2004-2005 David Hobday

 

 

success

BoostLink Optimizing Linker Version 2.0.1 Beta

http://www.picant.com/c2c/c.html

Copyright© 2004-2005 Pavel Baranov

Copyright© 2004-2005 David Hobday

 

 

Warning: Unable to successfully create 'delay_us' for target with clock freq 4000000 Hz

Warning: argument of 'delay_10us' calls must have a value of 1 or more

Building CASM file

 

Memory Usage Report

===================

RAM available:68 bytes, used:44 bytes (64.8%), free:24 bytes (35.2%)

ROM available:1024 words, used:965 words (94.3%), free:59 words (5.7%)

 

Successful

Done

******************************

 

 

I put LED Block on port B to watch the LCD pins. Hangs up in simulation. Get the error that the code is lost

 

"Debugging...

 

Can't locate source line for the current instruction"

 

 

Another question? How does the PIC type get set without a #define PIC16FXX statement. If there is a statement of which PIC is used, does it

override the TARGET PIC in the SETTINGS above in the IDE?

Do they cross check each other or could I be compiling with the wrong PIC sometimes without knowing it?

 

Thanks,

 

Mike ;)

 

 

 

 

 

 

 

To everyone,

 

I see that people are suffering with the old LCD code.

 

So until the next BoostC release is available I will maintain the following links:

 

Daves temporary LCD link

 

Please post here if you have success (or not) with the improved code.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Mike,

 

I forgot to mention that you need to overwrite lcd_driver.h in the install directory with the new one, assuming the default install path is used, this is C:\Program Files\SourceBoost\include

 

I put LED Block on port B to watch the LCD pins. Hangs up in simulation. Get the error that the code is lost

 

"Debugging...

Can't locate source line for the current instruction"

 

Change menu Settings->Options-> Debugger tab -> check the "skip global initialisation code at debug startup box".

 

Another question? How does the PIC type get set without a #define PIC16FXX statement. If there is a statement of which PIC is used, does it

override the TARGET PIC in the SETTINGS above in the IDE?

 

You can't set the target type with a #define. The target type is set by the menu Settings->Target.

 

Please also check how you are connecting the LCD plugin, this is where most mistakes our made.

 

Follow this temporary link to see my configuration.

 

Regards

Dave

Share this post


Link to post
Share on other sites

I got new LCD code to run on the simulator by putting a RETURN statment in the lcd header file to keep it from getting hung up looking for the LCD ready signal. :(

 

I could not get conditional assembly with ifdef?

 

I tried:

 

#ifdef RUN_UNDER_SIM

return;

 

Conditional did not work? A direct RETURN statement worked! ;)

 

It is like the header file didn't know simulator was defined?

 

I still get the LOST Error message when debugging. Reset does not seem to work?

 

"Debugging...

 

Can't locate source line for the current instruction

Can't locate source line for the current instruction

Can't locate source line for the current instruction

 

"

 

I tried moving the old lcd driver to the PicDem2+ and had little

results. Now that this runs in the simulator with the 16F84A, I will

try the 18F452 and PicDem2+ next.

 

Thanks,

 

Mike

 

 

 

To everyone,

 

I see that people are suffering with the old LCD code.

 

So until the next BoostC release is available I will maintain the following links:

 

Daves temporary LCD link

 

Please post here if you have success (or not) with the improved code.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Changed the Port Assignments and Bit pins for control on you new LCD code.

Changed to Lower Nibble for LCD.

Changed Target to 18F452 to run on PicDem2+. PortD is output, Lower Nibble.

PortA is control, RS=3, RW=2, E=1.

 

Got the following Error, doesn't point me where to go? Can you tell anything from this error?

 

***********************************************************

BoostC Optimizing C Compiler Version 2.0.1 Beta (for PIC18 architecture)

http://www.picant.com/c2c/c.html

Copyright© 2004-2005 Pavel Baranov

Copyright© 2004-2005 David Hobday

 

 

4bitlcd.pp(1): error: failure

failure

Exit code was 1.

Removing target: 4bitlcd.obj

Failed to locate output file '4bitlcd.obj'

Done

 

Failed

**************************************************************

 

Got any ideas??? :o

 

Thanks,

Mike

 

 

 

 

 

 

Could not get the new LCD code to run in simulator.  :(  Compiled with the standard complaints about delay arguments.

 

*************************************************************

BoostC Optimizing C Compiler Version 2.0.1 Beta (for PIC16 architecture)

http://www.picant.com/c2c/c.html

Copyright© 2004-2005 Pavel Baranov

Copyright© 2004-2005 David Hobday

 

 

success

BoostLink Optimizing Linker Version 2.0.1 Beta

http://www.picant.com/c2c/c.html

Copyright© 2004-2005 Pavel Baranov

Copyright© 2004-2005 David Hobday

 

 

Warning: Unable to successfully create 'delay_us' for target with clock freq 4000000 Hz

Warning: argument of 'delay_10us' calls must have a value of 1 or more

Building CASM file

 

Memory Usage Report

===================

RAM available:68 bytes, used:44 bytes (64.8%), free:24 bytes (35.2%)

ROM available:1024 words, used:965 words (94.3%), free:59 words (5.7%)

 

Successful

Done

******************************

 

 

I put LED Block on port B to watch the LCD pins.  Hangs up in simulation.  Get the error that the code is lost

 

"Debugging...

 

Can't locate source line for the current instruction"

 

 

Another question?  How does the PIC type get set without a #define PIC16FXX statement.  If there is a statement of which PIC is used, does it

override the TARGET PIC in the SETTINGS above in the IDE?

Do they cross check each other or could I be compiling with the wrong PIC sometimes without knowing it?

 

Thanks,

 

Mike ;)

 

 

 

 

 

 

 

To everyone,

 

I see that people are suffering with the old LCD code.

 

So until the next BoostC release is available I will maintain the following links:

 

Daves temporary LCD link

 

Please post here if you have success (or not) with the improved code.

 

Regards

Dave

Share this post


Link to post
Share on other sites

MotoDog,

 

I'm now looking into the problem using the lcd display code with PIC18 on PicDem2Plus board.

 

I already have found an issue with the LCD templates arguments size when using PIC18 target.

 

This should be resolved very soon.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Dave,

 

I tried the 16F877 too. It gave the same errors. So it is just not the 18 core?

 

Thanks,

 

Mike :rolleyes:

 

 

 

 

MotoDog,

 

I'm now looking into the problem using the lcd display code with PIC18 on PicDem2Plus board.

 

I already have found an issue with the LCD templates arguments size when using PIC18 target.

 

This should be resolved very soon.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Mike,

 

I tried the 16F877 too. It gave the same errors. So it is just not the 18 core?

 

The zip file that the link (above) allows you to download has three files.

1) lcd_drive.h - please put this in the include directory.

2) lcd.__c and lcd.c - the project, put these in another directory somewhere. use this project file and build the project. Forget 4bitlcd.c.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Got the new files to compile after changing to PicDem2+ with a 16F877.

The display does nothing? Used the direct HEX file from BoostC and loaded

it with ICD2?

 

So still no workie! :rolleyes:

 

Thanks

Mike

 

 

 

Mike,

 

I tried the 16F877 too. It gave the same errors. So it is just not the 18 core?

 

The zip file that the link (above) allows you to download has three files.

1) lcd_drive.h - please put this in the include directory.

2) lcd.__c and lcd.c - the project, put these in another directory somewhere. use this project file and build the project. Forget 4bitlcd.c.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Hi Everyone.

 

These problem are all now fixed.

 

LCD code also now has the ability to print out numerical values in Hex, binary and decimal, and a gotoxy function to position the cursor. B)

 

The down side is that the new code required some fixes in the compiler template code, so is not useable until the next release :rolleyes:

 

Regards

Dave

Share this post


Link to post
Share on other sites

How soon will this be released Dave? I could really use this facility now :rolleyes:

 

I have all the support hardware for my Uni project done now apart from the PIC programming. This needs the most time as I am an inexperienced PIC programmer to say the least. As usual time is running out.

 

Until I can get some code that will allow me to use the display on my PICDEM 2 PLUS I can't proceeed. There is an asm file that came with the demo board that I could use but I'm unsure how to go about using it in conjunction with C code.

 

Conrad

Share this post


Link to post
Share on other sites

Me too! :lol:

 

Maybe you could "ASM" the routines that Microchip supplied?

Ask Dave if this is possible?

 

 

I spent over a week trying to get the LCD code working on a PicDem2.

I tried 16F and 18F parts. I did get simple LED flashing going with an 18F.

I am now a little "burned out" on this rather complicated procedure using these

templates. I have had better luck writting in ASM with MPLAB. I have done

several projects using the Hatachi LCDs.

 

I don't have a project, just trying to learn to use C2C and Boost C.

 

The PicDem2 seemed to be the ideal learing board, since I got it with ICD2.

I guess I am giving up until the next compiler release, unless there is something

similar in C2C, since that is the compiler I purchased?

 

I have not tried using the ICD debugging mode or running Boost C inside MPLAB7?

 

Is it possible to do limited debugging with the HEX or ASM files from Boost C in ICD2?

 

I would like to keep going?

 

Thanks,

Mike

 

 

 

 

How soon will this be released Dave? I could really use this facility now :o

 

I have all the support hardware for my Uni project done now apart from the PIC programming. This needs the most time as I am an inexperienced PIC programmer to say the least. As usual time is running out.

 

Until I can get some code that will allow me to use the display on my PICDEM 2 PLUS I can't proceeed. There is an asm file that came with the demo board that I could use but I'm unsure how to go about using it in conjunction with C code.

 

Conrad

Share this post


Link to post
Share on other sites

MotoDog,

 

I will send you the lcd_driver code and test release (not official release) of the compiler. You will then have a working LCD.

 

I have not tried using the ICD debugging mode or running Boost C inside MPLAB7?

 

Is it possible to do limited debugging with the HEX or ASM files from Boost C in ICD2

 

ICD2 can't be used from within BoostC, you need to use the BoostC toolsuit under MPLABs.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Dave,

 

I'm having a great time working with the Picdem2+ and your LCD driver. I should have a working C version of the .asm demo program within a week.

 

One little bug with the LCD driver:

 

If you do this: lprintf("Test:%d", 0);

 

It prints this: Test: :o

Rather than this: Test:0 :lol:

 

I'm dealing with this by having a conditional print statement for the time being.

 

Thanks,

 

Dan

Share this post


Link to post
Share on other sites

Dan,

 

If you do this: lprintf("Test:%d", 0);

 

It prints this: Test: 

Rather than this: Test:0 

 

Another work around is to use

 

lprintf("Test:%05d", 0);

 

This specifies '0' as the fill character and a field width of 5.

This will give output with leading zeros eg output would be:

Test:00000

 

Regards

Dave

Share this post


Link to post
Share on other sites

Dan,

 

If you do this: lprintf("Test:%d", 0);

 

It prints this: Test: 

Rather than this: Test:0 

 

I have now fixed this :o

 

I'll mail you the update.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Dave,

 

Thank you.

 

Just some general rambling:

Last night I got the ADC working. One little bite was that the Pic document I had been referring to was for the 18F4520, thinking that it was plug compatible and code compatible with the 18F452. Not so. With the 4520 the ADC Go/Done bit is in adcon0 bit 1, but with the 452 it's in bit 2.

 

It's fun how the RB0 LED shares the same portb pin with the S3 pushbutton. You can drive the LED, then briefly change to input and check the switch without even seeing a flicker. :o

 

Dan

Share this post


Link to post
Share on other sites

Hi:

I've testing the project examples under the Boost C and C2C

with the folowing results:

 

Inter.c compiles fails to build

 

Serial_test.c compiles builds with warnings

 

randtest.c compiles builds with warnings using boost C simulation works

 

LCD.c fails to compile fails to build using boost C

 

interrupt.c fails to compile fails to build with C2C and bootC

comments don't indicate the target PIC. but says will run boost C compiler.

 

I2C_test.c fails to compile fails to build

comments don't indicate the target PIC

 

 

 

Am I the only one seeing these problems?

I am a beginner, but to find these problems is dissapointing, time consuming, frustating. I am using win XP pro. have Mplab 7.1, sourceboost 5.9.5

 

It is my personal opinion that examples should compile, build and run flawless or not be there, again just my opinion. Comments should provide all the nescessary setup info for beginners like myself to run examples

 

 

Thanks

Share this post


Link to post
Share on other sites

Dino,

 

There's a tremendous variety of different PIC processors, so you could have problems if there a mismatch. If the code does not state what PIC it's designed for, then you don't want to try to run it or even build it, just look at how they program in BoostC.

 

I submitted a BoostC-based demo program for the Picdem2 Plus demo board from Microchip. It's very heavily commented and (I think) very well written and runs well. It runs with the 18F452 and 16F877 on this demo board. Hopefully they will get it up in the example section soon.

 

Dan

 

Hi:

I've testing the project examples under the Boost C and C2C

with the folowing results:

 

Inter.c        compiles    fails to build

 

Serial_test.c  compiles  builds with warnings

 

randtest.c      compiles  builds with warnings  using boost C  simulation works 

 

LCD.c            fails to compile fails to build using boost C

 

interrupt.c      fails to compile fails to build  with C2C and bootC

comments don't indicate the target PIC.  but says will run boost C compiler.

 

I2C_test.c  fails to compile fails to build

comments don't indicate the target PIC

 

 

 

Am I the only one seeing these problems? 

I am a beginner, but to find these problems is dissapointing, time consuming, frustating. I am using win XP pro.  have Mplab 7.1, sourceboost 5.9.5

 

It is my personal opinion that examples should compile, build and run flawless or not be there, again just my opinion.  Comments should provide all the nescessary setup info for beginners like myself to run examples

 

 

Thanks

Share this post


Link to post
Share on other sites

:)

 

Dave,

 

when I try to compile the code from your link above in Boostc 2.2, I get a nice laundry list of problems. since this is supposed to be the latest and greatest revised code, any clues why an out-of-the-box (ok, out of the ZIP) compile would give these errors? (I did copy the revised lcd_driver.h to the default include directory, as well)

 

I tried with the 16f84A target (just to be sure), and my actual target of the 16f648a.

 

Jonathan

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

 

BoostC Optimizing C Compiler Version 2.2 Beta (for PIC16 architecture)

http://www.picant.com/c2c/c.html

Copyright© 2004-2005 Pavel Baranov

Copyright© 2004-2005 David Hobday

 

 

lcd.c(287:2): error: template arguments missing in the function template call

lcd.c(287:2): error: failed to generate expression

lcd.c(288:6): error: template arguments missing in the function template call

lcd.c(288:6): error: failed to generate expression

lcd.c(288:6): error: invalid operand 'LCD_Read() '

lcd.c(288:17): error: failed to generate expression

lcd.c(288:17): error: invalid operand '+ '

lcd.c(288:4): error: failed to generate expression

lcd.c(289:2): error: template arguments missing in the function template call

lcd.c(289:2): error: failed to generate expression

lcd.c(290:6): error: template arguments missing in the function template call

lcd.c(290:6): error: failed to generate expression

lcd.c(290:6): error: invalid operand 'LCD_Read() '

lcd.c(290:17): error: failed to generate expression

lcd.c(290:17): error: invalid operand '+ '

lcd.c(290:4): error: failed to generate expression

lcd.c(297:57): warning: local variable 'a' may be used uninitialized

lcd.c(298:57): warning: local variable 'b' may be used uninitialized

failure

Exit code was 1.

Removing target: lcd.obj

Failed to locate output file 'lcd.obj'

Done

 

Failed

Share this post


Link to post
Share on other sites

This sounds like a setup problem. Please check the LCD_ARGS definition you use in your code. Can you compile this code for 16F877 target?

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Hi Pavel,

 

I get the same errors when I try to compile for the 16f877 or 16f877a. To make sure we are in sync: I downloaded the code from Dave's link earlier in this forum. I modified the RW/RS/EN flags to match my real environment. (meaning in the original they were 1,2,0...and I set them to 0,2,1 (as shown below)

 

Here are my LCD_ARGS:

 

 

#define LCD_ARGS 2, /* Interface type: mode 0 = 8bit, 1 = 4bit(low nibble), 2 = 4bit(upper nibble) */ \

PORTB, TRISB, /* Data port and data port tris register */ \

PORTA, TRISA, /* Control port and control port tris register */ \

0, /* Bit number of control port is connected to RS */ \

2, /* Bit number of control port is connected to RW */ \

1

Share this post


Link to post
Share on other sites

Okay, I quit being lazy and TRUSTING the code! ;-)

 

I added:

 

#define LCD_WaitForNotBusy LCD_WaitForNotBusy<LCD_ARGS>

#define LCD_Read LCD_Read<LCD_ARGS>

 

 

to the bottom of lcd_Driver.h and now it compiles happily.

Share this post


Link to post
Share on other sites

Codesmith,

 

I meant to remove the files from my temporary link a long time ago.

The code here is a long time superceded - its gone now !

 

If you are looking for the lastest lcd_driver.h and sample program, look in the SourceBoost installation folder includes folder.

 

Also look in the SourceBoost samples folder for a complete LCD project that compiles with no problems.

 

I hope this helps.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...