|
|
View previous topic :: View next topic |
Author |
Message |
Hagar
Joined: 15 Nov 2008 Posts: 1
|
Header Files |
Posted: Sat Nov 15, 2008 7:27 pm |
|
|
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
|
|
|
Ttelmah Guest
|
|
Posted: Sun Nov 16, 2008 3:22 am |
|
|
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 |
|
|
|
|
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
|