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 support@ccsinfo.com

Is there any way to read PROCESSOR_TEXT in the project file

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



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

Is there any way to read PROCESSOR_TEXT in the project file
PostPosted: Wed Mar 05, 2014 1:34 pm     Reply with quote

I am using CCS 5.20 compiler
Is there any way to read PROCESSOR_TEXT from the project file, or get the processor identification that the compiler is set to.

I have a program that can run on different PICS, but it would be nice if I could use preprocessor commands to select the right pieces of code based on the processor. I understand once #device is set I can determine that, but setting #device based on the compiler setup would be great.
_________________
-Pete
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 05, 2014 1:44 pm     Reply with quote

The CCS function getenv() will get the PIC if you give it a parameter
of "DEVICE". You can then use #if and #elif statements to setup the
correct source code for a particular PIC. An example of this is given in:
Quote:
c:\program files\picc\drivers\pic18_usb.c
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Wed Mar 05, 2014 1:45 pm     Reply with quote

See the examples eg EX_8pin.c

Here are the extract of the top of the file.

Code:

#if defined(__PCB__)
#include <12C508.h>
#fuses INTRC,NOWDT,NOPROTECT, NOMCLR
#use delay(clock=4000000)
#define GP0 PIN_B0
#define GP1 PIN_B1
#define GP2 PIN_B2
#define GP3 PIN_B3
#define GP4 PIN_B4
#define GP5 PIN_B5

#elif defined(__PCM__)
#include <12C671.h>
#fuses INTRC,NOWDT,NOPROTECT, NOMCLR,NOLVP
#use delay(clock=4000000)
#define GP0 PIN_A0
#define GP1 PIN_A1
#define GP2 PIN_A2
#define GP3 PIN_A3
#define GP4 PIN_A4
#define GP5 PIN_A5

#endif


Don't know if this helps but that's my understanding of what you are asking.

Regards
pfournier



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

PostPosted: Wed Mar 05, 2014 2:28 pm     Reply with quote

PCM programmer

I was somehow under the impression that getenv returned the #device setting. Guess I was wrong, it does exactly what I want.

Thanks.
_________________
-Pete
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