CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Compiler Error w/ CCS Fns & User code - Pic24

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Grimmtooth



Joined: 16 Jul 2009
Posts: 5

View user's profile Send private message

Compiler Error w/ CCS Fns & User code - Pic24
PostPosted: Mon Jul 20, 2009 11:38 am     Reply with quote

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.
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Jul 20, 2009 11:49 am     Reply with quote

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!!!!
Grimmtooth



Joined: 16 Jul 2009
Posts: 5

View user's profile Send private message

PostPosted: Mon Jul 20, 2009 12:00 pm     Reply with quote

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.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Jul 20, 2009 1:30 pm     Reply with quote

Interleaving of variable definitions and instructions is a C++ feature only.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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