CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

LCD configuration

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hisham.i



Joined: 22 Aug 2010
Posts: 43

View user's profile Send private message

LCD configuration
PostPosted: Mon Aug 23, 2010 12:33 am     Reply with quote

Hello,
Am using LCD with pic16f877. I was trying a small example to be sure that it works but the compiler displays many errors and I don't know where the problem is...
This is my code:
Code:

#include "LCD.c"
#include <16f877.h>
#use delay(clock = 4000000)

main()
{
   lcd_init();
   lcd_putc("hisham");
   
}

Where the file LDC.c is the driver installed with the ccs compiler.
Ttelmah



Joined: 11 Mar 2010
Posts: 19359

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 2:08 am     Reply with quote

The processor include, _must_ be first.
Similarly the clock definition, must be before you include anything that uses the clock.
You also need fuse definitions to setup the chip.
Then remember, that in CCS, if the code goes 'off the end', there is no operating system to 'return' to.
Hence your code should remain 'inside' what you are doing.

Change your file to:
Code:

#include <16f877.h> //Should always be the _first_ include
//Where are your FUSE defintions?. You need to tell the compiler
//How to setup the chip - assuming you have a 4MHz crystal
#fuses XT, NOWDT, NOPROTECT, PUT, NOBROWNOUT, NOLVP
#use delay(clock = 4000000) //Must be before anything that uses 'times'

//Now include the LCD driver
#include "LCD.c"

main() {
   
   lcd_init();
   lcd_putc("hisham");
   while (TRUE) ; //Keep the code from dropping off the end.
}


Best Wishes
hisham.i



Joined: 22 Aug 2010
Posts: 43

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 6:35 am     Reply with quote

Thanks for your reply,
i tried your code, but i still get the following code errors..
*** Error 23 "C:\Program Files (x86)\PICC\devices\16f84.h" Line 2(8,9): Can not change device type this far into the code
*** Error 48 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 43(1,24): Expecting a (
*** Error 43 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 43(5,6): Expecting a declaration
*** Error 43 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 43(6,7): Expecting a declaration
*** Error 43 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 43(7,8): Expecting a declaration
*** Error 43 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 44(1,6): Expecting a declaration
*** Error 43 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 44(6,7): Expecting a declaration
*** Error 43 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 44(7,8): Expecting a declaration
*** Error 43 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 44(8,9): Expecting a declaration
*** Error 43 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 45(1,2): Expecting a declaration
*** Error 28 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 47(21,22): Expecting an identifier
*** Error 43 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 47(22,23): Expecting a declaration
*** Error 43 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 48(1,2): Expecting a declaration
*** Error 43 "C:\Program Files (x86)\PICC\drivers\LCD.c" Line 49(1,2): Expecting a declaration
*** Error 90 "prog.c" Line 13(21,22): Attempt to create a pointer to a constant
15 Errors, 0 Warnings
dyeatman



Joined: 06 Sep 2003
Posts: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 6:50 am     Reply with quote

You did not try it exactly as it is posted because it compiles just fine for me.

This line:
Code:
*** Error 23 "C:\Program Files (x86)\PICC\devices\16f84.h" Line 2(8,9): Can not change device type this far into the code

says you changed the device type to a 16F84. Why did you do that??

To get the program to compile for a 16F84 you need to remove
just the NOBROWNOUT and NOLVP fuses from the end of the line. (that's all you need to do)

The above message indicates you have some other line prior to the processor declaration
which is not allowed. The processor declaration MUST be the first line in the file.

What version of the CCS compiler are you using?
The version will be in the format 3.xxx or 4.xxx (e.g. 3.249 or 4.109)
_________________
Google and Forum Search are some of your best tools!!!!
hisham.i



Joined: 22 Aug 2010
Posts: 43

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 10:32 am     Reply with quote

I created a project according to the tutorial in the following link using mplab :
http://www.ccsinfo.com/faq.php?page=ccs_mplab
and set the micro controller to pic16f877
and then i wrote the previous code, but i got the previous error i don't know why pic16f84A!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 10:40 am     Reply with quote

In addition to the other comments:

Read this thread about how to setup an MPLAB project with #included
driver files:
http://www.ccsinfo.com/forum/viewtopic.php?t=42061

Also, because you changed the PIC to 16F84a, the lcd.c driver will not
compile. That's because it's setup to use Port D, and the 16F84a doesn't
have a Port D. You must tell the lcd.c driver to use Port B.
See this thread which tells how to do it.
http://www.ccsinfo.com/forum/viewtopic.php?t=43170
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 10:55 am     Reply with quote

Could MPLAB be picking up a .h file that is listed in the project window but not explicitly called out in the .c file?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 11:14 am     Reply with quote

No, MPLAB ignores any .h files that you add to the Header Files section
of the Project Window. It doesn't try to compile them just because
they are in the list.
hisham.i



Joined: 22 Aug 2010
Posts: 43

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 12:30 pm     Reply with quote

My problem was in the driver code, I added few lines of code so the driver was not working properly. When I deleted the modifications the code works properly...
Thank you Very Happy
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group