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

problem using multiple files

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



Joined: 08 Feb 2010
Posts: 4

View user's profile Send private message

problem using multiple files
PostPosted: Sun Apr 11, 2010 5:11 pm     Reply with quote

Hi all.
I am trying to write a program using my picdem2 board, using the onboard lcd as an output for feedback. I want to use "Main.c" and #include "lcd.c" to drive my lcd, with "lcd.c" added to the "Other Files" folder as suggested in the forums.

If I write the Main procedure after the end of "lcd.c" and just use one source file it works fine.

If I remove the main program procedure and use it as "Main.c", the main source file, with #include "lcd.c" in the listing, and add "lcd.c" to the 'Other Files' folder, it doesn't work.

I have followed the recommendations I have found on here and in the CCS manual but I still cannot compile more than one source file. I don't know what I'm doing wrong.
I am using MPLab ver 8.10 with the picdem2plus board and a 16f877a MCU and my compiler is ver 4.099

Please help.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 11, 2010 6:20 pm     Reply with quote

Post a very short program that shows the problem.
manley



Joined: 08 Feb 2010
Posts: 4

View user's profile Send private message

PostPosted: Sun Apr 11, 2010 10:23 pm     Reply with quote

If this short procedure is added to the flex_lcd driver source file it compiles and works fine. If I separate them and make this file the main file and add the lcd driver to "Other Files" and #include it, it won't compile.
Code:

#include lcd.c

void main()
{
   lcd_init();
  delay_ms(6);
 
  printf(lcd_putc,"Hello World");
  printf(lcd_putc,"\nline 2");
  while(TRUE);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 11, 2010 11:34 pm     Reply with quote

You need to add the three lines shown in bold, and you need to put
quotes around the lcd.c file.
Quote:

#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)

#include "lcd.c"

void main()
{
lcd_init();
delay_ms(6);

printf(lcd_putc,"Hello World");
printf(lcd_putc,"\nline 2");
while(TRUE);
}

Is the lcd.c file the Flex lcd driver ? If so, you shouldn't give it the
same name as the CCS lcd driver (which is lcd.c). You should name
it flex_lcd.c.

What's the name of the main file that holds all the code shown above ?
Is it main.c ? If so, you should only have one file in the "Source Files"
list in the MPLAB. It should be main.c.
manley



Joined: 08 Feb 2010
Posts: 4

View user's profile Send private message

thank you..
PostPosted: Wed Apr 14, 2010 8:25 pm     Reply with quote

Thanks for your help. I appreciate it greatly. This is the first opportunity I have had to log back in so I have still to implement your suggestions. Please don't interpret the delay as lack of interest. Main.c it is.
I am also using the flex_lcd driver and I will rename that also. I am assuming all other source files will be added to the "Other Files"folder.
Thanks again
Manley.
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