Translation - Japanese: PSoC®Creator™のコンパイラ引数を使用したファームウェア定数の編集 - KBA213561 - Community Translated (JA)
How do I edit firmware constants in PSoC Creator using compiler arguments without doing any modification in the code? When will this feature be useful to me?
When developing certain system level applications, it is common to place various debug code in the firmware. This debug code may involve changing a Components configuration in firmware. Usually, macros are defined to change configurations. You edit the macros to change configurations. However, these macros can be edited during compile time using compiler arguments. This avoids editing of the code.
Do the following to change the macros during compile time using compiler arguments.
- Open your project in PSoC Creator.
- Select Project > Build Settings.
- In the Build Settings dialog box, select Toolchain as follows:
- For PSoC 3: DP8051 Keil 9.51 or the latest version available
- For PSoC 4: ARM GCC 4.9 or the latest version available
- For PSoC 5LP: ARM GCC 4.9 or the latest version available
- On the left panel, expand the Toolchain that you selected, and then select Command Line from the Compiler group.
- On the right panel, select Custom Flags under Command Line, and then select the Edit button next to it.
- Declare the value in the format DEFINE (Variable name = value) in the text editor and click OK.
- Click OK to close the Build Settings dialog box.
For example, say your main.c file has the following format and that you are using Keil compiler:
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
#if RUN /* RUN is the macro used in this example */
You can define the macro RUN using the Custom Flag “DEFINE (Variable name = value)”. So, you add the following text in the Custom Flags text box, as shown in Figure 1:
Figure-1: Defining a value for a firmware constant in PSoC Creator
If you are using the GCC or MDK compiler, enter the command line argument in the format “–D RUN=0”.