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

Header Files

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



Joined: 15 Nov 2008
Posts: 1

View user's profile Send private message

Header Files
PostPosted: Sat Nov 15, 2008 7:27 pm     Reply with quote

Hi all!

I'm trying to use CCS (version 3.249) to build some code for a PIC18F8680. I'd like to code
dividing the code in "modules", where each module would have a header file
(.h) and a source file (.c). I have always coded this way with 8051, MSP and
others devices, but I just can't figure out what I'm doing wrong with CCS.
Any idea? Thank you so much!
Below the code I'm using to test and the error message I'm getting.

File: main.c
--------------

Code:

#include <18F8680.h>
#include "SerialI2C.h"

//Microcontroller configuration bits
#fuses HS,NOOSCSEN,NOPROTECT,NOCPD,NOLVP,MCLR,PUT,BROWNOUT,BORV42,WDT,WDT256   
#use delay(clock=20000000)   

void initPeripherals(void);

void main(void)
{
   initPeripherals();
   I2C_init();   
   while(1)
   {
      delay_ms(50);         
   }
}

void initPeripherals(void)
{
   
}



File SerialI2C.h:
------------------

Code:

#ifndef _SERIAL_I2C_
#define _SERIAL_I2C_

void I2C_init(void);

#endif //_SERIAL_I2C_


File SerialI2C.c:
-------------------

Code:

#include "SerialI2C.h"

void I2C_init(void)
{
    
}


Build message:
-----------------

Executing: "C:\Arquivos de programas\PICC\Ccsc.exe" +FH "main.c" +EXPORT I+="C:\Dashboard\Dashboard_fw2" +DF +LN +T -A +M -Z +Y=0 +EA
>>> Warning 203 "C:\Dashboard\Dashboard_fw2\main.c" Line 27(1,1): Condition always TRUE
C:\Dashboard\Dashboard_fw2\main.o ===> 0 Errors, 1 Warnings.
Executing: "C:\Arquivos de programas\PICC\Ccsc.exe" +FH "SerialI2C.c" +EXPORT I+="C:\Dashboard\Dashboard_fw2" +DF +LN +T -A +M -Z +Y=0 +EA
*** Error 128 "C:\Dashboard\Dashboard_fw2\SerialI2C.h" Line 4(1,2): A #DEVICE required before this line
C:\Dashboard\Dashboard_fw2\SerialI2C.o ===> 1 Errors, 0 Warnings.
Skipping link step. Not all sources built successfully.
BUILD FAILED: Sat Nov 15 21:42:03 2008
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 15, 2008 7:48 pm     Reply with quote

See the following links:

How to use multiple source files with MPLAB:
http://www.ccsinfo.com/forum/viewtopic.php?t=34046

More detailed information on using multiple files with MPLAB.
Read all the links in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=32221
Ttelmah
Guest







PostPosted: Sun Nov 16, 2008 3:22 am     Reply with quote

Also, the obvious thing that the configuration stuff needs to be before your own includes. So the order must be:
Code:

//Select processor
#include <18F8680.h>
//Configure processor
#fuses HS,NOOSCSEN,NOPROTECT,NOCPD,NOLVP,MCLR,PUT,BROWNOUT,BORV42,WDT,WDT256   
//Setup timings
#use delay(clock=20000000)   

//Now include your modules
#include "SerialI2C.h"


There is a lot of 'basic' stuff in the CCS code, which _requires_ the configuration data to be present (almost everything!. - serial handling, timings, etc. etc.).

Best Wishes
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