View previous topic :: View next topic |
Author |
Message |
Guest
|
Program structure- whats wrong:*** Error 112 "F:\CCS_Fe |
Posted: Sun Jul 09, 2006 5:20 am |
|
|
I wrote a lot of programms with only one C-file. Now I want to structure my program but it doesnīt work. I always get this error:
*** Error 112 "F:\CCS_Feheler\Display.c" Line 31(0,1): Function used but not defined: ... main
This is the MAIN.C:
#include <16F877>
#include "main.h"
#include "Display.h"
int Command_int;
int Data_int;
void main (void)
{
set_tris_e(0x00);
set_tris_d(0x00);
Display_Command ( 63 ); // Display an (62 + 63)
for (;;)
{
output_high(CS1);
output_low(CS2);
Write_Display_Data ( 0x00 );
output_low(CS1);
}
}
This is the DISPLAY.C:
#include <16F877>
#include "main.h"
#include "Display.h"
void Display_Command ( Command_int )
{
output_low(ENABLE);
output_low(R_W);
output_low(D_I);
output_d(Command_int);
delay_us(1);
output_high(ENABLE);
delay_us(1);
output_low(ENABLE);
}
void Write_Display_Data ( Data_int )
{
output_low(ENABLE);
output_low(R_W);
output_high(D_I);
output_d(Data_int);
delay_us(1);
output_high(ENABLE);
delay_us(1);
output_low(ENABLE);
}
This is the MAIN.H:
void main ( void );
#FUSES HS,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOCPD,NOWRT
#use delay(clock=16000000)
#use STANDARD_IO (A)
#use STANDARD_IO (B)
#use STANDARD_IO (C)
#use FAST_IO (D)
#use FAST_IO (E)
#use I2C(MASTER, SDA=PIN_C4, SCL=PIN_C3, SLOW, FORCE_HW)
#define CS1 PIN_C1
#define CS2 PIN_C0
#define RESET PIN_E0
#define R_W PIN_C5
#define D_I PIN_E2
#define ENABLE PIN_E1
This is the DISPLAY.H:
//---------------------------------------------------------------------
// Function Prototypes
//---------------------------------------------------------------------
void Display_Command ( Command_int );
void Write_Display_Data ( Data_int );
I donīt understand it: the main function is defined in Main.c - isnīt it? |
|
|
Ttelmah Guest
|
|
Posted: Sun Jul 09, 2006 9:02 am |
|
|
The simple answer is that you cannot/must not 'prototype' the main function.
Best Wishes |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Sun Jul 09, 2006 9:05 am |
|
|
Your prototypes aren't correct. You need to explicitly specify the datatype in your prototypes.
Code: | void Display_Command(Command_int) |
should be
Code: | void Display_Command(int Command_int) |
both in your header file and at the start of your subroutine. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
sjbaxter
Joined: 26 Jan 2006 Posts: 141 Location: Cheshire, UK
|
|
Posted: Sun Jul 09, 2006 10:08 am |
|
|
... if you add the variable type to your function prototypes, you then don't need the declarations at the top of main :
Code: |
int Command_int;
int Data_int;
|
as these are not required as 'global' variables. _________________ Regards,
Simon. |
|
|
epideath
Joined: 07 Jun 2006 Posts: 47
|
|
Posted: Sun Jul 09, 2006 10:38 am |
|
|
All of the above are needed but also With CCS you need to tell the compiler to load the seperate C files
So you need to use
#include "Display.c" instead of "Display.h".
Once that the C file is loaded then the functions will be loaded and they don't necessarily have to be prototyped as they get loaded before the call to them.
But it doesn't hurt to have the prototype as something may change in the future or if you wanted to port this to some other compiler at some time.
But as far as multiple source files CCS basically looks at them as one big C file.
Hope that makes sense.
Regards |
|
|
|