predefined symbols

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

predefined symbols

Jump to solution
1,145 Views
Masmiseim
Senior Contributor I

Hello,

 

Does the Codewarrior Compiler automatically create a symbol which indicates which controller is used? Just like other Embedded Compiler do.

Something like:

 

#define DEVICE K60_FX_512

#define DEVICE COLDFIRE_xxxx

 

I would like to enable processor specific Code automatically by checking those symbols (if they are available)

 

Thanks and Regards

 

Markus

Labels (1)
1 Solution
913 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hi Markus:

Well, the general answer would be no, you cannot change the controller. But if the project just involves crude source and header files (does not involve custom libraries, RTOS, stacks or similar), and you are switching to a MCU from same family, then you could reuse a project by modifying project settings, connection settings and files such as derivative.h and linker file.

But if in your mind is just to have a magic macro definition to switch between devices, that is not possible.

However you can have common sources and control the compilation with #if and #ifdef as usual.

Hope this clarifies a little more your doubts.

Regards!

Jorge Gonzalez

View solution in original post

0 Kudos
Reply
6 Replies
913 Views
Masmiseim
Senior Contributor I

Hello,

I think I found a solution. The project wizard creates the derivates.h File while setting up a new project. This includes the controller specific header File. I can use the macro definition of the Include Guard to check which controller is used.

Is it correct, that it is not possible to change the controller derivate used in a project?

Thanks and Regards

Markus

0 Kudos
Reply
913 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Markus:

You are correct, derivative.h includes a header file, and each MCU header file contains a macro definition. You may use that definition for your purpose. Does this clarify your doubt? Sorry, I did not fully understand your last question.

Regards!

Jorge Gonzalez

913 Views
Masmiseim
Senior Contributor I

Hello Jorge,

when I set up a new project, I have to choose the controller which I will develop for. There is no possibility to change the controller in an existing project. I have to set up a new project with the new controller. Is this correct?

Thanks and regards

Markus

0 Kudos
Reply
914 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hi Markus:

Well, the general answer would be no, you cannot change the controller. But if the project just involves crude source and header files (does not involve custom libraries, RTOS, stacks or similar), and you are switching to a MCU from same family, then you could reuse a project by modifying project settings, connection settings and files such as derivative.h and linker file.

But if in your mind is just to have a magic macro definition to switch between devices, that is not possible.

However you can have common sources and control the compilation with #if and #ifdef as usual.

Hope this clarifies a little more your doubts.

Regards!

Jorge Gonzalez

0 Kudos
Reply
913 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Markus:

CodeWarrior does not automatically create those symbols, but you can add them very easily either in your code or directly in the project settings, just by going to Project -> Properties. Look at the next screenshot:

Symbols.png

Hope this is useful!

Jorge Gonzalez

913 Views
Masmiseim
Senior Contributor I

Hello Jorge,

Thanks for the feedback. You are right; I could add such a symbol manually in the Project settings.

But when I change the target Controller of the Project, I have to change the symbol manually. And this will be forgotten often; ending up with strange errors. That’s why I’m searching for a solution which changes the symbol automatically.

Thanks and regards

Markus

0 Kudos
Reply