View previous topic :: View next topic |
Author |
Message |
Grimmtooth
Joined: 16 Jul 2009 Posts: 5
|
Compiler Error w/ CCS Fns & User code - Pic24 |
Posted: Mon Jul 20, 2009 11:38 am |
|
|
I have installed CCS at work for the purpose of working with the Pic 24 line. Once installed, I wanted to test out the compiler and have found a major error in compiling any integrated program. Whenever I use a CCS function, the following line of user code delivers the error ," A numeric expression must appear here". When I eliminate ALL of the CCS functions but leave user code, that compiles properly. When I eliminate all user code and leave only the CCS functions, they compile correctly. Its only when using both that I receive an error.
Has anyone had these difficulties, or is there a setting or configuration that I am missing that is preventing integration?
My code was as follows (derived from CCS pic 24 wizard for the header).
Header:
Code: | #include <24FJ128GA010.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOJTAG //JTAG disabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOCOE //Device will reset into operational mode
#FUSES ICSP2 //ICD uses PGC2/PGD2 pins
#FUSES WINDIS //Watch Dog Timer in non-Window mode
#FUSES WPRES128 //Watch Dog Timer PreScalar 1:128
#FUSES WPOSTS16 //Watch Dog Timer PostScalar 1:32768
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FRC_PS //Fast RC Oscillator with Post Scaler
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOOSCIO //OSC2 is clock output
#FUSES NOPR //Pimary oscillaotr disabled
#use delay(clock=20000000) |
The main program is as follows: (and throws the error)
Code: | #include "C:\Documents and Settings\Bahamas Bound\My Documents\PCW\test\CompilerTest.h"
void main()
{
setup_spi(SPI_SS_DISABLED);
setup_spi2(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer1(TMR_DISABLED);
output_high(PIN_A0);
output_high(PIN_A5);
output_high(PIN_A7);
int a = 50; // This is the line that throws the error when this code is compiled.
} |
No error is generated in either compile when I eliminate either all CCS functions or the user assignment. Any help on this would be greatly appreciated. |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Mon Jul 20, 2009 11:49 am |
|
|
Declaration of the variable (in this case int a) should be at the beginning of Main() before the setup statements. _________________ Google and Forum Search are some of your best tools!!!! |
|
![](templates/subSilver/images/spacer.gif) |
Grimmtooth
Joined: 16 Jul 2009 Posts: 5
|
|
Posted: Mon Jul 20, 2009 12:00 pm |
|
|
That appears to fix the problem. I didn't realize the compiler required all main declarations to be at the beginning of main. My experience with C compilers has been on the PC side with my Microchip programming being completed in assembly. Thanks for the help. |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Jul 20, 2009 1:30 pm |
|
|
Interleaving of variable definitions and instructions is a C++ feature only. |
|
![](templates/subSilver/images/spacer.gif) |
|