View previous topic :: View next topic |
Author |
Message |
Harry Mueller
Joined: 17 Oct 2005 Posts: 116
|
include files oddities |
Posted: Sat Dec 10, 2005 11:14 am |
|
|
In some cases where I use include files I run into anomolies. Periodically functions called in the main() portion will not compile and the program will only start working when I cut and paste the function from the include file into the main program file. Any ideas on this?
I'm using version 3.239.
Thanks....Harry |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Dec 10, 2005 11:55 am |
|
|
Quote: | Periodically functions called in the main() portion will not compile and the
program will only start working when I cut and paste the function from the
include file into the main program file. | When you call a function, the compiler must have already seen either
the function definition or a "function prototype" before that line.
This means you should put your #include statements for your driver
files above main(). |
|
|
Harry Mueller
Joined: 17 Oct 2005 Posts: 116
|
|
Posted: Sat Dec 10, 2005 2:09 pm |
|
|
PCM programmer wrote: | When you call a function, the compiler must have already seen either
the function definition or a "function prototype" before that line.
This means you should put your #include statements for your driver
files above main(). |
This is probably too general for you to help me with right now. It's happened when I've had include files listed up with the preprossesor directives. I had even cut and pasted the function names from the include files into the function call but the compiler would say the function was undefined. When the whole function was added the problem disappeared.
I'll bring this up again when I have some specific code to point to.
Thanks.....Harry |
|
|
kypec
Joined: 20 Sep 2003 Posts: 54
|
Include Dir paths (maybe)? |
Posted: Mon Dec 12, 2005 1:08 am |
|
|
Hi Harry,
maybe I'm wrong but I have encountered very similar problem to yours
when I switched some of my projects from PCWH 3.190 to 3.239.
Afterwards, the predefined constants which come from standard include
header files <18F1320.h> like ADC_TIME_0_TAD for example, became INVALID suddenly
When I inspected the header files closely I found out that they (CCS) have changed those defines completely!!!
old version 3.190
Code: | // Constants used for SETUP_ADC() are:
#define ADC_OFF 0 // ADC Off
#define ADC_CLOCK_DIV_2 0x80
#define ADC_CLOCK_DIV_4 0x84
#define ADC_CLOCK_DIV_8 0x81
#define ADC_CLOCK_DIV_32 0x82
#define ADC_CLOCK_DIV_16 0x85
#define ADC_CLOCK_DIV_64 0x86
#define ADC_CLOCK_INTERNAL 0x83 // Internal 2-6us
// The following may be OR'ed in with the above using |
#define ADC_TIME_0_TAD 0x80
#define ADC_TIME_2_TAD 0x88
#define ADC_TIME_4_TAD 0x90
#define ADC_TIME_6_TAD 0x98
#define ADC_TIME_8_TAD 0xA0
#define ADC_TIME_12_TAD 0xA8
#define ADC_TIME_16_TAD 0xB0
#define ADC_TIME_20_TAD 0xB8
|
new version 3.239
Code: | // Constants used for SETUP_ADC() are:
#define ADC_OFF 0 // ADC Off
#define ADC_CLOCK_DIV_2 0x100
#define ADC_CLOCK_DIV_4 0x04
#define ADC_CLOCK_DIV_8 0x01
#define ADC_CLOCK_DIV_16 0x05
#define ADC_CLOCK_DIV_32 0x02
#define ADC_CLOCK_DIV_64 0x06
#define ADC_CLOCK_INTERNAL 0x07 // Internal 2-6us
// The following may be OR'ed in with the above using |
#define ADC_TAD_MUL_0 0x00
#define ADC_TAD_MUL_2 0x08
#define ADC_TAD_MUL_4 0x10
#define ADC_TAD_MUL_6 0x18
#define ADC_TAD_MUL_8 0x20
#define ADC_TAD_MUL_12 0x28
#define ADC_TAD_MUL_16 0x30
#define ADC_TAD_MUL_20 0x38
|
My workaround for the above problem is to add the paths to OLD VERSION FILES manually through Options | Include Dirs... menu option. Obviously, the older files got placed first in the list. |
|
|
Harry Mueller
Joined: 17 Oct 2005 Posts: 116
|
|
Posted: Mon Dec 12, 2005 8:32 am |
|
|
Thanks kypec, although I'm experiencing a different problem, that would certainly be something else to be aware of since I'm switching versions right now.
Regards.....Harry |
|
|
|