View previous topic :: View next topic |
Author |
Message |
pfournier
Joined: 30 Sep 2003 Posts: 89
|
Is there any way to read PROCESSOR_TEXT in the project file |
Posted: Wed Mar 05, 2014 1:34 pm |
|
|
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
|
|
Posted: Wed Mar 05, 2014 1:44 pm |
|
|
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
|
|
Posted: Wed Mar 05, 2014 1:45 pm |
|
|
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
|
|
Posted: Wed Mar 05, 2014 2:28 pm |
|
|
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 |
|
|
|