View previous topic :: View next topic |
Author |
Message |
smartsarath2003
Joined: 17 Mar 2005 Posts: 1
|
CCS Compilation Problem |
Posted: Thu Mar 17, 2005 3:53 pm |
|
|
Hai
I am Newbie trying to use CCS compiler along with MP Lab 5.7. When I add #include<16f876.h>, I am getting an error during the compilation saying duplicate define. The error is as fallows
Command line: "C:\PROGRA~1\PICC\CCSC.EXE +FM C:\HOBBY\PICFIL~1\CCSCOM~1\ADC\VOLT_ADC.C"
Error[125] C:\Program Files\PICC\Examples\16f876.h 37 : Duplicate #define
If I don't include the header file, all the varibles defined in C:\Program Files\PICC\Examples\16f876.h are comes up with errors as they are not defined. So waht I did was don't include header file and re-declare all req. variables.
The new problem is with using output_c( ) function. Error says Undefined identifier. Can any one help me to get out of this problem please
I had PCM V2.705 (PCW compiler IDE V2.15) installed and compile file inside MP Lab environment. The CCS tool suite aslo appears installed in MP Lab.
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu Mar 17, 2005 4:52 pm |
|
|
The #include should be the very first line of your program. You should also not have your own #device statement (it is in the file), except to set the ADC, and pointer length values. If you are setting these, it should be added as the line immediately after the #include. So for example, the following would be the typical first two lines of a 16F876 project:
Code: |
#INCLUDE <16F877.H>
#DEVICE *=16 ADC=10
|
output_c, should work, _unless_ you have enabled case significance with the #case operator. If so, all the CCS functions are upper case, and must be typed as such.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Mar 17, 2005 5:26 pm |
|
|
Ttelmah wrote: | The #include should be the very first line of your program. You should also not have your own #device statement (it is in the file), except to set the ADC, and pointer length values. If you are setting these, it should be added as the line immediately after the #include. So for example, the following would be the typical first two lines of a 16F876 project:
Code: |
#INCLUDE <16F877.H>
#DEVICE *=16 ADC=10
|
output_c, should work, _unless_ you have enabled case significance with the #case operator. If so, all the CCS functions are upper case, and must be typed as such.
Best Wishes |
I use case and always do ccs functions in lower case. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Thu Mar 17, 2005 7:16 pm |
|
|
Hai,
Here is my error message for output_c( );
Building VOLT_ADC.HEX...
Compiling VOLT_ADC.C:
Command line: "C:\PROGRA~1\PICC\CCSC.EXE +FM C:\HOBBY\PICFIL~1\CCSCOM~1\ADC\VOLT_ADC.C"
Error[52] C:\Program Files\PICC\Examples\16f876.h 69 : Undefined identifier
MPLAB is unable to find output file "VOLT_ADC.HEX". This may be due to a compile, assemble, or link process failure.
Build failed.
Statements I used are
set_tris_c(0x00);
output_c(0xff);
I also used the same lines said in the previous post
![Question](images/smiles/icon_question.gif) |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Mar 17, 2005 9:23 pm |
|
|
Look at line 69 of 16f876.h |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Thu Mar 17, 2005 9:53 pm |
|
|
According to my info the function output_c() was not supported in that version. That is why it is "undefined" . That function was added in version 3 sometime I believe...
Many of the functions defined in the current manual are not available back in version 2. Look in a version 2 manual or the help file. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 17, 2005 10:08 pm |
|
|
Hi Dave, you beat me to it, while I was typing in my post, but
since I put so much time into it, I'll post it anyway.
That version of the compiler came out in the early part of 2000.
It doesn't support the output_c() function.
You're probably looking at the modern compiler manual that you got
from the CCS website. It's not going to be accurate for your version.
This page is from the CCS website in April 2000. It shows the
functions that are likely supported by your version:
http://web.archive.org/web/20000325043631/ccsinfo.com/picc.html
There is a work-around for your problem. You can define a macro
which will do the same thing as the modern CCS function. See
the statements shown in bold, below:
#include <16F876.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
// Add the following two lines:
#byte port_c = 7
#define output_c(value) set_tris_c(0x00); port_c = (value)
main()
{
// Now you have an output_c() function:
output_c(0xff);
while(1);
}
Your other problem is the one where the compiler reports an error in
a .H file but the error is really in the .C source file. That problem
occurred in compiler versions around that era. It was due to some
strange interaction with MPLAB.
For more information on it, go to this thread from the old CCS board.
Stefan Daystrom has some good notes on how to prevent it.
http://www.pic-c.com/forum/old/messages/134.html |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Thu Mar 17, 2005 10:15 pm |
|
|
Hi PCM,
Thats OK, your answer was much better than mine!
Dave |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Fri Mar 18, 2005 7:34 pm |
|
|
Thanks that worked out with out any problem
Is there any way i could get old manual from the web
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
|